alias01.gms : Check handling of multi-dimensional aliases

Description

This test checks that the alias statement can be used on multi-dimensional sets
as well.

Contributor: Lutz Westermann, November 2013


Small Model of Type : GAMS


Category : GAMS Test library


Main file : alias01.gms

$title 'Check handling of multi-dimensional aliases' (ALIAS01,SEQ=637)

$ontext
This test checks that the alias statement can be used on multi-dimensional sets
as well.

Contributor: Lutz Westermann, November 2013
$offtext


Set i           / i0*i9 /
    j           / j0*j9 /
    k           / k0*k9 /
    ijk (i,j,k) / #i.#j.#k /
    ijkL(i,j,k);
Alias (ijk, ijkA, ijkA2);

abort$(card(ijkA) <> card(ijk) ) 'Card of ijkA and ijk differ';

Set check(i,j,k);
check(ijk) = not ijkA(ijk);
abort$card(check) 'Not all elememts of ijk are in ijkA', check;

check(ijkA) = not ijk(ijkA);
abort$card(check) 'Not all elememts of ijkA are in ijk', check;

execute_unload 'test' ijkA,ijk;
execute_load   'test' ijkL=ijkA;

abort$(card(ijkL) <> card(ijk) ) 'Card of ijkL and ijk differ';

check(ijk) = not ijkL(ijk);
abort$card(check) 'Not all elememts of ijk are in ijkL', check;

check(ijkL) = not ijk(ijkL);
abort$card(check) 'Not all elememts of ijkL are in ijk', check;

* Do some calculations
scalar x, xA, xAL /0/;
x  = sum(ijk (i,j,k), ord(i) + 2*ord(j) + 3*ord(k));
xA = sum(ijkA(i,j,k), ord(i) + 2*ord(j) + 3*ord(k));

loop(ijkA(i,j,k),
  xAL = xAL + ord(i) + 2*ord(j) + 3*ord(k);
);

abort$(xA  <> x ) 'Sum using alias leads to different result than sum using set',  xA,  x;
abort$(xAL <> x ) 'Loop using alias leads to different result than sum using set', xAL, x;