```
Sets
i "products" /i1, i2, i3/
s "sites" /s1, s2, s3/
c "customers" /c1, c2, c3/;
Parameters
fc Fixed production cost for product i on unit j at site s
vc Variable production cost for product i on unit j at site s
t Transportation cost of product i from site s to customer c
h Inventory holding cost for product i at site s
ss Safety stock violation penalty cost for product i at site s
MRL Minimum production run length for product i on unit j at site s
R Production rate of product i on unit j at site s
PC /s1 190, s2 220, s3 250/
IL Safety stock for product i at site s
INV inventory
d demand
m lost sales
;
Table fc
s1 s2 s3
i1 6.9 6.9 6.9
i2 9.2 9.2 9.2
i3 5.5 5.5 5.5;
Table vc
s1 s2 s3
i1 2.1 2.3 2.2
i2 2.5 2.0 2.3
i3 3.1 2.9 2.6;
Table MRL
s1 s2 s3
i1 70 70 70
i2 60 60 60
i3 50 50 50;
Table R
s1 s2 s3
i1 0.5 0.7 0.45
i2 0.6 0.55 0.3
i3 0.85 0.7 0.5;
Table m
c1 c2 c3
i1 10.0 9.0 9.5
i2 10.5 11.8 10.8
i3 10.0 12.0 8.5;
Table d
c1 c2 c3
i1 160 185 125
i2 180 175 150
i3 190 180 155;
Table IL
s1 s2 s3
i1 10 10 10
i2 20 20 20
i3 15 15 15;
Table INV
s1 s2 s3
i1 0 0 0
i2 7 7 7
i3 5 5 5;
Table h
s1 s2 s3
i1 1.8 1.6 1.7
i2 2.1 2.0 2.3
i3 2.5 2.4 2.1;
Table t
c1 c2 c3
s1 2.9 9.7 8.0
s2 1.7 3.8 4.4
s3 2.3 3.4 7.1;
Table ss
s1 s2 s3
i1 2.7 2.1 2.3
i2 2.6 2.3 2.4
i3 2.9 2.5 2.2;
Positive Variables
A(i,s) Amount of product i available for supply at site s
P(i,s) Production amount of product i on unit j at site s
RL(i,s) Production run length of product i on unit j at site s
SP(s,c) Supply of product i from site s to customer c
ID(i,s) Safety stock deviation of product i at site s
IS(i,c) Shortage of product i at customer c;
Binary Variable
Y(i,s) Binary variable indicating whether product i is manufactured at site s;
Variable
Z objective;
Equations
obj
eq1 Equation 1 shows the production amount of a particular product obtained from production rate of product and the run length of product
eq2 Equation 2 models the capacity constraints
eq3 Equation 3 sets lower bound for the product run length
eq4 The amount available for supply in the logistics phase following the manufacturing stage is defined by Equation 4
eq5 Equation 5 presents the inventory level which is determined by the amount available for supply and the actual supply
eq6
eq7
eq8
eq9
eq10
;
obj.. Z=e=sum((i,s),fc(i,s)*Y(i,s)) + sum((i,s),vc(i,s)*P(i,s)) + sum((s,c),t(s,c)*SP(s,c))+ sum((i,s),h(i,s)*INV(i,s)) + sum((i,s),ss(i,s)*ID(i,s)) + sum((i,c),m(i,c)*IS(i,c));
eq1(i,s).. P(i,s) =e= R(i,s) * RL(i,s);
eq2(s).. sum(i,RL(i,s)) =l= PC(s);
eq3(i,s).. MRL(i,s)*Y(i,s) =l= RL(i,s);
eq4(i,s).. A(i,s) =e= INV(i,s) + P(i,s);
eq5(i,s).. INV(i,s) =e= A(i,s) - sum((c),SP(s,c));
eq6(i,c).. sum(s,SP(s,c)) =l= d(i,c);
eq7(i,c).. d(i,c) - sum(s,SP(s,c)) =l= IS(i,c);
eq8(i,c).. IS(i,c) =l= d(i,c);
eq9(i,s).. IL(i,s) - INV(i,s) =l= ID(i,s);
eq10(i,s).. ID(i,s) =l= IL(i,s);
Model project / all /;
File emp / '%emp.info%' /;
put emp '* problem %gams.i%'/;
$onput
randvar d discrete 0.7 160 0.7 185 0.7 125 0.5 180 0.5 175 0.5 150 0.8 190 0.8 180 0.8 155
stage 2 SP, ID, IS
stage 2 eq5, eq6, eq7, eq8, eq9, eq10
$offput
putclose emp;
Set scen "scenarios" / scen1*scen9 /;
Parameter
s_d(scen) "demand realization by scenario"
s_Y(scen) "units bought by scenario"
s_P(scen)
s_A(scen)
s_RL(scen)
s_rep(scen,*) "scenario probability" / #scen.prob 0/;
Set dict / scen .scenario.''
d .randvar .s_d
Y .level .s_Y
P .level .s_P
A .level .s_A
RL .level .s_RL
'' .opt .s_rep /;
solve project max z use EMP scenario dict;
display s_d, s_Y, s_A, s_P, s_RL, s_rep;
```

Hello, everyone! I’m solving bi-level optimization problem. I followed the steps on the GAMS site (Stochastic Programming part).

However, I get an error in the last sentence. (Solve and Display part)

Can anyone help me?