Skip to main content

gurobi indicator constraints multiple variables

Answered

Comments

3 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.
  • Jaromił Najman
    • Gurobi Staff

    Hi Leon,

    This is discussed in the Knowledge Base article How do I model conditional statements in Gurobi?

    In particular, you will not need an \(\epsilon > 0\), since your condition is a \(\geq\) and not a strict inequality.

    Moreover, if your condition reads "if sum is greater or equal than 0 then set b = 1 else b = 0", then you don't need the additional indicator variables discussed in the linked Knowledge Base article, because \(b\) then already holds the value of your binary.

    In your special case, you can use the constraint

    \[\begin{align*}
    \sum z \leq M \cdot r
    \end{align*}\]

    where \(M\) is a big-M constant equal to the number of binary variables \(z\). This way, if \(\sum z \geq 1\) holds, then \(r\) has to be set to \(1\).. Note that in this case if \(\sum z = 0\), then \(r\) can be \(0\) or \(1\).

    Best regards, 
    Jaromił

    1
  • Leon Irsig
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Jaromił,

    Thanks for your help!

    Best regards,
    Leon

    0

Post is closed for comments.