如何在每个解决方案中确保二进制决策变量的第二个索引相等?

时间:2019-06-16 08:13:52

标签: cplex opl

我有一个二进制决策变量x[l][c][f]F的范围为1-6。现在,我希望f在每个解决方案中都相等。因此,每当二进制变量等于1时,对于所有非零二进制变量,f必须相同(1-6)。因此,在解决方案中,每个x都具有f的相同索引。

Range F = 1..6;

Range L = 1..28;

Range C = 1..6;

dvar boolean x[L][C][F];  // bin decision variable equal to 1 if line l is jused with c carriages at a frequency of f

Forall (l in L, c in C, f in F)
(x[l][c][f]==1) => ??

1 个答案:

答案 0 :(得分:1)

可以

range F = 1..6;

range L = 1..28;

range C = 1..6;

dvar boolean x[L][C][F]; // bin decision variable equal to 1 if line l is jused with c carriages at a frequency of f

subject to
{
forall (l in L, c in C) sum(f in F) x[l][c][f]==1 ;
}

帮助?

或有您的评论吗?

range F = 1..6;

range L = 1..28;

range C = 1..6;


dvar boolean x[L][C][F]; // bin decision variable equal to 1 if line l is jused with c carriages at a frequency of f
dvar int nbFrequencyUsed[F];

subject to
{
forall(f in F) nbFrequencyUsed[f]==sum (l in L, c in C) x[l][c][f];
1>=sum(f in F) (nbFrequencyUsed[f]>=1);
}