load8.gms : Domain projection load tests

Description

Contributor: M. Bussick, October 2013


Small Model of Type : GAMS


Category : GAMS Test library


Main file : load8.gms

$title 'Domain projection load tests' (LOAD8,SEQ=631)

$onText
Contributor: M. Bussick, October 2013
$offText


$call gamslib -q 1
$echo set use(i,j); use(i,j) = x.l(i,j) gt 0.5; >> trnsport.gms
$echo set ii(i,i) / seattle.san-diego /;        >> trnsport.gms
$call gams trnsport lo=0 gdx=t.gdx
$if errorlevel 1 $abort Could not run trnsport. Check trnsport.lst

set rset1 / seattle, san-diego /
    rset2 / new-york, chicago, topeka /
    rset3 / #rset1, #rset2 /
    fset1 / 1*5 /
    fset2 / seattle /
    fset3 / chicago /;

$macro sameset(i,j) (card(i)=card(j) and sum((i,j)$sameas(i,j),1)=card(i))

$gdxIn t

set i, ii, il, ir, j, ij, yy(i,j); alias (i,ip);
parameter xxx(i);

* Some simple test that should trigger compilation errors

* Cannot load parameter
$load xxx<a
$if errorfree $abort '$load xxx<a' should trigger compilation error
$clearError

* Cannot load 2-dim set
$load yy<a
$if errorfree $abort '$load yy<a' should trigger compilation error
$clearError

* Cannot load alias
$load ip<a
$if errorfree $abort '$load ip<a' should trigger compilation error
$clearError

* Cannot load domain unknown to GDX symbol
$load j<a
$if errorfree $abort '$load j<a' should trigger compilation error
$clearError

* Cannot load domain position larger than GDX symbol dimension
$load j<a.dim2
$if errorfree $abort '$load j<a.dim2' should trigger compilation error
$clearError

* Automatic domain i recognition
$load i<d
$if not errorfree $abort '$load i<d' should not trigger compilation error
abort$(not sameset(i,rset1)) 'i and rset1 should be the same', i, rset1;

* Loading from a multi-dimensional set
$load ii<use.dim1
$if not errorfree $abort '$load ii<use.dim1' should not trigger compilation error
abort$(not sameset(ii,rset1)) 'ii and rset1 should be the same', ii, rset1;

* Forced domain position recognition
$load j<d.dim2
$if not errorfree $abort '$load j<d.dim2' should not trigger compilation error
abort$(not sameset(j,rset2)) 'j and rset2 should be the same', j, rset2;

* Join domains
$load ij<d.dim1
$if not errorfree $abort '$load ij<d.dim1' should not trigger compilation error
$loadM ij<d.dim2
$if not errorfree $abort '$load ij<d.dim2' should not trigger compilation error
abort$(not sameset(ij,rset3)) 'ij and rset3 should be the same', ij, rset3;

Set resf1(fset1), resf2(fset2), resf3(fset3) filtered result sets;

* Filtered read without error
$load resf1<d.dim1
$if not errorfree $abort '$load resf1<d.dim1' should not trigger compilation error
abort$card(resf1) 'resf1 should be empty due to domain check with fset1', resf1, fset1;

* Filtered read with error
$loadDCM resf1<d.dim1
$if errorfree $abort '$loadMDC resf1<d.dim1' should trigger compilation error
$clearError

* Filtered read with some result
$load resf2<d.dim1
$if not errorfree $abort '$load resf2<d.dim1 ' should not trigger compilation error
abort$(not sameset(resf2,fset2)) 'resf2 and fset2 should be the same', resf2, fset2;

* Filtered read with some result
$load resf3<d.dim2
$if not errorfree $abort '$load resf3<d.dim2 ' should not trigger compilation error
abort$(not sameset(resf3,fset3)) 'resf3 and fset3 should be the same', resf3, fset3

$gdxOut;