【问题标题】:Express equation in CPLEX ILOG在 CPLEX ILOG 中表达方程
【发布时间】:2021-04-09 03:07:18
【问题描述】:

我目前正在 IBM ILOG Cplex 上进行项目编码。我一直在将数学模型转换为 CPLEX 中的约束。在这里,我想知道我们如何在 cplex 上编写这个约束,因为它有 3 个元素。我尝试了 OR 逻辑但结果似乎错误 enter image description here

【问题讨论】:

    标签: cplex constraint-programming opl mathematical-expressions


    【解决方案1】:

    或者在 OPL 中可以正常工作,但您将其写为 ||

    参见示例https://github.com/AlexFleischerParis/zooopl/blob/master/zoodisjunction.mod

    int nbKids=300;
    float costBus40=500;
    float costBus30=400;
     
    dvar int+ nbBus40;
    dvar int+ nbBus30;
     
    minimize
     costBus40*nbBus40  +nbBus30*costBus30;
     
    subject to
    {
     40*nbBus40+nbBus30*30>=nbKids;
    
    //with nb buses 40 less than 3 or more than 7
    (nbBus40<=3) || (nbBus40>=7);
    }
    

    【讨论】:

    • 我可以写 forall(...) 公式 a == 公式 b == 公式 c。如果满足条件公式 a == b,循环是否终止?
    • 没有。小心x==y==z;与 (x==y)==z 相同;这意味着 z 是 0 还是 1 根据 x==y
    • 我已尝试将上述公式作为 forall (l in N, k in K, w in W) fc[l][k][w] + sum(i in N:i!= l)y[i][l][k][w] ==x[l][k][w] || lc[l][k][w] + sum(i in N:i!=l)y[l][i][k][w] ==x[l][k][w] ;但这似乎不起作用。结果给了我 fc=1 而其余的都等于 0
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-30
    • 1970-01-01
    • 1970-01-01
    • 2013-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多