Description
With GAMS 31 we introduced the capability to limit the domain of variables in the model statement. This test uses a dummy model to verify that this new feature leads to the same result as using explicit dollar conditions. The focus of this test is on non-trivial cases for the index use, like lag and lead operations, explicit labels or singleton sets. Contributor: Lutz Westermann, March 2020
Small Model of Type : GAMS
Category : GAMS Test library
Main file : limdom04.gms
$title Advanced test for limited domains for variables in model (limdom04,SEQ=815)
$onText
With GAMS 31 we introduced the capability to limit the domain of variables
in the model statement. This test uses a dummy model to verify that this new
feature leads to the same result as using explicit dollar conditions.
The focus of this test is on non-trivial cases for the index use, like
lag and lead operations, explicit labels or singleton sets.
Contributor: Lutz Westermann, March 2020
$offText
Set i / i1 * i20 /;
Alias (i,j,k,l);
Set sub(i,j,k);
Singleton Set si(i) / i12 /;
Alias (si,sj,sk);
sub(i,j,k)$(uniform(0,1)<0.2) = yes;
Positive Variable x(i,j,k);
Variable z;
Equation obj Dummy objective function
plainDLV Plain indices with Domain Limited Variables
plainDOL Plain indices using explicit DOLlar condition
lagLeadDLV Indices with lag and lead operators with Domain Limited Variables
lagLeadDOL Indices with lag and lead operators using explicit DOLlar condition
labelDLV Indices with explicit labels with Domain Limited Variables
labelDOL Indices with explicit labels using explicit DOLlar condition
singleDLV Indices with singleton sets with Domain Limited Variables
singleDOL Indices with singleton sets using explicit DOLlar condition
suffixDLV Using suffixes on variables with Domain Limited Variables
suffixDOL Using suffixes on variables using explicit DOLlar condition
;
obj.. z =e= 1;
plainDLV.. sum((i,j,k), x(i,j,k)) =l= 42;
plainDOL.. sum((i,j,k), x(i,j,k)$sub(i,j,k)) =l= 42;
lagLeadDLV.. sum((i,j,k), x(i-1,j+[2+6/3-ord(j)+card(k)],k+[min(5,ceil(sum(l,sqr(0.2))))])) =l= 42;
lagLeadDOL.. sum((i,j,k), x(i-1,j+[2+6/3-ord(j)+card(k)],k+[min(5,ceil(sum(l,sqr(0.2))))])$sub(i-1,j+[2+6/3-ord(j)+card(k)],k+[min(5,ceil(sum(l,sqr(0.2))))])) =l= 42;
labelDLV.. sum((j,k), x('i11',j,'i12')) =l= 42;
labelDOL.. sum((j,k), x('i11',j,'i12')$sub('i11',j,'i12')) =l= 42;
singleDLV.. sum((si,sj,sk(k)), x(si,sj,k)) =l= 42;
singleDOL.. sum((si,sj,sk(k)), x(si,sj,k)$sub(si,sj,k)) =l= 42;
Model mDLV / obj, plainDLV, lagLeadDLV, labelDLV, singleDLV, x(sub) /;
Model mDOL / obj, plainDOL, lagLeadDOL, labelDOL, singleDOL /;
option limrow = 0,
limcol = 0,
solprint = off
lp = convert;
solve mDLV min z use lp;
execute.CheckErrorLevel 'grep -v "LP written by GAMS" gams.gms > mDLV.gms';
solve mDOL min z use lp;
execute.CheckErrorLevel 'grep -v "LP written by GAMS" gams.gms > mDOL.gms';
execute.CheckErrorLevel '=diff -b mDLV.gms mDOL.gms';
$onSuffixDLVars
suffixDLV.. sum((i,j,k), x('i11',j,'i12' ) * x.l(i-1,j+[2+6/3-ord(j)+card(k)],k+[min(5,ceil(sum(l,sqr(0.2))))])) =l= 42;
suffixDOL.. sum((i,j,k), x('i11',j,'i12')$sub('i11',j,'i12') * x.l(i-1,j+[2+6/3-ord(j)+card(k)],k+[min(5,ceil(sum(l,sqr(0.2))))])$sub(i-1,j+[2+6/3-ord(j)+card(k)],k+[min(5,ceil(sum(l,sqr(0.2))))])) =l= 42;
Model mDLVSuf / obj, suffixDLV, x(sub) /;
Model mDOLSuf / obj, suffixDOL /;
option limrow = 0,
limcol = 0,
solprint = off
lp = convert;
solve mDLVSuf min z use lp;
execute.CheckErrorLevel 'grep -v "LP written by GAMS" gams.gms > mDLVSuf.gms';
solve mDOLSuf min z use lp;
execute.CheckErrorLevel 'grep -v "LP written by GAMS" gams.gms > mDOLSuf.gms';
execute.CheckErrorLevel '=diff -b mDLVSuf.gms mDOLSuf.gms';