ldidx05.gms : $loadIdx - checking restrictions

Description

Check basic operation of $loadIdx.
Cannot $loadIdx if the input contains an acronym

Contributor: Steve Dirkse, Oct 2013


Small Model of Type : GAMS


Category : GAMS Test library


Main file : ldidx05.gms

$title $loadIdx - checking restrictions (ldidx05,SEQ=629)
$onDollar

$onText
Check basic operation of $loadIdx.
Cannot $loadIdx if the input contains an acronym

Contributor: Steve Dirkse, Oct 2013
$offText

$if NOT set GENGDX $goTo SKIP_GENGDX

* generate a GDX file containing parameter a that can be $loadIdx'ed,
* and an almost-identical parameter b with an acronym stored,
* therefore not $loadIdx'able.
set d_i_m__3 / 1 * 3 /;
parameters a(d_i_m__3), b(d_i_m__3);
a(d_i_m__3) = 1;
a('2') = inf;
acronym aaa;
b(d_i_m__3) = 1;
b('2') = aaa;
execute_unload 'idx2_.gdx', a, b;
$exit

$label SKIP_GENGDX
* -------------------- TEST STARTS HERE -------------------

* a should be readable, b not
sets s1, s2;
parameter a(s1), b(s2);

$gdxIn idx2_
$loadIdx a
$gdxIn
$if not errorfree $abort '$loadIdx should accept data containing regular special values like INF'
abort$[card(s1) <> 3] 'unexpected read of s1', s1;
abort$[card(a) <> 3] 'unexpected read of a', a;
abort$[a('2') <> inf] 'unexpected read of a', a;

$gdxIn idx2_
$loadIdx b
$gdxIn
$if errorfree $abort '$loadIdx should reject data containing an acronym: AAA'
$clearError