Skip to main content

Defining Gurobi variables based on other variables

Answered

Comments

2 comments

  • Matthias Miltenberger
    • Gurobi Staff

    Hi Helen,

    All variables in Gurobi have an implicit lower bound of 0 - it is customary to model with nonnegative variables. I imagine that the infeasibility comes from your continuous deviation variables being nonnegative as well. You need to define them as follows:

    deviation[i,j] = model.addVar(
    vtype=GRB.CONTINUOUS,
    lb=-GRB.INFINITY,
    name=f"deviation[{i,j}]"
    )

    I hope that fixes your issue.

    Cheers,
    Matthias

    0
  • Helen Koch
    • Gurobi-versary
    • First Question
    • First Comment

    Hi Matthias,

    thank you so much for your prompt reply - I didn't know that, but it works now!

     

    Best,

    Helen

    0

Please sign in to leave a comment.