Import parameters from Excel to GAMS: get all zeros

637 views Asked by At

I have an Excel file GAMS2.xlsx with a spreadsheet GAMS, which contains data as shown at the picture

enter image description here

In GAMS I wrote such code:

Set t /t1*t5/;
 
Parameters
W(t);
$call gdxxrw GAMS2.xlsx par=W rng=GAMS!A3:B7 rdim=1 dset=t rng=GAMS!A3:A7 rdim=1
$gdxin GAMS2.gdx
$load W
$gdxin

Display W;

Then I get good gdx file

enter image description here

So, I have no errors after RUN, but all values of parameter W are zeros. In the lst file I see:

----     6 PARAMETER W

                      ( ALL       0.000 )

What's my mistake? Any help would be much appreciated, thank you!

1

There are 1 answers

0
Lutz On

Looks like your set t in the Excel file is 1 to 5 while your set t in the GAMS model is t1 to t5. So you don't have a matching domain and thus no values loaded. If you use $loadDC (DC for Domain Checked) instead of $load GAMS would have stopped and notified you about this right away.

BTW: You could also use implicit set definition to populate the set t from GDX as well easily. That would look like this:

Set t;
 
Parameters W(t<);

$call gdxxrw GAMS2.xlsx par=W rng=GAMS!A3:B7 rdim=1 dset=t rng=GAMS!A3:A7 rdim=1
$gdxin GAMS2.gdx
$load W
$gdxin

Display W;