Tomatoes exercise.docx (13.7 KB)

tomatoe 2.gms (2.65 KB)

Dear sir,

I am struggling to solve and model of the follwoing problem. I need to make a multi stage stochastic model to solve it through GAMS. I wrote the code but this gives error. I am pasting the problem first and them code. Any kind hearted individual, would you please solve the problem with multi stage and EMP annotation.

problem: Tomatoes Inc. (TI) produces tomato paste, ketchup, and salsa from four resources:

labor, tomatoes, sugar, and spices.

Each box of the tomato paste requires:

0.5 labor hours, 1.0 crate of tomatoes, no sugar, and 0.25 can of spice. A

ketchup box requires 0.8 labor hours, 0.5 crate of tomatoes, 0.5 sacks of sugar,

and 1.0 can of spice. A salsa box requires 1.0 labor hour, 0.5 crate of tomatoes,

1.0 sack of sugar, and 3.0 cans of spice.

The company is deciding production for the next three periods.

It is restricted to using 200 hours of labor, 250 crates of tomatoes, 300 sacks of sugar, and 100

cans of spices in each period at regular rates.

The company can, however, pay for additional resources at a cost of 2.0 per labor hour, 0.5 per tomato crate,

1.0 1.0 per sugar sack, and 1.0 per spice can.

The regular production costs for each product are 1.0 for tomato paste, 1.5 for ketchup, and 2.5 for salsa.

Demand is not known with certainty until after the products are made in each.

period. TI forecasts that in each period two possibilities are equally likely, corresponding.

to a good or bad economy.

In the good case, 200 boxes of tomato

paste, 40 boxes of ketchup, and 20 boxes of salsa can be sold.In the bad case,

these values are reduced to 100 , 30 , and 5 , respectively.

Any surplus production is stored at costs of

GAMS CODE:

Set

i resources / lab,tom,sug,spce/

j product /pst,ktc,sal /

t time period /t1*t3/

k possible output /good,bad/;

table demk(j,k) demand k mapping

good bad

pst 200 100

ktc 40 30

sal 20 5;

;

table rp(j,i) “resource-product matix-unit product”

lab tom sug spce

pst 0.5 1.0 0.0 0.25

ktc 0.8 0.5 0.5 1.0

sal 1.0 0.5 1.0 3.0;

Parameter

rmax(i) /lab 200,tom 250,sug 300, spce 100/

adlcost(i) /lab 2.0,tom 0.5,sug 1.0, spce 1.0/

prdcost(j) /pst 1.0,ktc 1.5,sal 2.5/

dem(j,t) demand of product

pr probability of being good_or bad demand /0.5/

invcost(j) inventory cost_or suplus prodc cost /pst 0.5 ,ktc 0.25,sal 0.2/

udc(j) unmet demand cost /pst 2.0,ktc 3.0,sal 6.0/

;

dem(j,t)=sum(k,pr*demk(j,k));

display dem;

Variable

x(j,t) production for the next three periods

y(i,t) addtional resource requirement

w(j,t) amount surplus product

m(j,t) unmet demand

z cost of everything

;

Positive Variable x,y,w,m;

Equation

objective

resourceqn(i,t)

demandeqn(t)

;

objective…z=e= sum((j,t), x(j,t)*prdcost(j))

- sum((i,t),y(i,t)*adlcost(i))

+sum((j,t),invcost(j)*w(j,t))

+sum((j,t), m(j,t)*udc(j));

*for fixed j --i varies

demandeqn(t)…sum(j,x(j,t)-m(j,t)+w(j,t-1)+w(j,t))=g=sum(j,dem(j,t));

resourceqn(i,t)…sum(j,x(j,t)*rp(j,i))=l=rmax(i);

model stochtom /all/;

solve stochtom min z using mip;

*EMP annotation

file emp /%emp.info%/;

put emp ‘*problem %gams.i’/;

put emp; emp.nd=6;

$onPut

stage 1 x(j,‘t1’) resourceqn(i,‘t1’)

stage 2 x(j,‘t2’) dem(j,‘t2’) y(i,‘t2’) w(j’t2’) resourceqn(i,‘t2’) m(j,‘t2’) demandeqn(‘t2’)

stage 3 x(j,‘t’) dem(j,‘t3’) y(i,‘t3’) w(j’t3’) resourceqn(i,‘t3’) m(j,‘t3’) demandeqn('t3)

$offput

putclose emp;

Set scen Scenarios / s1*s1000 /;
Parameter
srep(scen,*) scenario attributes / #scen.pr 0 /

s_dem(scen,t) Demand realization by scenario

s_x(scen,t) Units produced by scenario

s_y (scen,t) additional amount by secenaro

s_w(scen,t) Units stored by scenario

s_m(scen,t);

Set dict /

scen .scenario.’ ’

dem .randvar .s_dem

x .level .s_x

y .level .s_y

w .level .s_w

m. level.s_m/;

solve stochtom min z using emp scenario dict;

display s_dem, s_x, s_y, s_w,s_m;