Error while reading four-dimensional data form excel Topic is solved

Problems with syntax of GAMS
Post Reply
ceepbit
User
User
Posts: 4
Joined: 7 years ago

Error while reading four-dimensional data form excel

Post by ceepbit »

Dear all,

It's correct while I using $CALL GDXXRW.exe to reading two-dimensional data from excel file. However, when I want to read "four-dimensional data" from excel file, an error occurred.
the Gams code are as follows:

$CALL GDXXRW.exe x2017b.xlsx par=SAM rng=A1:E5 rdim=1 cdim=1
$GDXIN x2017b.gdx
sets u /BT, SE, NE, AGRI, INDU, SERV/
r(u) /BT, SE, NE/
i(u) /AGRI,INDU, SERV/ ;
Alias (i,j),(r,s);
Parameter SAM(*,*,*,*);
$LOAD SAM
$GDXIN
display SAM;[/i][/i]

the error log is,
*** Error 495 in E:\2017 ...\for try 1.gms
Load dimension are different
--- for try 1.gms(15) 3 Mb 2 Errors
*** Error 141 in E:\2017 ...\for try 1.gms
Symbol neither initialized nor assigned
A wild shot: You may have spurious commas in the explanatory
text of a declaration. Check symbol reference list.
--- for try 1.gms(19) 3 Mb 2 Errors

the excel file is.
dummy BT.AGRI BT.INDU SE.AGRI SE.INDU
BT.AGRI 1 2 0.3 0.8
BT.INDU 2 1 0.8 1.3
SE.AGRI 0.6 0.5 1 0.9
SE.INDU 1.8 1.3 2.6 2.3

It would be appreciative if you can give me a help.
Waiting for your reply.
Thanks in advance.

Other Gams code for reading four-dimensional data form excel is also welcome, and thank you very much.
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Error while reading four-dimensional data form excel

Post by Renger »

Hi Ceepbit

You shouldn't use the dot-notation. Every set element should be in its own cell in excel. In your case:

Code: Select all

				BT
				AGR
AGRI	INDU	1
The gdxxrw command will then be:

Code: Select all

$CALL GDXXRW.exe x2017b.xlsx par=SAM rng=A1:E6 rdim=2 cdim=2
Two sets are found in the rows (rdim=2), two sets are found in the columns (cdim=2) and your range is one row bigger.
You could also put three set elements in the row and just one in the columns: rdim=3 cdim=1

Hope this helps

Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
ceepbit
User
User
Posts: 4
Joined: 7 years ago

Re: Error while reading four-dimensional data form excel

Post by ceepbit »

Hi Renger,

Thank you very much for your suggestion. It is very useful.
Post Reply