Skip to main content

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

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support.
  • 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

Post is closed for comments.