メインコンテンツへスキップ

How to formulate multiple conditional logical (AND and OR) constraints

回答済み

コメント

1件のコメント

  • Maliheh Aramon
    • Gurobi Staff

    Hi, 

    You can define an auxiliary variable \(z_{ik} = x_i \land x_k\, ~~ \forall i, k\). The logical And constraints can be implemented using the Model.addGenConstrAnd() method in Gurobi Python API. 

    You can then use the Model.addGenConstrIndicator() method to implement the following two constraints for all \(i\) and \(k\) indices where \(i \neq k\):

    • \(\mbox{if}~ z_{ik} = 1 \rightarrow px_i - px_k + M \eta \leq M - l_i\)
    • \(\mbox{if}~ z_{ik} = 1 \rightarrow px_i - px_k - M \eta \leq - l_k\)

    Best regards,

    Maliheh

    0

サインインしてコメントを残してください。