diff --git a/src/MOI/MOI_wrapper.jl b/src/MOI/MOI_wrapper.jl index 91dac93d..6748cf19 100644 --- a/src/MOI/MOI_wrapper.jl +++ b/src/MOI/MOI_wrapper.jl @@ -482,7 +482,7 @@ function MOI.supports(model::Optimizer, attr::MOI.RawOptimizerAttribute) end p_id, p_type = Ref{Cint}(), Ref{Cint}() ret = Lib.XPRSgetcontrolinfo(model.inner, attr.name, p_id, p_type) - if ret != 0 + if ret != 0 || p_type[] == Lib.XPRS_TYPE_NOTDEFINED ret = Lib.XPRSgetattribinfo(model.inner, attr.name, p_id, p_type) end p_type_fail = p_type[] in (Lib.XPRS_TYPE_NOTDEFINED, Lib.XPRS_TYPE_INT64) @@ -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) diff --git a/test/test_MOI_wrapper.jl b/test/test_MOI_wrapper.jl index fc498158..76670877 100644 --- a/test/test_MOI_wrapper.jl +++ b/test/test_MOI_wrapper.jl @@ -1045,6 +1045,9 @@ function test_name_empty_names() end function test_dummy_nlp() + if Xpress.get_version() < v"41" + return + end model = Xpress.Optimizer(; OUTPUTLOG = 0) x = MOI.add_variables(model, 2) c = [1.0, 2.0] diff --git a/test/test_helper.jl b/test/test_helper.jl index 58f289ee..750d1dff 100644 --- a/test/test_helper.jl +++ b/test/test_helper.jl @@ -33,9 +33,10 @@ function test_show_xpress_error() end function test_xpress_problem_logfile() - p = Xpress.XpressProblem(; logfile = "test.log") - @test isfile("test.log") - rm("test.log") + # Use mktempdir so that the file is removed on process exit + filename = joinpath(mktempdir(), "test.log") + p = Xpress.XpressProblem(; logfile = filename) + @test isfile(filename) return end