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

Make INFEASIBLE_PROBLEM PrimalStatus checks more flexible #54

Merged
merged 1 commit into from
Nov 13, 2024
Merged
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
26 changes: 22 additions & 4 deletions src/MINLPTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ const TERMINATION_TARGET_LOCAL = Dict(
)
const PRIMAL_TARGET_LOCAL = Dict(
FEASIBLE_PROBLEM => JuMP.MOI.FEASIBLE_POINT,
INFEASIBLE_PROBLEM => JuMP.MOI.INFEASIBLE_POINT,
INFEASIBLE_PROBLEM => [
JuMP.MOI.INFEASIBLE_POINT,
JuMP.MOI.NO_SOLUTION,
JuMP.MOI.UNKNOWN_RESULT_STATUS,
],
)

# Target status codes for global solvers:
Expand All @@ -45,21 +49,35 @@ const TERMINATION_TARGET_GLOBAL = Dict(
)
const PRIMAL_TARGET_GLOBAL = Dict(
FEASIBLE_PROBLEM => JuMP.MOI.FEASIBLE_POINT,
INFEASIBLE_PROBLEM => JuMP.MOI.NO_SOLUTION,
INFEASIBLE_PROBLEM => [
JuMP.MOI.INFEASIBLE_POINT,
JuMP.MOI.NO_SOLUTION,
JuMP.MOI.UNKNOWN_RESULT_STATUS,
],
)

###
### Helper functions for the tests.
###

_check_status_subset(x::T, y::T) where {T} = x == y
_check_status_subset(x::T, y::AbstractVector{T}) where {T} = x in y

function check_status(
model,
problem_type::ProblemTypeCode,
termination_target = TERMINATION_TARGET_LOCAL,
primal_target = PRIMAL_TARGET_LOCAL,
)
@test JuMP.termination_status(model) == termination_target[problem_type]
@test JuMP.primal_status(model) == primal_target[problem_type]
@test _check_status_subset(
JuMP.termination_status(model),
termination_target[problem_type],
)
@test _check_status_subset(
JuMP.primal_status(model),
primal_target[problem_type],
)
return
end

function check_objective(model, solution; tol = OPT_TOL)
Expand Down
Loading