Description
Contributor: Michael Bussieck, January 2023
Small Model of Type : GAMS
Category : GAMS Test library
Main file : embgms03.gms
$title 'Test projection operator when loading data from embedded code' (EMBGMS03,SEQ=927)
$onText
Contributor: Michael Bussieck, January 2023
$offText
Parameter dataUniverse(*,*,*);
Set d1Want / i1 /
d2Want / j1, j2 /
d3Want / k1, k3 /
d1(*), d2(*), d3(*);
$macro checkIfAinB(a,b,Error) Set Error; Error(a) = not b(a); abort$card(Error) Error;
* Get set elements from specified dim of the parameter
checkIfAinB(d1,d1Want,Error1a)
checkIfAinB(d2,d2Want,Error2a)
checkIfAinB(d3,d3Want,Error3a)
checkIfAinB(d1Want,d1,Error1b)
checkIfAinB(d2Want,d2,Error2b)
checkIfAinB(d3Want,d3,Error3b)
Set e1(*), e2(*), e3(*);
Parameter dataDomain(e1,e2,e3);
* Get set elements by domain matching of the parameter
checkIfAinB(e1,d1Want,Error1c)
checkIfAinB(e2,d2Want,Error2c)
checkIfAinB(e3,d3Want,Error3c)
checkIfAinB(d1Want,e1,Error1d)
checkIfAinB(d2Want,e2,Error2d)
checkIfAinB(d3Want,e3,Error3d)
Set f1(*);
Parameter dataDomainF1(f1,f1,f1);
* Get set elements by domain matching of the parameter, start searching from the left
checkIfAinB(f1,d1Want,Error1e)
checkIfAinB(d1Want,f1,Error1f)
Set f2(*);
Parameter dataDomainF2(f2,f2,f2);
* Get set elements by domain matching of the parameter, start searching from the right
checkIfAinB(f2,d3Want,Error3e)
checkIfAinB(d3Want,f2,Error3f)
* Load filtered data - This example lead to an error at some stage because of out-of-order UELs when writing to GDX, see #5016
Set code, labId, rr(code,labId);
parameter raw(*,*,*);
execute_unload 'dd.gdx' rr;
* For the following operations we expect failures
$onEcho > noDomMatch.gms
Parameter dataUniverse(*,*,*);
Set d1(*), d2(*), d3(*);
$offEcho
$call gams noDomMatch.gms lo=%GAMS.lo%
$if not errorlevel 1 $abort Expected error from noDomMatch.gms
$onEcho > noParameter.gms
Parameter dataUniverse(*,*,*);
Parameter d1(*), d2(*), d3(*);
$offEcho
$call gams noParameter.gms lo=%GAMS.lo%
$if not errorlevel 1 $abort Expected error from noParameter.gms
$onEcho > wrongDim.gms
Parameter dataUniverse(*,*,*);
Set d1(*,*), d2(*,*,*), d3(*,*,*);
$offEcho
$call gams wrongDim.gms lo=%GAMS.lo%
$if not errorlevel 1 $abort Expected error from wrongDim.gms