## Multiple run of Stochastic programming emp extension Topic is solved

questions about GAMS' tools
karacat
User
Posts: 6
Joined: 1 year ago

### Multiple run of Stochastic programming emp extension

I try to solve a two stage stochastic programming and ı adjust demand randvar as poisson distribution with 100 scenario to obtain 100 random demand values according to poisson distribution. but I want to do 100 run to apply sample avarage approximation method (SAA) to this problem. I wrote "while loop" for solve statement to solve the problem multiple times to have converged solution. Gams solves problem multiple times but in every solution demand scenarios don't change and solutions stay same in every run. How can ı overcome this problem. Thank you for your help.

abhosekar
Moderator
Posts: 232
Joined: 1 year ago

### Re: Multiple run of Stochastic programming emp extension

Inside your while loop, you have to tell GAMS which scenario you want to solve. I assume demand (let's say d) is a parameter you are using in your formuation. You also have a parameter containing demands for all scenarios (let's say demands(sc)) where sc is the set of scenarios. You can loop over the set of scenarios, and inside the loop you have to set d = demands(sc).

karacat
User
Posts: 6
Joined: 1 year ago

### Re: Multiple run of Stochastic programming emp extension

Thank you for your help. Could you please help me to understand where ı should add your suggestion in my code "d" is random var demand

file emp / '%emp.info%' /;
put emp '* problem %gams.i%'/;
\$onput
randvar d poisson 10
stage 2 In Ls d
stage 2 cons2
\$offput
putclose emp;

Set scen Scenarios / s1*s100 /;
Parameter
s_d(scen) Demand realization by scenario
s_In(scen) Units overproduction by scenario
s_Ls(scen) "units underproduction by scenario"
s_rep(scen,*) "scenario probability" / #scen.prob 0/;

Set dict / scen .scenario.''
d .randvar .s_d
In .level .s_In
Ls .level .s_Ls
'' .opt .s_rep
/;

option emp = lindo;
\$echo STOC_NSAMPLE_STAGE = 100 > lindo.opt
SSP1.optfile = 1;

while (rpl le 10000,
solve SSP1 min z use emp scenario dict;
rpl=rpl+1;
Display s_d, s_In, s_Ls, s_rep,x.l,y.l,r.l,z.l;
);

karacat
User
Posts: 6
Joined: 1 year ago

### Re: Multiple run of Stochastic programming emp extension

this is my code at the attached file to understand my mistake clearly
SSP_tek ürünlü _emp_v2.gms