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

Problem with logical constraint using addGenConstrIndicator()

回答済み

コメント

3件のコメント

  • 正式なコメント
    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.
  • Marika Karbstein
    • 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
    • Gurobi-versary
    • 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

投稿コメントは受け付けていません。