Unable to open gdx file Topic is solved

Problems with syntax of GAMS
Post Reply
Konstantinos
User
User
Posts: 2
Joined: 3 years ago

Unable to open gdx file

Post by Konstantinos »

Hello everybody,

Being at a very early stage of using GAMS, I'm facing an error that I cannot fix after multiple attempts, although following GAMS Guide. I want to insert a simple Excel file called demand.xlsx that consists of 2 columns, representing an hourly step on Column A (t1 ~ t672) and the corresponding consumption of each hour on Column B. Using the code below (I have only copied the part that concerns the error), I'm getting an error that seems to be that there is no gdx file creating after importing my Excel file.
I would appreciate some feedback. Thank you in advance!

*=== Import from Excel Demand
PARAMETER demand(t)
$call gdxxrw.exe demand.xls par=Demand rng=A1:B672 rDim=1
$gdxin demand.gdx
$load Demand
$gdxin
DISPLAY Demand

The error that I'm getting is the following.

1 SETS technologies /coal, gas, nuclear, wind_offshore, wind_onshore /
2 timeperiods /t1*t672/;
3 alias(technologies,tech)
4 alias(timeperiods,t)
5
6 SET wind_tech(tech) /wind_offshore, wind_onshore/;
7 SET no_wind(tech) /coal,gas,nuclear/;
8
9 *=== Import from Excel Demand
10 PARAMETER demand(t)
**** File: C:\Users\Nosdi\Desktop\MODELLING & ANALYSIS OF SES USING OPERATIONS RESEARCH\Final Project\GAMS\demand.gdx
**** Msg : No such file or directory
12 $gdxin demand.gdx
**** $510
**** 510 Unable to open gdx file for $GDXIN
13 $load Demand
**** $502
**** 502 GDXIN file not open - ignore rest of line
15 DISPLAY Demand
**** $141
**** 141 Symbol declared but no values have been assigned. Check for missing
**** data definition, assignment, data loading or implicit assignment
**** via a solve statement.
**** A wild shot: You may have spurious commas in the explanatory
**** text of a declaration. Check symbol reference list.
GFA
User
User
Posts: 50
Joined: 5 years ago

Re: Unable to open gdx file

Post by GFA »

Hi, there might be some problems with your GDXXRW statement, if thats the case data is not read correctly from Excel and GDX is not created.
You can add a statement to your GDX call which makes a log file which might give some clues:

$call gdxxrw.exe demand.xls par=Demand rng=A1:B672 rDim=1 log=log.txt

On first sight it seems you haven't specified a sheetname "rng=<sheetname>!A1:B672"
Also use "i=" for input file and "o=" for output file: i=demand.xls o=demand.gdx (by the way you mention it is an "xlsx" but in your gams-code you write "xls"?)
Also have a look here: https://www.gams.com/latest/docs/T_GDXXRW.html

Good luck.
GFA
Konstantinos
User
User
Posts: 2
Joined: 3 years ago

Re: Unable to open gdx file

Post by Konstantinos »

GFA wrote: 3 years ago Hi, there might be some problems with your GDXXRW statement, if thats the case data is not read correctly from Excel and GDX is not created.
You can add a statement to your GDX call which makes a log file which might give some clues:

$call gdxxrw.exe demand.xls par=Demand rng=A1:B672 rDim=1 log=log.txt

On first sight it seems you haven't specified a sheetname "rng=<sheetname>!A1:B672"
Also use "i=" for input file and "o=" for output file: i=demand.xls o=demand.gdx (by the way you mention it is an "xlsx" but in your gams-code you write "xls"?)
Also have a look here: https://www.gams.com/latest/docs/T_GDXXRW.html

Good luck.
GFA
Thank you so much! Really appreciate your feedback, it works now!
Post Reply