Skip to main content

two side condition with binary

Answered

Comments

1 comment

  • Simranjit Kaur
    • Gurobi Staff

    Hi Haung,

    Assuming X can only take non-negative values, you can model the condition "if 0<=X<=5, then x_in_grid==1" with the following constraints:

    X <= 5 + M*(1-x_in_grid)
    X >= 6*(1-x_in_grid)

    If X <= 5, x_in_grid will have to take value 1, as otherwise, the second constraint above will cause an infeasibility.

    Best regards,
    Simran

    0

Please sign in to leave a comment.