single05.gms : Check correctness of set attributes for singleton sets

Description

```This test checks that the set attributes for singleton sets are correct. This is
done for assignments and in equations, both inside and outside of a loop.

Contributor: Lutz Westermann, October 2015
```

Small Model of Type : GAMS

Category : GAMS Test library

Main file : single05.gms

``````\$title 'Check correctness of set attributes for singleton sets' (SINGLE05,SEQ=687)

\$ontext
This test checks that the set attributes for singleton sets are correct. This is
done for assignments and in equations, both inside and outside of a loop.

Contributor: Lutz Westermann, October 2015
\$offtext

set           i     / 1*10 /
im(i) / 3    /;
singleton set is(i) / 3    /;

scalar m,s;

* Check set attributes for singleton sets in simple assignments
m = sum(im,im.rev);
s = is.rev;
abort\$(m<>s) 'Unexpected difference', m, s;

m = sum(im,im.pos);
s = is.pos;
abort\$(m<>s) 'Unexpected difference', m, s;

m = sum(im,im.off);
s = is.off;
abort\$(m<>s) 'Unexpected difference', m, s;

m = sum(im,im.uel);
s = is.uel;
abort\$(m<>s) 'Unexpected difference', m, s;

m = sum(im,im.val);
s = is.val;
abort\$(m<>s) 'Unexpected difference', m, s;

m = sum(im,im.len);
s = is.len;
abort\$(m<>s) 'Unexpected difference', m, s;

* Check set attributes for singleton sets in simple assignments within a loop
loop(i,
im(im)=no;
im(i)=yes;
is(i)=yes;

m = sum(im,im.rev);
s = is.rev;
abort\$(m<>s) 'Unexpected difference', m, s;

m = sum(im,im.pos);
s = is.pos;
abort\$(m<>s) 'Unexpected difference', m, s;

m = sum(im,im.off);
s = is.off;
abort\$(m<>s) 'Unexpected difference', m, s;

m = sum(im,im.uel);
s = is.uel;
abort\$(m<>s) 'Unexpected difference', m, s;

m = sum(im,im.val);
s = is.val;
abort\$(m<>s) 'Unexpected difference', m, s;

m = sum(im,im.len);
s = is.len;
abort\$(m<>s) 'Unexpected difference', m, s;
);

* Check set attributes for singleton sets in equations
variable revs, revm
poss, posm
offs, offm
uels, uelm
vals, valm
lens, lenm
z;
equation erevs, erevm
eposs, eposm
eoffs, eoffm
euels, euelm
evals, evalm
elens, elenm
obj;

obj.. z =e= 1;

erevs.. revs =e= is.rev;
erevm.. revm =e= sum(im,im.rev);

eposs.. poss =e= is.pos;
eposm.. posm =e= sum(im,im.pos);

eoffs.. offs =e= is.off;
eoffm.. offm =e= sum(im,im.off);

euels.. uels =e= is.uel;
euelm.. uelm =e= sum(im,im.uel);

evals.. vals =e= is.val;
evalm.. valm =e= sum(im,im.val);

elens.. lens =e= is.len;
elenm.. lenm =e= sum(im,im.len);

model mymodel /all/;

solve mymodel us lp max z;

abort\$(revs.l<>revm.l) 'Unexpected difference', revs.l, revm.l;
abort\$(poss.l<>posm.l) 'Unexpected difference', poss.l, posm.l;
abort\$(offs.l<>offm.l) 'Unexpected difference', offs.l, offm.l;
abort\$(uels.l<>uelm.l) 'Unexpected difference', uels.l, uelm.l;
abort\$(vals.l<>valm.l) 'Unexpected difference', vals.l, valm.l;
abort\$(lens.l<>lenm.l) 'Unexpected difference', lens.l, lenm.l;

* Check set attributes for singleton sets in equations within a loop
loop(i,
im(im)=no;
im(i)=yes;
is(i)=yes;

solve mymodel us lp max z;

abort\$(revs.l<>revm.l) 'Unexpected difference', revs.l, revm.l;
abort\$(poss.l<>posm.l) 'Unexpected difference', poss.l, posm.l;
abort\$(offs.l<>offm.l) 'Unexpected difference', offs.l, offm.l;
abort\$(uels.l<>uelm.l) 'Unexpected difference', uels.l, uelm.l;
abort\$(vals.l<>valm.l) 'Unexpected difference', vals.l, valm.l;
abort\$(lens.l<>lenm.l) 'Unexpected difference', lens.l, lenm.l;
);
``````
GAMS Development Corp.
GAMS Software GmbH

General Information and Sales
U.S. (+1) 202 342-0180
Europe: (+49) 221 949-9170