GDXXRWExample10.gms : Reads a number of parameters and sets using the index option from an MS Excel file and writes it to a GDX file

Description

This program illustrates reading a number of parameters and
sets using the index option. Index data is primarily a list
of set and parameter ranges and their dimensions.


Category : GAMS Data Utilities library


Main file : GDXXRWExample10.gms   includes :  GDXXRWExample10.gms  Test1.xls

$ontext

This program illustrates reading a number of parameters and
sets using the index option. Index data is primarily a list
of set and parameter ranges and their dimensions.

$offtext

 sets i row entries    /i1,i2/
      a column entries /a1, a2,a3/
      b  second row entries    /b1,b2/
      q  first column entries  /q1,q2/
      r  second column entries /r1,r2/
      set1
      set2;

 parameter data1(i,a), data2(i,a), data3(a,b,q,r);

$if %system.filesys% == UNIX $abort.noerror 'This model cannot run on a non-Windows platform';
$call msappavail -Excel
$if errorlevel 1 $abort.noerror 'Microsoft Excel is not available!';

$CALL GDXXRW Test1.xls Index=Index!a1 trace=0
$GDXIN Test1.gdx
$LOAD data1=D1 data2=D2 data3=D3 set1=S1 set2=S2
$GDXIN

display data1,data2,data3,set1,set2;


* Data Validation
table exp_data1 (i,a) expected_data1
         a1       a2       a3
i1        1        2        3
i2        4        5        6;
set error01(i,a) unexpected value;
error01(i,a) = exp_data1(i,a)<>data1(i,a);
abort$card(error01) error01;

table exp_data2 (i,a) expected_data2
         a1       a2       a3
i1        1        2        3
i2        4        5        6;
set error02(i,a) unexpected value;
error02(i,a) = exp_data2(i,a)<>data2(i,a);
abort$card(error02) error02;

parameter exp_data3(a,b,q,r) expected_data3 /
a1.b1.q1.r1  1
a1.b1.q1.r2  2
a1.b1.q2.r1  3
a1.b1.q2.r2  4
a1.b2.q1.r1  5
a1.b2.q1.r2  6
a1.b2.q2.r1  7
a1.b2.q2.r2  8
a2.b1.q1.r1  9
a2.b1.q1.r2 10
a2.b1.q2.r1 11
a2.b1.q2.r2 12
a2.b2.q1.r1 13
a2.b2.q1.r2 14
a2.b2.q2.r1 15
a2.b2.q2.r2 16
/;
set error03(a,b,q,r) unexpected value;
error03(a,b,q,r) = exp_data3(a,b,q,r)<>data3(a,b,q,r);
abort$card(error03) error03;

Alias (*,u);
Set expected_set1 /s1*s5/;
Set error04(u) unexpected elements;
error04(u) = expected_set1(u) xor set1(u);
abort$card(error04) error04;

Set expected_set2 /s1*s5/;
Set error05(u) unexpected elements;
error05(u) = expected_set2(u) xor set2(u);
abort$card(error05) error05;