Skip to main content

Affect binary value only when continuous variable is negative

Answered

Comments

2 comments

  • 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

Please sign in to leave a comment.