attrib01.gms : Test attribute setting and preservation in ConvertD

Description

With this test we check that the stage/scale/prior attribute gets
preserved as expected in ConvertD.

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 ConvertD (attrib01,SEQ=834)

$ontext
With this test we check that the stage/scale/prior attribute gets
preserved as expected in ConvertD.

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=convertd;

* By default, continuous and discrete variables should maintain the "stage" attribute in ConvertD
solve m min cont use mip;
execute.checkErrorlevel 'grep "x1.stage = 2;" gams.gms > %nul%';
execute.checkErrorlevel 'grep "b2.stage = 3;" gams.gms > %nul%';

* With "priorOpt = 1", continuous variables should maintain the "stage" attribute in ConvertD,
* 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 > %nul%';
execute.checkErrorlevel 'grep "b2.prior = 3;" gams.gms > %nul%';


* With "scaleOpt = 1", discrete variables should maintain the "stage" attribute in ConvertD,
* 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 > %nul%';
execute.checkErrorlevel 'grep "b2.stage = 3;" gams.gms > %nul%';

* 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%';