Hi there, welcome to the forum.
For the dual ray, you need to use dual
instead of shadow_price
.
Here’s an example:
julia> using JuMP, HiGHS
julia> model = Model(HiGHS.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: HiGHS
julia> set_attribute(model, "presolve", "off")
julia> @variable(model, x[1:2] >= 0)
2-element Vector{VariableRef}:
x[1]
x[2]
julia> @objective(model, Min, -sum(x))
-x[1] - x[2]
julia> @constraint(model, c1, x[1] <= 1)
c1 : x[1] ≤ 1
julia> @constraint(model, c2, sum(x) >= 3)
c2 : x[1] + x[2] ≥ 3
julia> @constraint(model, c3, x[2] <= 1)
c3 : x[2] ≤ 1
julia> optimize!(model)
Running HiGHS 1.5.3 [date: 1970-01-01, git hash: 45a127b78]
Copyright (c) 2023 HiGHS under MIT licence terms
Solving LP without presolve or with basis
Using EKK dual simplex solver - serial
Iteration Objective Infeasibilities num(sum)
0 -1.9999961998e+00 Ph1: 3(3); Du: 2(2) 0s
3 -1.9999961998e+00 0s
Model status : Infeasible
Simplex iterations: 3
Objective value : -2.0000000000e+00
HiGHS run time : 0.00
julia> dual_status(model)
INFEASIBILITY_CERTIFICATE::ResultStatusCode = 4
julia> cons = [c1, c2, c3]
3-element Vector{ConstraintRef{Model, C, ScalarShape} where C}:
c1 : x[1] ≤ 1
c2 : x[1] + x[2] ≥ 3
c3 : x[2] ≤ 1
julia> ray = dual.(cons)
3-element Vector{Float64}:
-1.0
1.0
-1.0
julia> ray = shadow_price.(cons)
3-element Vector{Float64}:
-1.0
-1.0
-1.0
(Note the change in sign!)
shadow_price
is really just a helper function for querying the dual solution of an LP at it is taught in some textbooks. See Constraints · JuMP.