Sensitivity analysis in optimization

Hello All,

New to Optimization & JuMP. Trying to do sensitivity analysis for this example, and wondering how to get reduced costs, objective coefficients, allowable increase/decrease, shadow prices, and final values for given constraints. They are very easy to get on excel solver. Read through the documentation here, Expressions and Constraints — JuMP -- Julia for Mathematical Optimization 0.18 documentation, but not helpful.

Please advice.

#Initialise values
n=4;r=[.1;.15;.16; 0.08]
A = [1 1 1 1]
b = 80
D = [.5 .3 .25 .6; .3 .1 .4 .2; .2 .6 .35 .2]
d = [28; 24; 12]

using JuMP
using Gurobi

#Define Model
model = Model(solver=GurobiSolver(Presolve=0))

#Define variables
@variable(model, x[1:4])
#Define Objective
@objective(model, Max, r'*x)
#Define constraints
@constraints model begin
       x .>= zeros(1,4)
       A*x .== b
       D*x .>= d
end

status = solve(model)

getvalue(x) # Giving correct final values

println(getdual(x)) # The duals are shown as zeros

Much of what you are asking for (e.g. allowable increase/decrease) isn’t implemented in JuMP. See
https://github.com/JuliaOpt/JuMP.jl/issues/1332

getdual(x) returns the dual variable associated with a variable bound. Since you don’t have bounds on your variables, this is 0.0.

getdual does work on constraints though:

@constraint(model, my_constraint, sum(x) <= 1)
getdual(my_constraint)
1 Like

I’m not sure if what you need is included, but if you use Clp as your solver, you can access the Clp C interface with using Clp.ClpCInterface to get access to more detailed solution information.

1 Like