Skip to main content

Creating conditional binary 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.
  • Ronald van der Velden
    • 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

    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

Post is closed for comments.