Merge input data of a parameter

Hello all,

I am reading my input data from Excel. From five spreadsheets I read in each a distance matrix of a mode (Road, Air, Sea, etc.). The matrix is the same size in all cases, so exactly the same. Only the mode is different. What is the best way to create a single parameter d(m(=mode),i(=start),j(=end)) in GAMS?

Thanks for your help :slight_smile:

Many greetings and Merry Christmas
Janisch

I would read the five matrices at compile time into different symbols and do the merge at execution time. For 5 matrices there is little need to automate:

set i / ... /, j / ... /;
parameter d1(i,j), d2(i,j),d3(i,j),d4(i,j);
$gdxin d1
$load d1
$gdxin d2
$load d2
...
set m / 1*5 /;
parameter d(m,i,j);
d('1',i,j) = d1(i,j);
d('2',i,j) = d2(i,j);
...

If you have more you should add the mode already to your Excel data:
image.png
So you can load with merge:

set i / ... /, j / ... /, m/1*5/;
parameter d(m,i,j);
$gdxin d1
$loadM d
$gdxin d2
$loadM d
...

Hope this helps,
-Michael

Super! This is exactly what I was looking for.
Thanks for your help :slight_smile:

Many greetings Janisch