My questions are:
- I want to know if sets can be combined with the set scen. something like this:
Set demand scenarios with uncertain parameter /1*3/;
…and under EMP, I have
Set scen scenarios /s1*s30/
My questions are:
…and under EMP, I have
Set scen scenarios /s1*s30/
@ola I am struggling to understand your question. Maybe you can try to elaborate?
The EMP SP documentation is a good starting point for stochastic programming with GAMS and EMP.
I meant this, see the code below. Is it okay to have two sets
Sets
t two days shelf-life /t1 * t2/
tl three to four days shelf-life /t3 * t4/
tb five to six days shelf-life /t5 * t6/
o demand scenarios with uncertain parameter /o1*o3/;
Scalar c Purchase costs per unit / 30 /
p Penalty shortage cost per unit unsatisfied demand / 5 /
h Holding cost per unit leftover / 10 /
v Revenue per unit sold / 60 /
vl Revenue per unit for salvage of less-quality sold / 18 /
vb Revenue per unit for salvage of low quality sold / 7.5 /
* Random parameters
d Demand / 63 /;
Variable Z Profit;
Positive Variables
X Units bought
I Inventory
L Lost sales
S Units of quality sold, one to two days
Sl Units of less-quality sold, three to four days
Sb Units of bad-quality sold, five to six days;
Equations Row1, Row2, Row3, Row4, Row5, Row6, Profit;
*units bought, X, order atleast 1(serves as a dummy constraint for stage 1);
Row1.. X =g= 1;
*demand for quality;
Row2.. sum(t,(S)) =l= D;
*demand for less quality;
Row3.. sum(tl,(Sl)) =l= D;
*demand for bad quality;
Row4.. sum(tb,(Sb)) =l= D;
*total demand for quality is the sum of units sold in the quality, low-quality and bad quality;
Row5.. D =e= sum(o,(S + Sl + Sb)) + L;
*total inventory (I) and units of quality sold (S), less-quality sold (Sl), bad quality sold (Sb) and lost sales;
Row6.. I =e= [(X - (S + Sl + Sb))];
*Profit, to be maximized;
Profit.. Z =e= sum(t,sum(tl,sum(tb,sum(o,(v*S)+(vl*Sl)+(vb*Sb))))) - (c*X) - (h*I) - (p*L);
Model GAMSPracticeExample / all /;
file emp / '%emp.info%' /; put emp '* problem %gams.i%'/;
$onPut
randvar d discrete 0.7 45
0.2 40
0.1 50
stage 2 I L S Sl Sb d
stage 2 Row1 Row2 Row3 Row4 Row5 Row6
$offPut
putclose emp;
Set scen Scenarios / s1*s6 /;
Parameter
s_d(scen) Demand realization by scenario
s_X(scen) Units bought by scenario
s_S(scen) Units of quality sold by scenario
s_Sl(scen) Units of less quality sold by scenario
s_Sb(scen) Units of bad quality sold by scenario;
Set dict / scen .scenario.''
d .randvar .s_d
S .level .s_s
Sl .level .s_sl
Sb .level .s_sb
X .level .s_X /;
solve GAMSPracticeExample max z use emp scenario dict;
Display s_D, s_X, s_S, s_Sl, s_Sb;
@ola Sorry, but even with the code, I don’t get what you are trying to implement. There is a set o
with three elements which, based on the explanatory text, seem to be meant for demand scenarios. But at the same time you are using the emp info file to create scenarios for demand parameter d
. This is completely independent from set o
.
The way o
is used in the model also does not look right. An expression sum(o,(S + Sl + Sb))
, where you sum over elements in o
without using any symbol indexed with o
is just the same as 3*(S + Sl + Sb)
(because o
has three elements).
Since I don’t understand what you are trying to achieve it is a bit hard to help. I think it could make sense for you to take a look at the EMP Library and filter for the newsboy
examples that demonstrate different ways of dealing with multiple random variables.
I hope this helps!
Fred
Thank you so much Fred. I am looking at determining safety stock of perishables with a life span of few days. However, I want to consider any unsold items at salvage price. The goal is to maximize profit and minimize perishable food waste.
The sets “t” represents shelf-life of the perishables at different quality stage. I used “o” to represent omega, representing the demand parameters.
Please, does this gives more insight to my problem?
Hi ola,
Thanks for explaining the problem background.
You alraedy made the demand parameter d
a random variable and you are turning this into a stochastic program via EMP. So still don’t understand what the o
is needed for, sorry.