prevwork1.gms : PreviousWork Test

Description

This model is a basic test to ensure that the command line
parameter previousWork works as expected.

Contributor: Lutz Westermann, February 2021


Small Model of Type : GAMS


Category : GAMS Test library


Main file : prevwork1.gms

$title PreviousWork Test (PREVWORK1,SEQ=854)

$onText
This model is a basic test to ensure that the command line
parameter previousWork works as expected.

Contributor: Lutz Westermann, February 2021
$offText

$onEchoV > test.gms
$if not set mode $set mode all

$ifI %mode%==restart $goTo restart
Set
   i 'canning plants' / seattle,  san-diego /
   j 'markets'        / new-york, chicago, topeka /;

Parameter
   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.8     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;

Variable
   x(i,j) 'shipment quantities in cases'
   z      'total transportation costs in thousands of dollars';

Positive Variable x;

Equation
   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), c(i,j)*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 /;

$ifI %mode%==save $exit

$label restart
solve transport using lp minimizing z;

display x.l, x.m;
$offEcho

$call.checkErrorLevel gams test.gms lo=%gams.lo% --mode=all gdx=all

$call.checkErrorLevel gams test.gms lo=%gams.lo% --mode=save s=1 previousWork=1
$call.checkErrorLevel gams test.gms lo=%gams.lo% --mode=restart r=1 gdx=restart

$call.checkErrorLevel gdxdiff all.gdx restart.gdx > %system.nullfile%

* Now, check for a specific, potential problematic suffix

$onEcho > genRestart.gms
Variable x;
Equation e;
e.. x =e= 1;
model m /e/;
m.savepoint = 8;
solve m min x use lp;
$offEcho

$onEchoV > cont.gms
display x.l;
execute 'rm -rf "%gams.scrDir%m_p.gdx"';
$offEcho


$call.checkErrorLevel gams genRestart.gms s=1 previousWork=1 a=c lo=%GAMS.lo%
$call.checkErrorLevel gams cont.gms r=1 lo=%GAMS.lo%