[英]How to declare a dynamic array inside tuple in CPLEX?
我在 CPLEX 中聲明了一組元組。 元組內部聲明了一個二維數組,這些數組的長度對於元組數組的每個元素都會不同。 但是 CPLEX 顯示錯誤。 我附上了代碼片段。 誰能幫我這個?
int n=...;
range N=1..n;
tuple info{
int a;
int b;
int box[1..b];
float d;
}
info tuplearray[N]=...;
元組集中的所有數組 a 具有相同的大小。 所以我會使用元組集。
讓我給你舉個例子:
.mod
int n=4;
range N=1..n;
int m=2;
tuple info{
int a;
int b;
int box[1..m];
float d;
}
info tuplearray[i in N]=...;
execute
{
writeln(tuplearray);
}
tuple boxitem
{
int i;
int j;
int v;
}
{boxitem} boxitems={<1,1,1>,<2,1,3>,<2,2,4>,<3,1,2>,<4,1,2>};
int sizes[i in 1..n]=card({t | t in boxitems : t.i==i});
execute
{
writeln(sizes);
writeln(boxitems);
}
.dat
tuplearray=[<1,2,[1,2],1.5>,<3,4,[3,2],1.5>,<1,2,[4,2],1.5>,<7,8,[6,2],1.5>,];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.