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

gurobi indicator constraints multiple variables

回答済み

コメント

2件のコメント

  • 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

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