User Tools

Site Tools


interfaces:what_is_the_default_layout_when_exporting_an_n-dimensional_parameter_or_set_from_gdx_to_excel

What is the default layout when exporting an n-dimensional parameter or set from GDX to Excel using gdxxrw?

The default layout for an n-dimensional parameter or set from GDX to Excel is to have n-1 indices in the row and one index in the column. For example, lets say you have a 3 dim parameter a(i,j,k) and you export this using gdxxrw with default settings (meaning rdim=2, cdim=1) you get a layout like this (A..E are the Excel column headers, 1-4 are the Excel row headers).

  A   B   C   D   E  ...
1         k1 k2  k3
2 i1 j1    1  2   3
3 i1 j2    6  7   8
4 i1 j3   11 12  12
.
.
.

Below you find a small GAMS model that illustrates the impact of the different setting for rdim and cdim.

set i / i1*i3 /
    j / j1*j4 /
    k / k1*k5 /;
parameter a(i,j,k), cnt /0/;
loop((i,j,k), cnt=cnt+1; a(i,j,k) = cnt);

execute_unload 'a.gdx', a;
$onecho > gdxxrw.txt
i=a.gdx
o=a.xls

par=a
rng=default!a1

par=a
rng=0_3!a1 rdim=0 cdim=3

par=a
rng=1_2!a1 rdim=1 cdim=2

par=a
rng=2_1!a1 rdim=2 cdim=1

par=a
rng=3_0!a1 rdim=3 cdim=0
$offecho
execute 'gdxxrw @gdxxrw.txt';
execute 'shellexecute a.xls';
interfaces/what_is_the_default_layout_when_exporting_an_n-dimensional_parameter_or_set_from_gdx_to_excel.txt · Last modified: 2010/05/18 12:08 by support