ldidx01.gms : $loadIdx - checking basic operation

Description

Check basic operation of $loadIdx:
  - A: load the data and each index set all via $loadIdx
  - B: load the data and index sets, assuming common index sets
  - C: load the data and index sets, using aliases for common sets
  - D: load just the data, index sets pre-loaded
  - E: load just the data, index sets pre-loaded, use some aliases

Contributor: Steve Dirkse, Oct 2013

  -----  - A: load the data and each index set all via $loadIdx ----------


Small Model of Type : GAMS


Category : GAMS Test library


Main file : ldidx01.gms

$title $loadIdx - checking basic operation (ldidx01,SEQ=625)

$onText
Check basic operation of $loadIdx:
  - A: load the data and each index set all via $loadIdx
  - B: load the data and index sets, assuming common index sets
  - C: load the data and index sets, using aliases for common sets
  - D: load just the data, index sets pre-loaded
  - E: load just the data, index sets pre-loaded, use some aliases

Contributor: Steve Dirkse, Oct 2013
$offText

* -----  - A: load the data and each index set all via $loadIdx ----------
sets
  i
  j1, j2, j3
  k1, k2, k3, k4, k5, k6, k7, k8, k9, k10
  ;
parameters
  a0
  a1(i)
  a3 (j1, j2, j3)
  a10(k1, k2, k3, k4, k5, k6, k7, k8, k9, k10)
  ;
$gdxIn idx1_
$loadIdx a0 a1 a3 a10
$gdxIn
abort$[a0 <> 525] 'a0 not as expected', a0;
abort$[card(i) <> 5] 'i not as expected';
abort$[card(a1) <> 3] 'a1 not as expected';
abort$[card(j1) <> 3] 'j1 not as expected';
abort$[card(j2) <> 5] 'j2 not as expected';
abort$[card(j3) <> 2] 'j3 not as expected';
abort$[card(a3) <> 6] 'a3 not as expected';
abort$[card(k1) <> 3] 'k1 not as expected';
abort$[card(k2) <> 5] 'k2 not as expected';
abort$[card(k3) <> 2] 'k3 not as expected';
abort$[card(k4) <> 2] 'k4 not as expected';
abort$[card(k5) <> 2] 'k5 not as expected';
abort$[card(k6) <> 2] 'k6 not as expected';
abort$[card(k7) <> 2] 'k7 not as expected';
abort$[card(k8) <> 2] 'k8 not as expected';
abort$[card(k9) <> 2] 'k9 not as expected';
abort$[card(k10)<> 2] 'k10 not as expected';
abort$[card(a10) <> 256] 'a10 not as expected';


* -----  - B: load the data and index sets, assuming common index sets ---
sets s1, s2, s3;
parameter b(s1, s2, s3, s3, s3, s3, s3, s3, s3, s3);
$gdxIn idx1_
$loadIdx b=a10
$gdxIn
abort$[card(s1) <> 3] 's1 not as expected';
abort$[card(s2) <> 5] 's2 not as expected';
abort$[card(s3) <> 2] 's3 not as expected';
abort$[card(b) <> 256] 'b not as expected';


* -----  - C: load the data and index sets, using aliases for common sets-
sets ss1, ss2, ss3;
alias(ss3,ss4,ss5,ss6,ss7,ss8,ss9,ss10);
parameter v(ss1,ss2,ss3,ss4,ss5,ss6,ss7,ss8,ss9,ss10);
$gdxIn idx1_
$loadIdx v=a10
$gdxIn
abort$[card(ss1) <> 3] 'ss1 not as expected';
abort$[card(ss2) <> 5] 'ss2 not as expected';
abort$[card(ss3) <> 2] 'ss3 not as expected';
abort$[card(ss4) <> 2] 'ss4 not as expected';
abort$[card(ss5) <> 2] 'ss5 not as expected';
abort$[card(ss6) <> 2] 'ss6 not as expected';
abort$[card(ss7) <> 2] 'ss7 not as expected';
abort$[card(ss8) <> 2] 'ss8 not as expected';
abort$[card(ss9) <> 2] 'ss9 not as expected';
abort$[card(ss10)<> 2] 'ss10 not as expected';
abort$[card(v) <> 256] 'v not as expected';


* -----  - D: load just the data, index sets pre-loaded: -----------------
sets
  ii  / 1 * 5 /
  jj1 / 1 * 3 /
  jj2 / 1 * 5 /
  jj3 / 1 * 2 /
  p1  / 1 * 3 /
  p2  / 1 * 5 /
  p3  / 1 * 2 /
  px  / 1 * 2 /
  ;
scalar ddd;
parameters
  aa0
  aa1(ii)
  aa3(jj1,jj2,jj3)
  aa10(p1,p2,p3,px,px,px,px,px,px,px)
  ;
$gdxIn idx1_
$loadIdx ddd=a0 aa0=a0 aa1=a1 aa3=a3 aa10=a10
$gdxIn
abort$[ddd <> 525] 'ddd not as expected', ddd;
abort$[aa0 <> 525] 'aa0 not as expected', aa0;
abort$[card(aa1) <> 3] 'aa1 not as expected', aa1;
abort$[card(aa3) <> 6] 'aa3 not as expected';
abort$[card(aa10) <> 256] 'aa10 not as expected';


* -----  - E: load just the data, index sets pre-loaded, use some aliases-
alias(p3,pa);
parameters
  bb10(p1,p2,pa,pa,pa,pa,pa,pa,pa,pa)
  ;
$gdxIn idx1_
$loadIdx bb10=a10
$gdxIn
abort$[card(bb10) <> 256] 'bb10 not as expected';