0

I want to add an excel to cplex but I just get this error: Exception from IBM ILOG Concert: excel: size of the range is not the size of the array. I used SheetConnection.

int M1=3;
int M2=3; 
int P1=3; 
int P2=3; 
int T=12;
int D=12; 
int H=2; 
int J=3;
range patients_meli=0..(M1+1);//0ta4
range patients_Tourist=(M1+2)..(M2+M1+2);
range providers_meli=1..P1;//1ta6
range providers_Tourist=(P1+1)..(P2+P1);
range Period=0..H;

int Cexcl[1..P1, 1..J*3]=...;
int C[p in providers_meli][j in 1..J][h in Period]=Cexcl[p,h+3*(J-1)];
int Cpexcl[1..P2, 1..J*3]=...;
int Cp[p in 1..3][j in 1..J][h in Period]=Cpexcl[p,h+3*(J-1)];

in my .dat file i add code like this:


SheetConnection sheetInput("Book1.xlsx");
Cexcl from SheetRead (sheetInput,"'cost1'!B3:G5");   
Cpexcl from SheetRead (sheetInput,"'cost2'!B3:G5");

I changed numbers I feel I defined my arrays wrong. or there is sth wrong with my excel. please help.

excel file pictures: [1]: https://i.stack.imgur.com/MTWvQ.png [1]: https://i.stack.imgur.com/pRCuS.png

ButchMonkey
  • 1,873
  • 18
  • 30

1 Answers1

0

in the .mod you wrote

int Cexcl[1..P1, 1..J*3]=...;

so the size should be 3 times 9

but in the .dat

Cexcl from SheetRead (sheetInput,"'cost1'!B3:G5"); 

is size 3 times 6

So that cannot be good.

You could have a look at the example oil in examples/opl/oil

Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15