Description
This program illustrates reading a four dimensional parameter from spreadsheet. This model is referenced in "Reading Multi-dimensional Parameter from Spreadsheet" from the GDXXRW Documentation.
Category : GAMS Data Utilities library
Main file : GDXXRWExample7.gms includes : Test1.xlsx GDXXRWExample7.gms
$title Reading Multi-dimensional Parameter from Spreadsheet (GDXXRWExample7,SEQ=018)
$onText
This program illustrates reading a four dimensional parameter from spreadsheet.
This model is referenced in "Reading Multi-dimensional Parameter from
Spreadsheet" from the GDXXRW Documentation.
$offText
$callTool win32.msappavail Excel
$if errorlevel 1 $abort.noError "No Excel available"
Set
a 'first row entries' / a1, a2 /
b 'second row entries' / b1, b2 /
q 'first column entries' / q1, q2 /
r 'second column entries' / r1, r2 /;
Parameter data3(a,b,q,r);
$call gdxxrw Test1.xlsx par=data3 rng=EX3!A1:F6 rDim=2 cDim=2 trace=0
$ifE errorLevel<>0 $abort Error reading from spreadsheet!
$gdxIn Test1.gdx
$load data3
$gdxIn
display data3;
* Data Validation
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 error01(a,b,q,r) 'unexpected value';
error01(a,b,q,r) = exp_data3(a,b,q,r)<>data3(a,b,q,r);
abort$card(error01) error01;