implset2.gms : Test for Implicit Set Definition with default records

Description

This test ensures the implicitly defined set also get a record
if the defining symbol has default records.

Contributor: Lutz Westermann, January 2021


Small Model of Type : GAMS


Category : GAMS Test library


Main file : implset2.gms

$title 'Test for Implicit Set Definition with default records' (IMPLSET2,SEQ=853)

$onText
This test ensures the implicitly defined set also get a record
if the defining symbol has default records.

Contributor: Lutz Westermann, January 2021
$offText

Alias(u,*);

* 1: Use a parameter with 0 values
Set i(*);
Parameter p(i<) / i0 0
                  i1 1
                  i2 0
                  i3 3 /;
Set iWant / i0*i3 /
    iTest(u);

iTest(u) = iWant(u) xor i(u);
abort$card(iTest) iTest;

* 2: Use a table with 0 values
Set j(*);
Table ij(i,j<)
     j0  j1  j2 j3 j4
i0    0   0   0     3
i1    0   0   0     3 
i2    0   1   0     3 
i3    0   1   0     3 ;

Set jWant / j0*j2, j4 /
    jTest(u);

jTest(u) = jWant(u) xor j(u);
abort$card(jTest) jTest;

* 3: Use a variable with default values
Set k(*);
Variable x(k<) / l0.l        0
                 m0.m        0
                 upInf.up +INF
                 loInf.lo -INF /;

Set kWant / l0, m0, upInf, loInf /
    kTest(u);

kTest(u) = kWant(u) xor k(u);
abort$card(kTest) kTest;

* x has just default records -> card should be 0
abort$card(x) 'X should have just default records';

* 3: Use a variable table with default values
Set l(*);
Variable Table y(l<)
       l  m   up   lo
l0     0
m0        0
upInf       +INF
loInf            -INF ;

Set lWant / l0, m0, upInf, loInf /
    lTest(u);

lTest(u) = lWant(u) xor l(u);
abort$card(lTest) lTest;

* y has just default records -> card should be 0
abort$card(y) 'Y should have just default records';

* 4: Load a parameter with 0 values from GDX
Set m(*);
Parameter pGDX(m<);
Set mWant / 0*4 /
    mTest(u);

$gdxIn zero.gdx
$load pGDX=p

mTest(u) = mWant(u) xor m(u);
abort$card(mTest) mTest;