Load dimension are different error

Problems with syntax of GAMS
Post Reply
amirbaghban
User
User
Posts: 3
Joined: 2 weeks ago

Load dimension are different error

Post by amirbaghban » 2 weeks ago

Hello everyone,

I am working on a model and need to load an excel file of a data set. For simplicity, I am bringing not the whole model but something that I can show the problem to resolve the issue. I also upload the excel file here.

My problem is that I do not know how to load the excel file correctly. I got an example of GAMS documentation and it works well but when I try a one-dimensional excel file or even two dimensional one, I get Load dimension are different error.

Code: Select all

Sets
  OP     /op1*op5/
  K       PUMP  /K0*K2/    ;


$call gdxxrw.exe Info.xlsx par=h rng=sheet1!A1:A5

parameter
h(op)
$gdxin Info.gdx
$load h
$gdxin
            ;
POSITIVE VARIABLES

 ST(K)
 G(op)
 MAKESPAN ;

FREE VARIABLE Z;

EQUATIONS
EQ1
OBJ     ;

EQ1.. h('op5')*G('op1') =e= st('k2')*h('op1');
OBJ..           Z =E= MAKESPAN;

OPTION OPTCR=1E-6;
OPTION DECIMALS=5;
OPTION LIMROW=100;
OPTION LIMCOL=100;
OPTION ITERLIM=90000000;
OPTION RESLIM=10800;
OPTION THREADS=0;

MODEL EX2  /ALL/;
SOLVE EX2  USING MIP MINIMIZING Z;
DISPLAY G.L,ST.L;[attachment=0]Info.xlsx[/attachment]
Attachments
Info.xlsx
(11.2 KiB) Downloaded 13 times

User avatar
bussieck
Moderator
Moderator
Posts: 832
Joined: 6 years ago

Re: Load dimension are different error

Post by bussieck » 2 weeks ago

I suggest that you look at the gdxxrw documentation (https://www.gams.com/latest/docs/T_GDXXRW.html). There are many good examples that you can follow. Reading GAMS indexed data requires the indexes (here op1*op5) to be present with the data. GAMS and GAMS tools do not read positional data.

-Michael

amirbaghban
User
User
Posts: 3
Joined: 2 weeks ago

Re: Load dimension are different error

Post by amirbaghban » 2 weeks ago

Dear Michael,

Thank you for your answer.

To be honest, I could not find any example tailored to my own problem.

I was wondering if you could resolve the error yourself.

The bests, Amir

User avatar
bussieck
Moderator
Moderator
Posts: 832
Joined: 6 years ago

Re: Load dimension are different error

Post by bussieck » 1 week ago

I think this comes pretty close: https://www.gams.com/latest/docs/T_GDXX ... DSHEET_PAR. Experiment and see how to adjust it to your own situation. Good luck.

-Michael

amirbaghban
User
User
Posts: 3
Joined: 2 weeks ago

Re: Load dimension are different error

Post by amirbaghban » 1 week ago

Dear Michael,

Thanks a lot. I saw this example before but never thought about dim statement. Now, I know how to read the table.

Thank you again. I am going to accept the answer.

Bests, Amir

Post Reply