single01.gms : Check handling of singleton sets

Description

```This test checks that the singleton sets can be used as expected
when strictSingleton=0

Contributor: Lutz Westermann, January 2014
```

Small Model of Type : GAMS

Category : GAMS Test library

Main file : single01.gms

``````\$title 'Check handling of singleton sets' (SINGLE01,SEQ=639)

\$ontext
This test checks that the singleton sets can be used as expected
when strictSingleton=0

Contributor: Lutz Westermann, January 2014
\$offtext

set i /i1*i3/
j /j1*j3/
k /k1*k3/
l /l1*l3/;

singleton set si(i)    /i2/
sk(k)    /k2/
sl(l)    /l2/
sij(i,j) /i2.j2/
sjk(j,k) /j2.k2/
skl(k,l) /k2.l2/ ;

parameter pi(i)
pii(i,i)
pij(i,j)
pijk(i,j,k)
pijkl(i,j,k,l);

alias (i,a);
pi(i)          =      ord(i);
pij(i,j)       = 10  *ord(i)+    ord(j);
pii(i,a)       = 10  *ord(i)+    ord(a);
pijk(i,j,k)    = 100 *ord(i)+10 *ord(j)+   ord(k);
pijkl(i,j,k,l) = 1000*ord(i)+100*ord(j)+10*ord(k)+ord(l);

scalar x,y,z;

x = pi(si);
y = sum(si,pi(si));
abort\$(x<>y) 'Unexpected difference',x,y;
loop(i,
si(i)=yes;
x = pi(si);
y = sum(si,pi(si));
);
abort\$(x<>y) 'Unexpected difference',x,y;

option strictSingleton = 0;
z = 0;
while(z<=2,
si(i)=yes;
x = pi(si);
y = sum(si,pi(si));
z = z+1;
);
abort\$(x<>y) 'Unexpected difference',x,y;
for(z=1 to 2,
si(i)=yes;
x = pi(si);
y = sum(si,pi(si));
);
abort\$(x<>y) 'Unexpected difference',x,y;
z = 0;
repeat(
si(i)=yes;
x = pi(si);
y = sum(si,pi(si));
z = z+1;
until(z>2));
abort\$(x<>y) 'Unexpected difference',x,y;

x = pij(sij);
y = sum(sij,pij(sij));
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,j),
sij(i,j)=yes;
x = pij(sij);
y = sum(sij,pij(sij));
);
abort\$(x<>y) 'Unexpected difference',x,y;

loop(k,
x = pijkl(sij,k-pi(si),sl);
y = sum((sij,sl), pijkl(sij,k-sum(si,pi(si)),sl));
);
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,j,k),
sij(i,j)=yes;
sl(l)   =yes;
x = pijkl(sij,k-pi(si),sl);
y = sum((sij,sl), pijkl(sij,k-sum(si,pi(si)),sl));
);
abort\$(x<>y) 'Unexpected difference',x,y;

loop(k,
x = sum(l,pijk(sij,k-pi(si)));
y = sum(l,sum(sij, pijk(sij,k-sum(si,pi(si)))));
);
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,j,k),
sij(i,j)=yes;
si(i)   =yes;
x = sum(l,pijk(sij,k-pi(si)));
y = sum(l,sum(sij, pijk(sij,k-sum(si,pi(si)))));
);
abort\$(x<>y) 'Unexpected difference',x,y;

x = pijk(sij,sk);
y = sum((sij,sk),pijk(sij,sk));
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,j,k),
sij(i,j)=yes;
sk(k)   =yes;
x = pijk(sij,sk);
y = sum((sij,sk),pijk(sij,sk));
);
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,j),
sij(i,j)=yes;
x = pijk(sij,sk);
y = sum((sij,sk),pijk(sij,sk));
);
abort\$(x<>y) 'Unexpected difference',x,y;
loop(k,
sk(k)=yes;
x = pijk(sij,sk);
y = sum((sij,sk),pijk(sij,sk));
);
abort\$(x<>y) 'Unexpected difference',x,y;

x = pijkl(si,sjk,sl);
y = sum((si,sjk,sl),pijkl(si,sjk,sl));
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,j,k,l),
si(i)   =yes;
sjk(j,k)=yes;
sl(l)   =yes;
x = pijkl(si,sjk,sl);
y = sum((si,sjk,sl),pijkl(si,sjk,sl));
);
loop((j,k,l),
sjk(j,k)=yes;
sl(l)   =yes;
x = pijkl(si,sjk,sl);
y = sum((si,sjk,sl),pijkl(si,sjk,sl));
);
loop((i,l),
si(i)   =yes;
sl(l)   =yes;
x = pijkl(si,sjk,sl);
y = sum((si,sjk,sl),pijkl(si,sjk,sl));
);
loop((i,j,k),
si(i)   =yes;
sjk(j,k)=yes;
x = pijkl(si,sjk,sl);
y = sum((si,sjk,sl),pijkl(si,sjk,sl));
);
abort\$(x<>y) 'Unexpected difference',x,y;

