# two-stage modelling making expectation

3 views (last 30 days)
bus14 on 25 Apr 2019
Hi community,
I am busy modelling a two-stage optimization problem. In this first stage, I have to make an expectation of the optimal value of the second stage E[Q(x,D)] in order to find an optimal value of X. I find it difficult to put this expectation in Matlab.In this case D is a normally distributed vector for demand. The first stage is to Min c.'*x+E[Q(x,D)] x>0The used codes are:
%first stage
%Min c.'*x+E[Q(x,D)]
c=[3];
E[Q(x,D)];
%Q(x,D)=(l-q).'*z(*)-s.'*y(*);
%s.t x=y(*)+A1.'*z(*);
f= [c.', E];%How to define E
Aeq = [];
beq = [];
lb = [0];%x>0
ub = [Inf];
sol = linprog(f,[],[],Aeq,beq,lb,ub);
x = [sol(1)]
The second stage is Min (l-q).'*z-s.'*y
s.t. y=x-A1.'*z , 0<z<d, y>0 and its code which already works
l = 0.25;
q = 2;
s = 1;
A = 1;
x = 20;
d = 80;
f= [-s.', (l-q).'];
Aeq = [1, A];
beq = x;
lb = [0, 0];
ub = [Inf, d];
sol = linprog(f,[],[],Aeq,beq,lb,ub);
y = sol(1)
z = sol(2)
The difficulty for me is how to define E[Q(x,D)] as the expectation of the second stage.
Does anyone maybe have advice how I could do this?
Thankyou!