Skip to main content

Creating conditional binary variables

Answered

Comments

2 comments

  • Ronald van der Velden
    Gurobi Staff Gurobi Staff

    Hi Summer,


    You could try \(Y \leq M \cdot X\), where \(M\) is a number that is at least as large as the upperbound of \(Y\). Ideally you keep \(M\) as tight as possible to avoid running into numerical issues.

    If you also want to force \(X=0\) when \(Y=0\) then you would need a second constraint. But in many cases this is either irrelevant, or the objective function automatically enforces this relationship (e.g. when there's a cost associated to \(X\).

    Kind regards,

    Ronald

    0
  • Gwyneth Butera
    Gurobi Staff Gurobi Staff

    In addition to Ronald's reply, you can also refer to the Knowledge Base article How do I model conditional statements in Gurobi? which describes how to use indicator constraints.

    0

Please sign in to leave a comment.