x = pijkl(si,'j1',skl);
y = sum((si,skl),pijkl(si,'j1',skl));
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,k,l),
si(i)   =yes;
skl(k,l)=yes;
x = pijkl(si,'j1',skl);
y = sum((si,skl),pijkl(si,'j1',skl));
);
abort\$(x<>y) 'Unexpected difference',x,y;

x = sum(j,pijkl(si,j,skl));
y = sum(j,sum((si,skl),pijkl(si,j,skl)));
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,k,l),
si(i)   =yes;
skl(k,l)=yes;
x = sum(j,pijkl(si,j,skl));
y = sum(j,sum((si,skl),pijkl(si,j,skl)));
);
abort\$(x<>y) 'Unexpected difference',x,y;

x = pijkl(sij,skl);
y = sum((sij,skl),pijkl(sij,skl));
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,j,k,l),
sij(i,j)=yes;
skl(k,l)=yes;
x = pijkl(sij,skl);
y = sum((sij,skl),pijkl(sij,skl));
);
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,j),
sij(i,j)=yes;
x = pijkl(sij,skl);
y = sum((sij,skl),pijkl(sij,skl));
);
abort\$(x<>y) 'Unexpected difference',x,y;
loop((k,l),
skl(k,l)=yes;
x = pijkl(sij,skl);
y = sum((sij,skl),pijkl(sij,skl));
);
abort\$(x<>y) 'Unexpected difference',x,y;

loop(i,
x = pijkl(i-pi(si),sjk,sl);
y = sum((sjk,sl), pijkl(i-sum(si,pi(si)),sjk,sl));
);
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,j,k,l),
si(i)=yes;
sjk(j,k)=yes;
sl(l)=yes;
x = pijkl(i-pi(si),sjk,sl);
y = sum((sjk,sl), pijkl(i-sum(si,pi(si)),sjk,sl));
);
abort\$(x<>y) 'Unexpected difference',x,y;

loop(i,
x = pijkl(i-pi(si),sjk,sl);
y = sum((sjk), pijkl(i-sum(si,pi(si)),sjk,'l2'));
);
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,j,k),
si(i)=yes;
sjk(j,k)=yes;
x = pijkl(i-pi(si),sjk,sl);
y = sum((sjk), pijkl(i-sum(si,pi(si)),sjk,'l2'));
);
abort\$(x<>y) 'Unexpected difference',x,y;

alias(si,sai);
x = pi(sai);
y = sum(sai,pi(sai));
abort\$(x<>y) 'Unexpected difference',x,y;
loop(i,
sai(i)=yes;
x = pi(sai);
y = sum(sai,pi(sai));
);
abort\$(x<>y) 'Unexpected difference',x,y;

x = pii(si,sai);
y = sum((si,sai),pii(si,sai));
abort\$(x<>y) 'Unexpected difference',x,y;
loop(i,
si(i)=yes;
sai(i)=yes;
x = pii(si,sai);
y = sum((si,sai),pii(si,sai));
);
abort\$(x<>y) 'Unexpected difference',x,y;

x = pii(si,si);
y = sum((si),pii(si,si));
abort\$(x<>y) 'Unexpected difference',x,y;
loop(i,
si(i)=yes;
x = pii(si,si);
y = sum((si),pii(si,si));
);
abort\$(x<>y) 'Unexpected difference',x,y;

alias(sjk,sajk);
loop(i,
x = pijkl(i-pi(si),sajk,sl);
y = sum((sajk,sl), pijkl(i-sum(si,pi(si)),sajk,sl));
);
abort\$(x<>y) 'Unexpected difference',x,y;
loop((i,j,k),
si(i)    =yes;
sajk(j,k)=yes;
sl(l)    =yes;
x = pijkl(i-pi(si),sajk,sl);
y = sum((sajk,sl), pijkl(i-sum(si,pi(si)),sajk,sl));
);
abort\$(x<>y) 'Unexpected difference',x,y;

set u / 1*10 /;
singleton set su(u) /5/;

x = su.val;
y = sum(su,su.val);
abort\$(x<>y) 'Unexpected difference',x,y;

x = 0; y = 0;
loop(u,
su(u) = yes;
x = x + su.val;
y = y + sum(su,su.val);
);
abort\$(x<>y) 'Unexpected difference',x,y;
``````
GAMS Development Corp.
GAMS Software GmbH

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