Description
Test GDXXRW with writing a two dimensional parameter merged/clear with different layouts in Excel rdim=1 cdim=1, rdim=2 cdim=0 Contributor: Michael Bussieck, October 2016
Small Model of Type : GAMS
Category : GAMS Test library
Main file : gdxxrw7.gms
$title Test merge and clear option for special data layout (GDXXRW7,SEQ=698)
$onText
Test GDXXRW with writing a two dimensional parameter merged/clear with different
layouts in Excel
rdim=1 cdim=1, rdim=2 cdim=0
Contributor: Michael Bussieck, October 2016
$offText
* If no Excel installed then quit
$callTool win32.msappavail Excel
$if errorlevel 1 $abort.noError "No Excel available"
set t /t1*t5/; set s /s1*s3/;
parameter a(s,t), a11(s,t), a20(s,t), a02(s,t), diff(s,t);
a(s,t) = round(uniform(0,1),2);
execute_unload "a.gdx", a;
$call cp -f dimtest.xlsx mergetest.xlsx
$call cp -f dimtest.xlsx cleartest.xlsx
* Save and Close spreadsheet
executeTool 'win32.excelTalk saveAndClose mergetest.xlsx';
* Writing
execute 'gdxxrw.exe o=mergetest.xlsx i=a.gdx par=a rng=11!a1:f4 rdim=1 cdim=1 merge par=a rng=20!a1:c15 rdim=2 cdim=0 merge par=a rng=02!a1:o3 rdim=0 cdim=2 merge log=gdxxrw.log';
abort$errorlevel 'gdxxrw.exe o=mergetest.xlsx'
execute 'gdxxrw.exe o=cleartest.xlsx i=a.gdx par=a rng=11!a1:f4 rdim=1 cdim=1 clear par=a rng=20!a1:c15 rdim=2 cdim=0 merge par=a rng=02!a1:o3 rdim=0 cdim=2 merge log=gdxxrw.log';
abort$errorlevel 'gdxxrw.exe o=cleartest.xlsx'
* Reading
execute 'gdxxrw.exe o=mergegdx.gdx i=mergetest.xlsx par=a11 rng=11!a1 rdim=1 cdim=1 par=a20 rng=20!a1 rdim=2 cdim=0 par=a02 rng=02!a1 rdim=0 cdim=2 log=gdxxrw.log';
abort$errorlevel 'gdxxrw.exe o=mergegdx.gdx'
execute_load 'mergegdx', a11, a20, a02;
diff(s,t) = a(s,t)-a11(s,t); abort$card(diff) a,a11,diff;
diff(s,t) = a(s,t)-a20(s,t); abort$card(diff) a,a20,diff;
diff(s,t) = a(s,t)-a02(s,t); abort$card(diff) a,a02,diff;
execute 'gdxxrw.exe o=cleargdx.gdx i=cleartest.xlsx par=a11 rng=11!a1 rdim=1 cdim=1 par=a20 rng=20!a1 rdim=2 cdim=0 par=a02 rng=02!a1 rdim=0 cdim=2 log=gdxxrw.log';
abort$errorlevel 'gdxxrw.exe o=cleargdx.gdx'
execute_load 'cleargdx', a11, a20, a02;
diff(s,t) = a(s,t)-a11(s,t); abort$card(diff) a,a11,diff;
diff(s,t) = a(s,t)-a20(s,t); abort$card(diff) a,a20,diff;
diff(s,t) = a(s,t)-a02(s,t); abort$card(diff) a,a02,diff;