gussex1.gms : Simple GUSS example

**Description**

GUSS is a procedure that facilitates optimization of a collection of related problems modifying data in those problems. GUSS allows one to solve the collection of models in a single pass without needing repeated solves or a LOOP over multiple solves. GUSS is not really a solver but rather organizes and passes data to and from another LP, NLP, MIP etc solver. This is all done in a faster fashion than say when using multiple solves through the GAMS Loop command. In particular GUSS runs the model repeatedly over user specified data for model parameters that collectively define alternative scenarios to be run. In doing this it repeatedly updates the base model with the altered scenario data, then solves the updated model for that scenario and saves user chosen results for each scenario. GUSS was developed by Michael R. Bussieck, Michael C. Ferris, and Timo Lohmann. It is documented in http://www.gams.com/modlib/adddocs/gusspaper.pdf and in the GUSS section of the solver manual. Use of GUSS for an existing model requires six steps 1. Definition of scenarios to run 2. Definition of parameters holding scenario specific data for the items in the model that to be changed 3. Definition of parameters that will hold scenario specific model results for the items that the user wished to save 4. Definition of a set that tells GUSS the scenarios to run, data to change and results to save 5. Modification of the solve statement to identify that scenarios will be run 6. Development of code to report the scenario results These 6 steps are demonstrated used the simple transport model

**References**

- Kallrath, J, Ed, Algebraic Modeling Systems: Modeling and Solving Real World Optimization Problems. Springer, Berlin Heidelberg, 2012.
- Bussieck, M R, Ferris, M C, and Lohmann, T, GUSS: Solving Collections of Data Related Models within GAMS. In Kallrath, J, Ed, Algebraic Modeling Systems: Modeling and Solving Real World Optimization Problems. Springer, Berlin Heidelberg, 2012, pp. 35-56.

**Small Model of Type :** LP

**Category :** GAMS Model library

**Main file :** gussex1.gms

```
$Title Simple GUSS example (GUSSEX1,SEQ=398)
$ontext
GUSS is a procedure that facilitates optimization of a collection of related
problems modifying data in those problems. GUSS allows one to solve the
collection of models in a single pass without needing repeated solves or a
LOOP over multiple solves. GUSS is not really a solver but rather organizes and
passes data to and from another LP, NLP, MIP etc solver. This is all done in a
faster fashion than say when using multiple solves through the GAMS Loop command.
In particular GUSS runs the model repeatedly over user specified data for model
parameters that collectively define alternative scenarios to be run. In doing
this it repeatedly updates the base model with the altered scenario data, then
solves the updated model for that scenario and saves user chosen results for
each scenario.
GUSS was developed by Michael R. Bussieck, Michael C. Ferris, and Timo Lohmann.
It is documented in http://www.gams.com/modlib/adddocs/gusspaper.pdf and in the
GUSS section of the solver manual.
Use of GUSS for an existing model requires six steps
1. Definition of scenarios to run
2. Definition of parameters holding scenario specific data for the items
in the model that to be changed
3. Definition of parameters that will hold scenario specific model results
for the items that the user wished to save
4. Definition of a set that tells GUSS the scenarios to run, data to change
and results to save
5. Modification of the solve statement to identify that scenarios will be run
6. Development of code to report the scenario results
These 6 steps are demonstrated used the simple transport model
Bussieck, M R, Ferris, M C, and Lohmann, T, GUSS: Solving Collections of Data
Related Models within GAMS. In Kallrath, J, Ed, Algebraic Modeling Systems: Modeling
and Solving Real World Optimization Problems. Springer, Berlin Heidelberg, 2012, pp. 35-56.
$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 / base, run1, run2 /
Table newsupply(ScenariosToRun,i) updater for a
seattle san-diego
base 350 600
run1 300 650
run2 400 550 ;
Table newdemand(ScenariosToRun,j) updater for b
new-york chicago topeka
base 325 300 275
run1 325 300 275
run2 350 300 250 ;
Set mattrib / system.GUSSModelAttributes /;
Parameter
resultantx(ScenariosToRun,i,j) collector for level of x
srep(ScenariosToRun, mattrib) model attibutes like modelstat etc
o(*) GUSS options / SkipBaseCase 1 /
Set dict / ScenariosToRun.scenario.''
o. opt .srep
a. param .newsupply
b. param .newdemand
x. level .resultantx /
Solve transport using lp minimizing z scenario dict;
* The solve statement from the line above results can also be expressed
* in traditional GAMS syntax as follows:
$ontext
loop(ScenariosToRun,
a(i) = newsupply(ScenariosToRun,i);
b(j) = newdemand(ScenariosToRun,j);
Solve transport using lp minimizing z;
resultantx(ScenariosToRun,i,j) = x.l(i,j));
$offtext
Option resultantx:0:1:2;
Display resultantx;
Set Error(scenariostorun) Empty solution;
Error(scenariostorun) = sum((i,j),resultantx(scenariostorun,i,j)) = 0;
Abort$card(error) 'Missing solution for some scenarios', error;
```