I have a 4-dimensional data in Excel as follows. Row 1: Set a with 2 elements, /'Refinery 1','Refin

sembuang711q6

sembuang711q6

Answered question

2022-05-15

I have a 4-dimensional data in Excel as follows.
Row 1: Set a with 2 elements, /'Refinery 1','Refinery 2'/
Row 2: Set b with 2 elements, /'Pipeline','Rail'/
Column 1: Set q with 2 elements, /'Warehouse 1','Warehouse 2'/
Column 2: Set r with 3 elements, /'Petroleum','Diesel', 'Jet Fuel'/.
My data looks like this in Excel.
I try to import the data from Excel to GAMS by the following code.
sets a first row entries
b second row entries
q first column entries
r second column entries
parameter data3(a,b,q,r);
$CALL GDXXRW.EXE i=Try1.xlsx o=Try1.gdx set=a rng=Sheet1!A3:A6 rdim=1 set=b rng=Sheet1!B3:B6 rdim=1 set=q rng=Sheet1!C1:H1 cdim=1 set=r rng=Sheet1!C2:H2 cdim=1 par=data3 rng=Sheet1!A1:F6 Rdim=2 Cdim=2
$GDXIN Try1.gdx $LOAD a,b,q,r,data3 $GDXIN
display data3;
It shall produce the resulting parameter, i.e data3 as 24 elements (2x2x2x3), But it only shows 16 elements, due to some problems and ignores other elements.
The resulting GDX looks like this!
Any help will be highly appreciated. Thanks!

Answer & Explanation

reflam2kfnr

reflam2kfnr

Beginner2022-05-16Added 16 answers

This is not a question about mathematics, so this forum is not really appropriate.
But to answer your question, easier is:
sets a first row entries
b second row entries
q first column entries
r second column entries
parameter data3(a,b,q,r);
$CALL GDXXRW.EXE i=Try1.xlsx par=data3 rng=A1 Rdim=2 Cdim=2 trace=2
$GDXIN Try1.gdx
$LOAD adisplay a,b,q,r,data3;
If you want to stick with your approach use dset instead of set in the call to gdxxrw.

Do you have a similar question?

Recalculate according to your conditions!

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?