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

Frequently asked questions about GAMS

Moderator: aileen

Forum rules
Please ask questions in the other sub-forums
Locked
aileen
User
User
Posts: 136
Joined: 3 years ago

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

Post by aileen »

What is the default layout when exporting an n-dimensional parameter or set from GDX to Excel using GDXXRW?
aileen
User
User
Posts: 136
Joined: 3 years ago

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

Post by aileen »

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).

Code: Select all

  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 settings for rdim and cdim.

Code: Select all

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';
Locked