cmi01.gms : Test captureModelInstance option with all solveLink combinations

Description

In this model, we use different solveLink options in combination with captureModelInstance=1.

Contributor: Michael Bussieck, October 2020


Small Model of Type : GAMS


Category : GAMS Test library


Main file : cmi01.gms

$title 'Test captureModelInstance option with all solveLink combinations' (CMI1,SEQ=837)

$onText
In this model, we use different solveLink options in combination with captureModelInstance=1.

Contributor: Michael Bussieck, October 2020
$offText


$onEcho > t.gms
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 /;
transport.solveLink=%solveLink%;
solve transport using lp minimizing z;
$if set gridSolve
f=readyCollect(transport.handle);f=handleCollect(transport.handle);display$sleep(1)'sleep';f=handleDelete(transport.handle);
$offEcho

$call.checkErrorLevel gams t.gms lo=2 captureModelInstance=1 --solveLink=0
$echoN '$setGlobal scalarModel ' > setsm.gms
$call grep "Writing Gams" t.log | cut -c25- >> setsm.gms
$include setsm
$call.checkErrorLevel gams %scalarModel% lo=2

$call.checkErrorLevel gams t.gms lo=2 captureModelInstance=1 --solveLink=1
$echoN '$setGlobal scalarModel ' > setsm.gms
$call grep "Writing Gams" t.log | cut -c25- >> setsm.gms
$include setsm
$call.checkErrorLevel gams %scalarModel% lo=2

$call.checkErrorLevel gams t.gms lo=2 captureModelInstance=1 --solveLink=2
$echoN '$setGlobal scalarModel ' > setsm.gms
$call grep "Writing Gams" t.log | cut -c25- >> setsm.gms
$include setsm
$call.checkErrorLevel gams %scalarModel% lo=2

$call.checkErrorLevel gams t.gms lo=3 captureModelInstance=1 --solveLink=3 --gridSolve=1 > t.log
$echoN '$setGlobal scalarModel ' > setsm.gms
$call grep "Writing Gams" t.log | cut -c25- >> setsm.gms
$include setsm
$call.checkErrorLevel gams %scalarModel% lo=2

$call.checkErrorLevel gams t.gms lo=3 captureModelInstance=1 --solveLink=4 > t.log
$echoN '$setGlobal scalarModel ' > setsm.gms
$call grep "Writing Gams" t.log | cut -c25- >> setsm.gms
$include setsm
$call.checkErrorLevel gams %scalarModel% lo=2

$call.checkErrorLevel gams t.gms lo=2 captureModelInstance=1 --solveLink=5
$echoN '$setGlobal scalarModel ' > setsm.gms
$call grep "Writing Gams" t.log | cut -c25- >> setsm.gms
$include setsm
$call.checkErrorLevel gams %scalarModel% lo=2

$call.checkErrorLevel gams t.gms lo=3 captureModelInstance=1 --solveLink=6 --gridSolve=1 lp=cplex > t.log
$echoN '$setGlobal scalarModel ' > setsm.gms
$call grep "Writing Gams" t.log | cut -c25- >> setsm.gms
$include setsm
$call.checkErrorLevel gams %scalarModel% lo=2

$call.checkErrorLevel gams t.gms lo=3 captureModelInstance=1 --solveLink=7 lp=cplex > t.log
$echoN '$setGlobal scalarModel ' > setsm.gms
$call grep "Writing Gams" t.log | cut -c25- >> setsm.gms
$include setsm
$call.checkErrorLevel gams %scalarModel% lo=2

$setEnv ZIPSCRDIR_PGAMS xxx
$setEnv DEBUG_PGAMS 2
$call rm -rf myscrdir && mkdir myscrdir
$call.checkErrorLevel gams t.gms lo=3 --solveLink=0 scrdir=myscrdir > t.log
$echoN '$setGlobal zipFile ' > setzf.gms
$call grep "Issuing command: gmszip" t.log | cut -d" " -f5 >> setzf.gms
$include setzf
$ifThen %system.fileSys%==UNIX
$  call.checkErrorLevel rm -rf myscrdir && gmsunzip -qq %zipFile% && gmsgenux.out myscrdir/gamscntr.%gams.scrExt% cplex > /dev/null
$else
$  call.checkErrorLevel rm -rf myscrdir && gmsunzip -qq %zipFile% && gmsgennx.exe myscrdir\gamscntr.%gams.scrExt% cplex > NUL
$endIf