% Probabilistic constraint 

% Example taken from [Kizbun, Kan 1996] "Reserving Air Tickets"



% Parameters

c = [300 30 1000 280 250];
n  =[350 350];

mu = 1/20; 
alpha = 0.99;

% Calculations
F_b = icdf('Exponential',alpha,mu);

f_a = (1-exp(-20*F_b))/(1-exp(-20)) - alpha;

a_b = log(1-((1-exp(-20*icdf('Exponential',alpha,mu)))/(1-exp(-20)) ...
     -alpha)*(1-exp(-20)))/-20;

f = [-c(1) c(5) 1];

A = [0 1 0;
    c(4)*a_b 0 -1;
    (c(4)*a_b+c(2)*(1-a_b)) 0 -1;
    (c(4)*a_b+c(3)*(1-a_b)) -(c(3)-c(2)) -1;
    c(4)*F_b 0 -1;
    (c(4)*F_b+c(2)*(1-F_b)) 0 -1;
    (c(4)*F_b+c(3)*(1-F_b)) -(c(3)-c(2)) -1];

b = [n(2) 0 c(2)*n(1) c(3)*n(1) 0 c(2)*n(1) c(3)*n(1)]';

lb = [0 0 0]';
ub = [inf inf inf]';

[x, fval, EF] = linprog(f,A,b,[],[],lb,ub);

