问:CPLEX:如何将2个方程写为1个常数

时间:2018-07-20 09:30:12

标签: mathematical-optimization linear-programming cplex

我正在使用CPLEX解决MILP。现在我要用相同的变量写这两个方程式

view the equations

我试图将其写入

(第一个方程为)

ct20 : forall(r1 in request,r2 in request, m1 in deliveries, m2 in deliveries : m1!=m2, k1 in truck, k2 in truck:k1!=k2, j1 in truck, j2 in truck:j1!=j2)
  sum(p in plant, k1 in truck:k1!=k2, j1 in jobs:j1!=j2)(x[p][r1][m1][k1][j1]*start_load[k1][j1]) <= sum(p in plant, k2 in truck:k1!=k2, j2 in jobs:j1!=j2)(x[p][r1][m1][k1][j1]*start_load[k2][j2])

(第二个方程为)

&& sum(p in plant, k1 in truck:k1!=k2, j1 in jobs:j1!=j2)(x[p][r1][m1][k1][j1]*start_load[k1][j1]+load_time[p][k1]) 
    <= sum(p in plant, k2 in truck:k1!=k2, j2 in jobs:j1!=j2)(x[p][r1][m1][k1][j1]*start_load[k2][j2])

如何将它们合并为一个,谢谢。

1 个答案:

答案 0 :(得分:1)

您知道您可以将约束与{和}分组吗?

range r=1..10;

dvar int x[r] in 0..10;

subject to
{
forall(i in r) 
{
4<=x[i];

x[i]<=6;
}


}

致谢