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

Defining Gurobi variables based on other variables

回答済み

コメント

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

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