Skip to content

Commit

Permalink
Fix supports_constraint(::Optimizer, ::Type{VariableIndex}, ::Type{Ze…
Browse files Browse the repository at this point in the history
…roOne}) (#242)
  • Loading branch information
odow authored Oct 23, 2024
1 parent 201cbed commit c7cf7ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 61 deletions.
5 changes: 2 additions & 3 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2410,12 +2410,11 @@ end
###

function MOI.supports_constraint(
model::Optimizer,
::Optimizer,
::Type{MOI.VariableIndex},
::Type{<:Union{MOI.ZeroOne,MOI.Integer}},
)
solver = MOI.get(model, MOI.RawOptimizerAttribute("solver"))
return solver != "simplex" && solver != "ipm"
return true
end

function MOI.is_valid(
Expand Down
61 changes: 3 additions & 58 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,12 @@ function runtests()
return
end

const _EXPLICIT_METHOD_FAILURES = [
"test_objective_qp_ObjectiveFunction_edge_cases",
"test_objective_qp_ObjectiveFunction_zero_ofdiag",
"test_quadratic_duplicate_terms",
"test_quadratic_integration",
"test_quadratic_nonhomogeneous",
"test_linear_Semicontinuous_integration",
"test_linear_Semiinteger_integration",
]

function test_runtests()
model = MOI.Bridges.full_bridge_optimizer(HiGHS.Optimizer(), Float64)
MOI.set(model, MOI.Silent(), true)
# Turn presolve off so that we generate infeasibility certificates. This is
# a temporary work-around until we fix this upstream in HiGHS.
MOI.set(model, MOI.RawOptimizerAttribute("presolve"), "off")
# Slightly loosen tolerances, particularly for QP tests
MOI.Test.runtests(model, MOI.Test.Config(; atol = 1e-7))
return
Expand All @@ -53,54 +46,6 @@ function test_runtests_cache()
return
end

function test_runtests_simplex()
model = MOI.Bridges.full_bridge_optimizer(HiGHS.Optimizer(), Float64)
MOI.set(model, MOI.Silent(), true)
MOI.set(model, MOI.RawOptimizerAttribute("solver"), "simplex")
for presolve in ("on", "off")
MOI.set(model, MOI.RawOptimizerAttribute("presolve"), presolve)
MOI.Test.runtests(
model,
MOI.Test.Config();
exclude = _EXPLICIT_METHOD_FAILURES,
)
end
return
end

function test_runtests_ipm()
model = MOI.Bridges.full_bridge_optimizer(HiGHS.Optimizer(), Float64)
MOI.set(model, MOI.Silent(), true)
MOI.set(model, MOI.RawOptimizerAttribute("solver"), "ipm")
MOI.Test.runtests(
model,
MOI.Test.Config();
exclude = _EXPLICIT_METHOD_FAILURES,
)
return
end

function test_runtests_ipm_no_presolve()
model = MOI.Bridges.full_bridge_optimizer(HiGHS.Optimizer(), Float64)
MOI.set(model, MOI.Silent(), true)
MOI.set(model, MOI.RawOptimizerAttribute("solver"), "ipm")
MOI.set(model, MOI.RawOptimizerAttribute("presolve"), "off")
MOI.Test.runtests(
model,
MOI.Test.Config(),
exclude = [
# Termination status is OTHER_ERROR
r"^test_conic_linear_INFEASIBLE$",
r"^test_conic_linear_INFEASIBLE_2$",
# See https://github.com/ERGO-Code/HiGHS/issues/1807
r"^test_conic_NormInfinityCone_INFEASIBLE$",
r"^test_conic_NormOneCone_INFEASIBLE$",
_EXPLICIT_METHOD_FAILURES...,
],
)
return
end

function test_SolverName()
@test MOI.get(HiGHS.Optimizer(), MOI.SolverName()) == "HiGHS"
return
Expand Down

0 comments on commit c7cf7ec

Please sign in to comment.