简体   繁体   中英

Initializing 2D array of tuples from Sheets in OPL CPLEX

I have created a 2D array of tuples in OPL CPLEX. I am able to initialize the array directly from the .dat file but when I'm initializing it from an excel sheet, the error " N:int,a:float with 2 dimensions not supported for sheets" pops out. It seems like the feature to initialize a 2D array of tuples from sheet is not there. Is this the case or I'm making some mistake? Also, is there some other way to go about this? I'm attaching the snippet of the code below.

 /*mod file*/
 int M=...;
 range m=1..M;
 int B=...;
 range b=1..B;
 int T=...;
 range t=1..T;

 tuple data{
    int N;
    float a;
 }

 data d[m][b]=...;

 dvar boolean x[b][m][t];


/*dat file for direct initialization*/
 M=2;
 B=3;
 T=2;

 d=[[<1,1.5>,<2,1>,<7,5.6>],
    [<8,2.7>,<0,5.9>,<9,9.2>]];



 /*dat file for initialization from excel*/
 M=2;
 B=3;
 T=2;

 SheetConnection sheet("B2.xlsx");

 d from SheetRead(sheet,"d");


/*Excel sheet*/

Named Range of d in excel
1   1.5
2   1
7   5.6
8   2.7
0   5.9
9   9.2

It would work if d was a 2D structure but it is 3D since you have 2 indexes m and b and 2 elements within a tuple.

So I recommend the IBM technote Reading a 3-dimensional array from an Excel spreadsheet .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM