Skip to main content

RHS value

Answered

Comments

12 comments

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Could you please elaborate what exactly do you mean by "largest negative/positive change in RHS"?

    Do you want to access the RHS attribute of a linear constraint?

    0
  • Cong Jin
    Conversationalist
    First Question

    My problem is how to obtain the variation range of RHS with specified constraints while keeping the optimal solution unchanged, that is, the minimum and maximum values of RHS while keeping the optimal solution unchanged. Or the sensitivity analysis of restricting the right-hand constant, which is often mentioned in operational research.

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    For sensitivity analysis one usually requires the so-called shadow costs. You can access these via the Pi attribute. Is this what you are looking for?

    Or maybe you are looking for Gurobi's Multi Scenario feature?

    0
  • Cong Jin
    Conversationalist
    First Question

    Excuse me, is there any related attribute that can be directly found out about Δb?

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    What you are looking for is the linear constraint Slack attribute.

    print(constraint.Slack)
    0
  • Cong Jin
    Conversationalist
    First Question

    Hello, is this the same meaning as the reduced cost of the slack variable in the corresponding constraint?

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hello, is this the same meaning as the reduced cost of the slack variable in the corresponding constraint?

    The slack of a constraint is the difference between the right hand-side and the left hand-side of a given constraint.

    For example if you have the constraint \(2x + y \leq 3\) and the solution point \(x=0.5, y = -1\) then the slack is \( 3 - (2\cdot 0.5 - 1) = 3\).

    0
  • Cong Jin
    Conversationalist
    First Question

    Actually, what I want is LB, UB and RC in the following picture, but I don't know how to get them. Where X and H are variables.

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    You can access all variable attributes as described in the link provided by Matthias in your other post

    Attribute Examples - Optimizer Reference Manual - Gurobi Optimization

    You can also use the getAttr() method. Please note that some attributes like, e.g., the reduced costs (RC), are only available after a successful optimization run, i.e., after a successful call to the optimize() method.

    For an easier start with Gurobi and Python I recommend having a look at one of our webinars

    0
  • Cong Jin
    Conversationalist
    First Question

    Thank you very much for your help. For the whole mathematical model, I have successfully implemented it with gurobi, but I don't know if gurobi can directly calculate the parameters I need, especially the RC value mentioned in the above figure. Correspondingly, cplex can be found directly. I don't know if gurobi has a similar method.

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    As described in the documentation of the getAttr() method, you can use

    print(model.getAttr("RC", model.getVars()))

    Please note that the above is for Python.

    Which programming language are you planning to use?

     

    In addition to the above recommended webinars, it would make sense for you to have a look at

    Switching from other solvers to Gurobi

    0
  • Cong Jin
    Conversationalist
    First Question

    Thank you very much for your help.

    0

Please sign in to leave a comment.