single03.gms : Check singleton sets in put statement

Description

This test checks the behavior of Singleton Sets in put statements.

Contributor: Lutz Westermann, March 2014


Small Model of Type : GAMS


Category : GAMS Test library


Main file : single03.gms

$title 'Check singleton sets in put statement' (SINGLE03,SEQ=644)

$onText
This test checks the behavior of Singleton Sets in put statements.

Contributor: Lutz Westermann, March 2014
$offText


set i       / i1 t1, i2 t2, i3 t3, i4 t4 /
    j (i)   / i2*i4            some text /
    ii(i,i) / i1*i4.i1*i4                /;

singleton set is (i)   / i3    /
              is2(i)   / i1    /
              iis(i,i) / i3.i4 /;
alias(is,as);

parameter p(i); p(i) = ord(i);

file dummy /'have.txt'/; put dummy;
put i.tn(is):15      ' ' i.te(is):0                  /
    j.tn(is):15      ' ' j.te(is):0                  /
    is.tn(is):15     ' ' is.te(is):0     ' ' is.tl:0 /
    ii.tn(iis):15    ' ' ii.te(iis):0                /
    ii.tn(is,is2):15 ' ' ii.te(is,is2):0             /
    p.tn(is):15      ' ' p(is):0                     / ;
put '---';
loop(i,
   is(i)    = yes;
   is2(i)   = yes;
   iis(i,i) = yes;
   put / i.tn(is):15      ' ' i.te(is):0                  /
         j.tn(is):15      ' ' j.te(is):0                  /
         is.tn(is):15     ' ' is.te(is):0     ' ' is.tl:0 /
         ii.tn(iis):15    ' ' ii.te(iis):0                /
         ii.tn(is,is2):15 ' ' ii.te(is,is2):0             /
         p.tn(is):15      ' ' p(is):0                     / ;
)
put '---';
loop(i,
   is2(i)   = yes;
   put / i.tn(is):15      ' ' i.te(is):0                  /
         j.tn(is):15      ' ' j.te(is):0                  /
         is.tn(is):15     ' ' is.te(is):0     ' ' is.tl:0 /
         ii.tn(is,is2):15 ' ' ii.te(is,is2):0             /
         p.tn(is):15      ' ' p(is):0                     / ;
)
put '---' ;
loop(i,
   is(i)   = yes;
   put / i.tn(is):15        ' ' i.te(is):0                  /
         j.tn(is):15        ' ' j.te(is):0                  /
         is.tn(is):15       ' ' is.te(is):0     ' ' is.tl:0 /
         ii.tn('i2',is2):15 ' ' ii.te('i2',is2):0           /
         ii.tn('i2',is):15  ' ' ii.te('i2',is):0            /
         p.tn(is):15        ' ' p(is):0                     / ;
)
putclose

execute 'diff want.txt have.txt';
execute 'diff want.txt have.txt > diff.txt';
abort$errorlevel 'want differs from have: check diff.txt';

$onEcho > want.txt
i('i3')         t3
j('i3')         some text
is('i3')        i3 i3
ii('i3','i4')   i3.i4
ii('i3','i1')   i3.i1
p('i3')         3.00
---
i('i1')         t1
j('i1')         i1
is('i1')        i1 i1
ii('i1','i1')   i1.i1
ii('i1','i1')   i1.i1
p('i1')         1.00

i('i2')         t2
j('i2')         some text
is('i2')        i2 i2
ii('i2','i2')   i2.i2
ii('i2','i2')   i2.i2
p('i2')         2.00

i('i3')         t3
j('i3')         some text
is('i3')        i3 i3
ii('i3','i3')   i3.i3
ii('i3','i3')   i3.i3
p('i3')         3.00

i('i4')         t4
j('i4')         some text
is('i4')        i4 i4
ii('i4','i4')   i4.i4
ii('i4','i4')   i4.i4
p('i4')         4.00
---
i('i4')         t4
j('i4')         some text
is('i4')        i4 i4
ii('i4','i1')   i4.i1
p('i4')         4.00

i('i4')         t4
j('i4')         some text
is('i4')        i4 i4
ii('i4','i2')   i4.i2
p('i4')         4.00

i('i4')         t4
j('i4')         some text
is('i4')        i4 i4
ii('i4','i3')   i4.i3
p('i4')         4.00

i('i4')         t4
j('i4')         some text
is('i4')        i4 i4
ii('i4','i4')   i4.i4
p('i4')         4.00
---
i('i1')         t1
j('i1')         i1
is('i1')        i1 i1
ii('i2','i4')   i2.i4
ii('i2','i1')   i2.i1
p('i1')         1.00

i('i2')         t2
j('i2')         some text
is('i2')        i2 i2
ii('i2','i4')   i2.i4
ii('i2','i2')   i2.i2
p('i2')         2.00

i('i3')         t3
j('i3')         some text
is('i3')        i3 i3
ii('i2','i4')   i2.i4
ii('i2','i3')   i2.i3
p('i3')         3.00

i('i4')         t4
j('i4')         some text
is('i4')        i4 i4
ii('i2','i4')   i2.i4
ii('i2','i4')   i2.i4
p('i4')         4.00
$offEcho