Skip to main content

Problem with logical constraint using addGenConstrIndicator()

Answered

Comments

2 comments

  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    Hi Ludwig,

    In your code, you have modeled
    if "finish"=1 then "beet_flow"=0,
    This relation does not restrict "beet_flow" in case "finish" has the value 0. So, you can have both 0.
    You probably want to define the constraint as

    model.addGenConstrIndicator(finish[i, t], 0, beet_flow[i, 0, 0, t] >= 1e-7)

    Here, the finish variable cannot take the value 0 if the beet_flow variable is 0 and must then be 1. Note that strict inequalities are not possible (Why doesn't Gurobi support strict inequality constraints like x < a?). That is why I used >= 1e-7 instead of >0. Furthermore, it is used that the LB of the beet_flow variables is 0.

    Best regards,
    Marika

    0
  • Ludwig Baunach
    First Comment
    First Question

    Hi Marika, 

    thank you very much for your response. It helped me fix the problem. Actually, I needed to add both constraints to create the correct indicator. Without the second other one I would get ones for all values. 

    for i in I:
    for t in T:
    model.addGenConstrIndicator(finish[i, t], 0, beet_flow[i, 0, 0, t] >= 1e-7)

    for i in I:
    for t in T:
    model.addGenConstrIndicator(finish[i, t], 1, beet_flow[i, 0, 0, t] <= 1e-7)

    Thank you for your help!

    Best regards,

    Ludwig

    0

Please sign in to leave a comment.