Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dual objective value with free variable #255

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2271,9 +2271,10 @@ function _active_bound(l, x, u, d)
end
elseif isfinite(l)
return l
else
@assert isfinite(u)
elseif isfinite(u)
return u
else
return 0.0
end
end

Expand Down
14 changes: 14 additions & 0 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -941,11 +941,13 @@ function test_active_bound()
(0.0, 1.0, 1.0, -2.0) => 1.0,
(0.0, 0.6, 1.0, -2.0) => 1.0,
(0.0, 0.6, 1.0, 2.0) => 1.0, # incorrect d but doesn't matter
(-Inf, 0.0, Inf, 0.0) => 0.0,
# It's a ray. Choose based on sign
(0.0, NaN, 1.0, 2.0) => 0.0,
(0.0, NaN, 1.0, 1e-10) => 0.0,
(0.0, NaN, 1.0, -2.0) => 1.0,
(0.0, NaN, 1.0, -1e-10) => 1.0,
(-Inf, NaN, Inf, 0.0) => 0.0,
# It's a one-sided ray
(0.0, NaN, Inf, 2.0) => 0.0,
(0.0, NaN, Inf, -1e-10) => 0.0,
Expand All @@ -972,6 +974,18 @@ function test_add_constrained_variable_tuple()
return
end

function test_dual_objective_value_infeasible()
model = HiGHS.Optimizer()
x = MOI.add_variable(model)
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
f = 1.0 * x
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
MOI.optimize!(model)
@test MOI.get(model, MOI.DualStatus()) == MOI.INFEASIBLE_POINT
@test MOI.get(model, MOI.DualObjectiveValue()) == 0.0
return
end

end # module

TestMOIHighs.runtests()
Loading