Skip to main content

Defining Gurobi variables based on other variables

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.
  • 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

Post is closed for comments.