$ontext Transportation problem with stochastic demands. DECIS formulation Erwin Kalvelagen, January 2003 $offtext sets i 'factories' /f1*f3/ j 'distribution centers' /d1*d5/ s 'individual scenarios' /lo,mid,hi/ ; parameter capacity(i) /f1 500, f2 450, f3 650/; table demand(j,s) 'possible outcomes for demand' lo mid hi d1 150 160 170 d2 100 120 135 d3 250 270 300 d4 300 325 350 d5 600 700 800 ; table prob(j,s) 'probabilities for table demand' lo mid hi d1 .25 .50 .25 d2 .25 .50 .25 d3 .25 .50 .25 d4 .30 .40 .30 d5 .30 .40 .30 ; loop(j, abort$(abs(sum(s,prob(j,s))-1)>0.001) "probabilities don't add up"); table transcost(i,j) 'unit transportation cost' d1 d2 d3 d4 d5 f1 2.49 5.21 3.76 4.85 2.07 f2 1.46 2.54 1.83 1.86 4.76 f3 3.26 3.08 2.60 3.76 4.45 ; scalar prodcost 'unit production cost' /14/; scalar price 'sales price' /24/; scalar wastecost 'cost of removal of overstocked products' /4/; *----------------------------------------------------------------------- * CORE MODEL *----------------------------------------------------------------------- variables ship(i,j) 'shipments' product(i) 'production' sales(j) 'sales (actually sold)' waste(j) 'overstocked products' profit ; positive variables ship,product,sales,waste; equations obj production(i) selling(j) ; obj.. profit =e= sum(j, price*sales(j)) - sum((i,j), transcost(i,j)*ship(i,j)) - sum(j, wastecost*waste(j)) - sum(i,prodcost*product(i)); production(i).. product(i) =e= sum(j, ship(i,j)); product.up(i) = capacity(i); selling(j).. sum(i, ship(i,j)) =e= sales(j)+waste(j); sales.up(j) = demand(j,'mid'); *----------------------------------------------------------------------- * STAGE 1/STAGE 2 CLASSIFICATION *----------------------------------------------------------------------- * * variables * ship.stage(i,j) = 1; waste.stage(j) = 2; sales.stage(j) = 2; * * equations * production.stage(i) = 1; selling.stage(j) = 2; *----------------------------------------------------------------------- * WRITING THE .STG FILE *----------------------------------------------------------------------- file stg /model.stg/; put stg; put "INDEP DISCRETE"/; loop(j, loop(s, put "UP BND sales ",j.tl,demand(j,s)," PERIOD2",prob(j,s)/; ); ); putclose stg; *----------------------------------------------------------------------- * output a MINOS option file *----------------------------------------------------------------------- file mopt / MINOS.SPC /; put mopt; put "begin"/; put "rows 250"/; put "columns 250"/; put "elements 10000"/; put "end"/; putclose; *----------------------------------------------------------------------- * Solve with default settings *----------------------------------------------------------------------- option lp=decism; model m /obj,production,selling/; solve m maximizing profit using lp; *----------------------------------------------------------------------- * Solve exactly using DECIS option ISTRAT 4 *----------------------------------------------------------------------- file decopt / decism.opt /; put decopt; put '4 "ISTRAT"'/; putclose; m.optfile=1; solve m maximizing profit using lp;