Description
With this test we check that the stage/scale/prior attribute gets preserved as expected in Convert. Contributor: Lutz Westermann, October 2020
Small Model of Type : GAMS
Category : GAMS Test library
Main file : attrib01.gms
$title Test attribute setting and preservation in Convert (attrib01,SEQ=834)
$onText
With this test we check that the stage/scale/prior attribute gets
preserved as expected in Convert.
Contributor: Lutz Westermann, October 2020
$offText
$onEcho > mod.gms
Variable cont;
Binary Variable disc;
Equation dummy;
dummy.. cont =e= disc;
Model m /all/;
$offEcho
$include mod.gms
cont.stage = 2;
disc.stage = 3;
option mip=convert;
* By default, continuous and discrete variables should maintain the "stage" attribute in Convert
solve m min cont use mip;
execute.checkErrorlevel 'grep "x1.stage = 2;" gams.gms > %system.nullFile%';
execute.checkErrorlevel 'grep "b2.stage = 3;" gams.gms > %system.nullFile%';
* With "priorOpt = 1", continuous variables should maintain the "stage" attribute in Convert,
* but discrete ones should have the "prior" attribute
m.priorOpt = 1;
solve m min cont use mip;
execute.checkErrorlevel 'grep "x1.stage = 2;" gams.gms > %system.nullFile%';
execute.checkErrorlevel 'grep "b2.prior = 3;" gams.gms > %system.nullFile%';
* With "scaleOpt = 1", discrete variables should maintain the "stage" attribute in Convert,
* but continuous ones should be scaled in the equations
m.priorOpt = 0;
m.scaleOpt = 1;
solve m min cont use mip;
execute.checkErrorlevel 'grep "2*x1" gams.gms > %system.nullFile%';
execute.checkErrorlevel 'grep "b2.stage = 3;" gams.gms > %system.nullFile%';
* There should be an error, when setting the prior attribute for continuous variables
* or the scale attribute for discrete ones
$onEcho > err.gms
$include mod.gms
cont.prior = 2;
$if errorfree $abort 'prior attribute should not be allowed for continuous variables'
$clearError
disc.scale = 2;
$if errorfree $abort 'scale attribute should not be allowed for discrete variables'
$clearError
$offEcho
execute.checkErrorlevel 'gams err.gms a=c lo=%GAMS.lo%';