Error in creating GDX File from Excel Data Topic is solved

Problems with syntax of GAMS
Post Reply
pradeep2431
User
User
Posts: 4
Joined: 5 years ago

Error in creating GDX File from Excel Data

Post by pradeep2431 »

Hello Experts,
I have a 3-dimensional data in Excel, which looks as follows. (Excel is also attached)
Image

I try to import the data from Excel to GAMS by creating a GDX file by the following code.

Code: Select all

Sets
S 'SupplierS'
K 'Scenarios'
M 'Plants'

Parameters
q11 (S,K,M) 'Transportation cost from supplier,S to  plant,M under scenario,S'

$onecho > gdxxrw_in.txt
dset=S rng=Sheet1!A2:A10 rdim=1
dset=K rng=Sheet1!B2:B10 rdim=1
dset=M rng=Sheet1!C1:E1 cdim=1
par=q11 rng=Sheet1!A1:E10 rdim=2 cdim1
$offecho

$CALL GDXXRW.EXE i=data.xlsx o=Try2.gdx @gdxxrw_in.txt
$ife errorlevel<>0 $abort Problems calling GDXXRW
$GDXIN Try2.gdx
$LOAD S,K,M,q11
$GDXIN
However, GAMS doesn't produce the desired results and throw's the following error.

Code: Select all

**** 343  Abort triggered by above statement
What am I doing wrong? Any help will be highly appreciated!

Regards.
Pradeep
Attachments
data.xlsx
(8.75 KiB) Downloaded 234 times
Capture.JPG
Capture.JPG (25.77 KiB) Viewed 6534 times
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Error in creating GDX File from Excel Data

Post by bussieck »

It is worth looking into the lst and log to look for clues for errors. Here is the relevant snippet of the log:

Code: Select all

--- call GDXXRW.EXE i=data.xlsx o=Try2.gdx @gdxxrw_in.txt

GDXXRW           25.1.3 r4e34d435fbd Released Oct 30, 2018 VS8 x86 32bit/MS Wi
Input file : C:\tmp\data.xlsx
Output file: C:\tmp\Try2.gdx
**** Unknown option = cdim1
Total time = 921 Ms
--- gdxxrw0815.gms(17) 2 Mb
***
*** Abort Problems calling GDXXRW
***
The **** Unknown option = cdim1 would have pointed you to the typo in line 4 of your gdxxrw_in.txt file par=q11 rng=Sheet1!A1:E10 rdim=2 cdim1. Change this to cdim=1 and everything works fine.

There is some not so well know way to extract the set information from a parameter in GDX via the $load setSym<paramSym.dimN loading (see https://www.gams.com/latest/docs/UG_Dol ... DOLLARload):

Code: Select all

Sets S, K, M;
Parameters q11 (S,K,M);

$CALL GDXXRW.EXE i=data.xlsx o=Try2.gdx par=q11 rng=Sheet1!A1:E10 rdim=2 cdim=1
$ife errorlevel<>0 $abort Problems calling GDXXRW
$GDXIN Try2.gdx
$LOAD S<q11.dim1 K<q11.dim2 M<q11.dim3 q11
$GDXIN
-Michael
pradeep2431
User
User
Posts: 4
Joined: 5 years ago

Re: Error in creating GDX File from Excel Data

Post by pradeep2431 »

Dear Bussieck,

Thank you very much for your polite answer with nice explanation.
I am just a beginner in GAMS and will definitely look for the error log file in future for primary resolution.

Thanks a lot!
Regards
Pradeep
Post Reply