Skip to main content

Affect binary value only when continuous variable is negative

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.
  • Jaromił Najman
    • Gurobi Staff

    Hi Natalie,

    The constraint looks correct as along as the variable bounds of all constraints are set correctly, i.e., t_move >= 0 and tw_e has a non-default negative lower bound.

    When the constraint with t_move as a variable comes into effect, it results in an infeasible result.

    Did you try to find the cause of infeasibility as described in How do I determine why my model is infeasible?

    Best regards, 
    Jaromił

    0
  • Natalie Pueyo
    • Gurobi-versary
    • Conversationalist
    • First Question

    Hi Jaromil,

    The link you provided helped me determine that the lower bound I was using was wrong. I kept having trouble with that until I found a simpler version of the constraints which work:

    m.addConstrs(((x[k, l, i] == 0) for i in N for l in L for k in K if Y[i] - (self.q_vy + (k + 1)*self.cell_l) >= self.travel_l), name="fruitInHorizon")

    m.addConstrs(((x[k, l, i] == 0) for i in N for l in L for k in K if Y[i] - (self.q_vy + k*self.cell_l) <= 0 ), name="fruitStartPassed")

    This removed the need for the problematic lower bounds and the extra auxiliary variable t_move.

    Thank you!

    Natalie

    0

Post is closed for comments.