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

Defining Gurobi variables based on other variables

回答済み

コメント

2件のコメント

  • 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

サインインしてコメントを残してください。