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

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.

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

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

• Gurobi Staff

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

print(constraint.Slack)

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

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

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.

• 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

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.

• 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

Thank you very much for your help.