Description
GAMS 35 introduced $gdxLoad as alternative to $gdxIn ... $load ... $gdxIn. It is a single statement to open a GDX file and load symbols from it and does not interfere with other $load operations from another file opened via $gdxIn before. Contributor: Lutz Westermann, February 2021
Small Model of Type : GAMS
Category : GAMS Test library
Main file : load13.gms
$title 'Test $gdxLoad' (LOAD13,SEQ=851)
$onText
GAMS 35 introduced $gdxLoad as alternative to $gdxIn ... $load ... $gdxIn.
It is a single statement to open a GDX file and load symbols from it and does not
interfere with other $load operations from another file opened via $gdxIn before.
Contributor: Lutz Westermann, February 2021
$offText
$onEcho > data1.gms
Set i / i1*i3 /
j / j1*j3 /;
Parameter a(i) / #i 1 /
b(j) / #j 2 /;
$offEcho
$onEcho > data2.gms
Set i / i1*i3 /
j / j1*j3 /;
Parameter a(i) / #i 11 /
b(j) / #j 22 /;
$offEcho
$call.checkErrorLevel gams data1 lo=%GAMS.lo% gdx=data1
$call.checkErrorLevel gams data2 lo=%GAMS.lo% gdx=data2
* Make sure that in general $gdxLoad does the same as $gdxIn .. $load .. $gdxIn
Alias (u,*);
Set i1(u), i2(u);
Parameter a1(u), a2(u);
$gdxLoad data1.gdx i1=i a1=a
$gdxIn data1.gdx
$load i2=i a2=a
$gdxIn
Set error1(u), error2(u);
error1(u) = i1(u) xor i2(u);
abort$card(error1) error1;
error2(u) = a1(u) <> a2(u);
abort$card(error2) error2;
* Make sure that $gdLoad can be called between two $load calls w/o interfering with the operations for the file opened with $gdxIn
Set i3(u), j1(u), j2(u);
Parameter a3(u), b1(u), b2(u);
$gdxIn data1.gdx
$load i3=i
$gdxLoad data2.gdx j1=j b1=b
$load a3=a
$gdxIn data2.gdx
$load j2=j b2=b
$gdxIn
Set error3(u), error4(u),
error5(u), error6(u);
error3(u) = i1(u) xor i3(u);
abort$card(error3) error3;
error4(u) = a1(u) <> a3(u);
abort$card(error4) error4;
error5(u) = j1(u) xor j2(u);
abort$card(error5) error5;
error6(u) = b1(u) <> b2(u);
abort$card(error6) error6;