Description
Contributor: Michael R. Bussieck, April 2014
Small Model of Type : GAMS
Category : GAMS Test library
Main file : gussskip.gms
$title Simple GUSS example with skipped scenario (GUSSSKIP,SEQ=651)
$onText
Contributor: Michael R. Bussieck, April 2014
$offText
Sets
i canning plants / seattle, san-diego /
j markets / new-york, chicago, topeka / ;
Parameters
a(i) capacity of plant i in cases
/ seattle 350
san-diego 600 /
b(j) demand at market j in cases
/ new-york 325
chicago 300
topeka 275 / ;
Table d(i,j) distance in thousands of miles
new-york chicago topeka
seattle 2.5 1.7 1.8
san-diego 2.5 1.4 ;
Scalar f freight in dollars per case per thousand miles /90/ ;
Parameter c(i,j) transport cost in thousands of dollars per case ;
c(i,j) = f * d(i,j) / 1000 ;
Variables
x(i,j) shipment quantities in cases
z total transportation costs in thousands of dollars ;
Positive Variable x ;
Equations
cost define objective function
supply(i) observe supply limit at plant i
demand(j) satisfy demand at market j ;
cost .. z =e= sum((i,j), f * d(i,j) / 1000 *x(i,j)) ;
supply(i) .. sum(j, x(i,j)) =l= a(i) ;
demand(j) .. sum(i, x(i,j)) =g= b(j) ;
Model transport /all/ ;
Set ScenariosToRun scenarios / s1*s10 /
Alias (ScenariosToRun, s);
Parameter
newsupply(s,*) updater for a
newdemand(s,*) updater for b
resultantx(s,i,j) collector for level of x;
newdemand(s,j) = normal(b(j),0.1);
newsupply(s,i) = normal(a(i),0.1);
* Make sure we don't go infeasible
newdemand(s,'total') = sum(j,newdemand(s,j));
newsupply(s,'total') = sum(i,newsupply(s,i));
newsupply(s,i)$(newdemand(s,'total')>newsupply(s,'total')) =
newsupply(s,i)*(newdemand(s,'total')+1)/newsupply(s,'total');
* Clear Total otherwise we get unmatched records in GUSS
newdemand(s,'total') = 0;
newsupply(s,'total') = 0;
Parameter o(*) / SolveEmpty eps /
sr(s,*) / #s.ModelStat na /;
Set gs(s) scenarios per GUSS run
dict / s. scenario.''
o. opt .sr
a. param .newsupply
b. param .newdemand
x. level .resultantx /;
set se(s) / s1 /;
sr(se,'modelstat') = na;
newdemand(se,j) = 0; newsupply(se,i) = 0;
o('SolveEmpty') = eps;
option solveopt=merge;
Solve transport using lp minimizing z scenario dict;
abort$(sr('s1','modelstat')<>na) 'expect skipped s1', sr;
option solveopt=replace;
Solve transport using lp minimizing z scenario dict;
abort$(sr('s1','modelstat')<>0) 'expect skipped s1', sr;
o('SolveEmpty') = 1;
option solveopt=merge;
Solve transport using lp minimizing z scenario dict;
abort$(sr('s1','modelstat')<>1) 'expect solved s1', sr;
****
se('s5') = yes;
sr(se,'modelstat') = na;
newdemand(se,j) = 0; newsupply(se,i) = 0;
o('SolveEmpty') = 1;
option solveopt=merge;
Solve transport using lp minimizing z scenario dict;
abort$(sr('s1','modelstat')<>1) 'expect solved s1', sr;
abort$(sr('s5','modelstat')<>na) 'expect skipped s5', sr;
option solveopt=replace;
Solve transport using lp minimizing z scenario dict;
abort$(sr('s1','modelstat')<>1) 'expect solved s1', sr;
abort$(sr('s5','modelstat')<>0) 'expect skipped s5', sr;
o('SolveEmpty') = 2;
option solveopt=merge;
Solve transport using lp minimizing z scenario dict;
abort$(sr('s1','modelstat')<>1) 'expect solved s1', sr;
abort$(sr('s5','modelstat')<>1) 'expect solved s5', sr;
****
se('s10') = yes;
sr(se,'modelstat') = na;
newdemand(se,j) = 0; newsupply(se,i) = 0;
o('SolveEmpty') = 2;
option solveopt=merge;
Solve transport using lp minimizing z scenario dict;
abort$(sr('s1','modelstat')<>1) 'expect solved s1', sr;
abort$(sr('s5','modelstat')<>1) 'expect solved s5', sr;
abort$(sr('s10','modelstat')<>na) 'expect skipped s10', sr;
option solveopt=replace;
Solve transport using lp minimizing z scenario dict;
abort$(sr('s1','modelstat')<>1) 'expect solved s1', sr;
abort$(sr('s5','modelstat')<>1) 'expect solved s5', sr;
abort$(sr('s10','modelstat')<>0) 'expect skipped s10', sr;
o('SolveEmpty') = 3;
option solveopt=merge;
Solve transport using lp minimizing z scenario dict;
abort$(sr('s1','modelstat')<>1) 'expect solved s1', sr;
abort$(sr('s5','modelstat')<>1) 'expect solved s5', sr;
abort$(sr('s10','modelstat')<>1) 'expect solved s10', sr;