1

I have a Gams model and I want read sets and parameters from Excel to Gams.As shown below:

enter image description here

How can I read this parameter in Gams?

Thanks

n.e
  • 83
  • 1
  • 8
  • tried XLS2GMS mentioned in its documentation? – p._phidot_ Jan 10 '20 at 02:32
  • 1
    If you are on Windows, I would use gdxxrw. Here is an example, which should show you everything you need: https://www.gams.com/latest/datalib_ml/libhtml/datalib_GDXXRWExample13.html – Lutz Jan 10 '20 at 08:36
  • thanks,It is solved,but I do not know, how can I read parameter from excel such as d(j) for example from C1 : C4 with name of parameter ? – n.e Jan 10 '20 at 10:29
  • I wrote this: $ call gdxxrw Output.xlsx par=d rng=sheet1!C1:C4 rdim=1 parameter d(j) $gdxin Output.gdx $load d $gdxin display d; but gives zero in gams – n.e Jan 10 '20 at 10:30

1 Answers1

0

For that table you need 2 indexes (i.e. sets) e.g. set i for the column of a, b and c. And set j for the row of d, e and f. Try this:

parameter d(i,j) "Data with column of a, b and c and row of e, d and f";
$Call GDXXRW.exe i=C:\Input.xlsx par=d rng=Sheet1!C1:F4 Rdim=1 Cdim=1 o=C:\Input.gdx
$GDXIN C:\Input.gdx
$LOAD d
$GDXIN

Display d;
olucube.com
  • 330
  • 2
  • 11