Skip to main content

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

Answered

Comments

1 comment

  • Maliheh Aramon
    • Gurobi Staff 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

Please sign in to leave a comment.