uldidx02.gms : unloadIdx - checking execution restrictions

Description

Check basic operation of execute_unloadIdx.  We expect to write only
parameters whose indices are counting numbers, i.e. 1, 2, 3, ...
Check for:
  - non-counting-numbers in the universe : OK
  - non-counting-numbers in domain: rejected
  - domain not starting with 1: rejected
  - any gaps in domain: rejected
  - writing special values: OK for eps, undf, inf, NA
  - writing special values: acronym rejected

Contributor: Steve Dirkse, Oct 2013


Small Model of Type : GAMS


Category : GAMS Test library


Main file : uldidx02.gms

$TITLE unloadIdx - checking execution restrictions (uldidx02,SEQ=623)

$ontext
Check basic operation of execute_unloadIdx.  We expect to write only
parameters whose indices are counting numbers, i.e. 1, 2, 3, ...
Check for:
  - non-counting-numbers in the universe : OK
  - non-counting-numbers in domain: rejected
  - domain not starting with 1: rejected
  - any gaps in domain: rejected
  - writing special values: OK for eps, undf, inf, NA
  - writing special values: acronym rejected

Contributor: Steve Dirkse, Oct 2013
$offtext

sets
  i  / 0, 1, 2, 3, 'a', 4, 6, 5  /
  j1  / 1 * 4 /
  j2  / 1 * 5 /
  j3  / 1 * 6 /
  k   / 0 * 2 /
  ka  / 1 * 3, 'a' /
  k2  / 2 * 3 /
  k3  / 1 , 3 /
  ;

parameter b1(j1); b1(j1) = ord(j1);
parameter b2(j2); b2(j2) = ord(j2);
parameter b3(j3); b3(j3) = j3.pos;

parameter c (k ); c (k ) = ord(k);
parameter ca(ka); ca(ka) = ord(ka);
parameter c2(k2); c2(k2) = ord(k2);
parameter c3(k3); c3(k3) = ord(k3);

acronym aaa;
$onundf
* special values should be OK, except for acronyms
parameter sv(j2) /
  1  eps
  2  undf
  3  inf
  4  NA
/;
$offundf


execute_unloadIdx 'tmp1', b1;
execute_unloadIdx 'tmp2', b1, b2;

execute_unloadIdx 'tmp2', sv;

sv('1') = aaa;
display sv;
execute_unloadIdx 'tmp2', sv;
abort$[execerror = 0] 'unloadIdx successful but failure expected';
execerror = 0;

* should fail: domain j3 is not ordered correctly
execute_unloadIdx 'tmp3', b3;
abort$[execerror = 0] 'unloadIdx successful but failure expected';
execerror = 0;

* should fail: domain k contains 0
execute_unloadIdx 'tmp3', c;
abort$[execerror = 0] 'unloadIdx successful but failure expected';
execerror = 0;

* should fail: domain ka contains 'a'
execute_unloadIdx 'tmp3', ca;
abort$[execerror = 0] 'unloadIdx successful but failure expected';
execerror = 0;

* should fail: domain k2 does not start with 1
execute_unloadIdx 'tmp3', c2;
abort$[execerror = 0] 'unloadIdx successful but failure expected';
execerror = 0;

* should fail: domain k3 = 1, 3 has a gap
execute_unloadIdx 'tmp3', c3;
abort$[execerror = 0] 'unloadIdx successful but failure expected';
execerror = 0;

execute 'rm -f tmp1.gdx tmp2.gdx tmp3.gdx';