Merge input data of a parameter Topic is solved

Problems with syntax of GAMS
Post Reply
Janisch
User
User
Posts: 38
Joined: 3 years ago

Merge input data of a parameter

Post by Janisch »

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

Many greetings and Merry Christmas
Janisch
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Merge input data of a parameter

Post by bussieck »

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:

Code: Select all

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
image.png (4.51 KiB) Viewed 2201 times
So you can load with merge:

Code: Select all

set i / ... /, j / ... /, m/1*5/;
parameter d(m,i,j);
$gdxin d1
$loadM d
$gdxin d2
$loadM d
...
Hope this helps,
-Michael
Janisch
User
User
Posts: 38
Joined: 3 years ago

Re: Merge input data of a parameter

Post by Janisch »

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

Many greetings Janisch
Post Reply