[英]How do I input 3D array data in CPLEX?
Set of inputs
int i=...; //set of origins
int j=...; //set of destinations
int t=...;//set of time periods
i=100;
j=100;
t=4;
How do I input these data in CPLEX?如何在 CPLEX 中输入这些数据? Cplex cannot read 3D arrays from excel. Cplex 无法从 excel 读取 3D arrays。 Is there any way I could tell CPLEX to read 3D array data from CPLEX?有什么方法可以告诉 CPLEX 从 CPLEX 读取 3D 数组数据?
You can only read 2D arrays directly but with some tricks you can read from any dimension.您只能直接读取 2D arrays 但通过一些技巧您可以从任何维度读取。
A very good tech note answers this:一个非常好的技术说明回答了这个问题:
https://www.ibm.com/support/pages/node/125333 https://www.ibm.com/support/pages/node/125333
And a small example from https://github.com/AlexFleischerParis/oplexcel还有一个来自https://github.com/AlexFleischerParis/oplexcel的小例子
.mod .mod
range A=1..2;
range B=1..3;
range C=1..4;
tuple someTuple{
key int a;
key int b;
key int c;
int value;
};
{someTuple} someSet = ...;
int v[a in A][b in B][c in C]=item(someSet,<a,b,c>).value;
dvar int X[A][B][C];
subject to
{
forall(a in A,b in B,c in C) X[a][b][c]==v[a][b][c];
}
assert forall(a in A,b in B,c in C) X[a][b][c]==a*b*c;
.dat .dat
SheetConnection sheet("write3Darray.xlsx");
someSet from SheetRead(sheet,"A1:D24");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.