Skip to content

Commit

Permalink
Make INFEASIBLE_PROBLEM PrimalStatus checks more flexible (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Nov 13, 2024
1 parent 46ce897 commit 8e263a4
Showing 1 changed file with 22 additions and 4 deletions.
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

0 comments on commit 8e263a4

Please sign in to comment.