Hi! I’ve been trying to exchange data from Excel to GAMS. I checked a Youtube video, and ran this code:
Set i nodes /1,2,3,4,5,6,7,8,9,10,11,12/;
Parameter Dst(i,i) Distances between two nodes;
$onmulti
$onecho > ficheiroteste.txt
dset=i rng=a1 rdim=1
par=Dst rng=DistanceDur!a1 rdim=1 cdim=1
$offecho
$offmulti
$call GDXXRW InstanzCPLEX_HCSRP_10_2.xlsx trace=3 @ficheiroteste.txt
$GDXIN InstanzCPLEX_HCSRP_10_2.gdx
$LOADm i
$LOAD Dst
$GDXIN
Display Dst;
This works, as I am able to transfer the 12 nodes to GAMS and successfully build a table with them. If I then remove the defined nodes, and leave it strictly like this:
Set i nodes;
Parameter Dst(i,i) Distances between two nodes;
$onmulti
$onecho > ficheiroteste.txt
dset=i rng=a1 rdim=1
par=Dst rng=DistanceDur!a1 rdim=1 cdim=1
$offecho
$offmulti
$call GDXXRW InstanzCPLEX_HCSRP_10_2.xlsx trace=3 @ficheiroteste.txt
$GDXIN InstanzCPLEX_HCSRP_10_2.gdx
$LOADm i
$LOAD Dst
$GDXIN
Display Dst;
The set nodes becomes flexible, meaning that I can add or remove a node in the Excel, and it will respectively appear or disappear in the GAMS log. However, this only works if the Excel has only one sheet. If I have more than one, no error occurs, but the values of the nodes are not loaded, and in the GAMS log the parameter Dst is presented as an empty table.
Can anyone help me? It would be helpful if I could use more than in the Excel file I’m working, so that I could have more sets there, instead of having to create an Excel file for each set.
Thankyou very much!