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-dimensional parameter a(i,j,k) and you export it 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 example 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.xlsx
par=a rng=default!a1
par=a rng=rdim0_cdim3!a1 rdim=0 cdim=3
par=a rng=rdim1_cdim2!a1 rdim=1 cdim=2
par=a rng=rdim2_cdim1!a1 rdim=2 cdim=1
par=a rng=rdim3_cdim0!a1 rdim=3 cdim=0
$offecho
execute 'gdxxrw @gdxxrw.txt';
execute 'shellexecute a.xlsx';
IMPRESSUM / LEGAL NOTICEPRIVACY POLICY interfaces/what_is_the_default_layout_when_exporting_an_n-dimensional_parameter_or_set_from_gdx_to_excel.txt · Last modified: 2020/05/26 12:20 by Frederik Fiand