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

Can one change variable values in a gurobipy model object and see how this affects constraints?

回答済み

コメント

2件のコメント

  • 正式なコメント
    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.
  • Simranjit Kaur
    • Gurobi Staff

    Hi Lutz,

    You can fix a variable by setting its lower bound and upper bound to the same value and resolve the model.

    var.UB = my_value
    var.LB = my_value

    To see how these changes affect your constraints, you can check constraint attributes like Slack or Pi. Slack shows the difference between the left-hand side and the right-hand side of the constraint, indicating how close the constraint is to being binding. Pi represents the dual prices or shadow prices of the constraints, which can tell you how the objective value would improve if you slightly increased the right-hand side of the constraint.

    slack = constr.getAttr('Slack')
    pi = constr.getAttr('Pi')

    You may also find the following articles helpful:

    Best regards,
    Simran

    0

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