我定义了以下元组:
tuple capacity3 {
int sup; // varies from 1 to 5
int comp; // varies from 1 to 3
int peri; // varies from 1 to 6
int val3; // values corresponding to sup, comp, peri
}
{ capacity3 } aa = ...;
我把我的元组写成
aa={<1,1,1,620>,<1,1,2,610>,<1,1,3,630>,<1,1,4,620>,<1,1,5,640>,<1,1,6,630>, ... //and so on.
现在我有以下约束;
forall(i in I, c in C, p in P)
sum(j in J)X[i][j][c][p]<= RHS
在 RHS,我需要将定义为 val3 (620, 610 ....)
的值写入对应于特定 i,c 和 p
的元组中,它们是在我的元组中定义为 sup、comp 和 peri
。
我将如何写我的约束,即 RHS 的步幅值?或者我在其他地方也出错了?
我是 CPLEX 的新手。
最佳答案
同样的问题:
https://developer.ibm.com/answers/questions/387005/writing-constraint-for-a-tuple.html
你可以这样写:
.mod
tuple capacity3 {
key int sup; // varies from 1 to 5
key int comp; // varies from 1 to 3
key int peri; // varies from 1 to 6
int val3; // values corresponding to sup, comp, peri
}
range I=1..1;
range J=1..1;
range C=1..1;
range P=1..6;
{capacity3} aa=...;
dvar float X[I][J][C][P];
subject to
{
forall(i in I, c in C, p in P) sum(j in J)X[i][j][c][p]<= item(aa,<i,c,p>).val3;
}
.dat
aa={
<1,1,1,620>,<1,1,2,610>,
<1,1,3,630>,<1,1,4,620>,<1,1,5,640>,<1,1,6,630>
};
关于c - 元组的写入约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45127545/