Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Mar 29, 2024
1 parent 916bb92 commit 476ddcd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/MOI/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3073,21 +3073,20 @@ function _has_primal_ray(model::Optimizer)
return has_Ray[] != 0
end

const _SOLSTATUS_MAP = Dict(
Lib.XPRS_SOLSTATUS_NOTFOUND => MOI.NO_SOLUTION,
Lib.XPRS_SOLSTATUS_OPTIMAL => MOI.FEASIBLE_POINT,
Lib.XPRS_SOLSTATUS_FEASIBLE => MOI.FEASIBLE_POINT,
Lib.XPRS_SOLSTATUS_INFEASIBLE => MOI.NO_SOLUTION,
Lib.XPRS_SOLSTATUS_UNBOUNDED => MOI.NO_SOLUTION,
)

function _cache_primal_status(model)
stat =
@_invoke Lib.XPRSgetintattrib(model.inner, Lib.XPRS_SOLSTATUS, _)::Int
if stat == Lib.XPRS_SOLSTATUS_UNBOUNDED && _has_primal_ray(model)
if _has_primal_ray(model)
return MOI.INFEASIBILITY_CERTIFICATE
end
return _SOLSTATUS_MAP[stat]
dict, attr = if is_mip(model)
_MIPSTATUS, Lib.XPRS_MIPSTATUS
else
_LPSTATUS, Lib.XPRS_LPSTATUS
end
stat = @_invoke Lib.XPRSgetintattrib(model.inner, attr, _)::Int
if dict[stat][2] in (MOI.OPTIMAL, MOI.LOCALLY_SOLVED)
return MOI.FEASIBLE_POINT
end
return MOI.NO_SOLUTION
end

function MOI.get(model::Optimizer, attr::MOI.PrimalStatus)
Expand Down
3 changes: 3 additions & 0 deletions test/test_MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,9 @@ end

function test_dummy_nlp()
model = Xpress.Optimizer(; OUTPUTLOG = 0)
if Xpress.get_version() < v"41.0.0"
return
end
x = MOI.add_variables(model, 2)
c = [1.0, 2.0]
MOI.set(
Expand Down

0 comments on commit 476ddcd

Please sign in to comment.