diff --git a/REQUIRE b/REQUIRE index 98a16d6..0962221 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,4 @@ julia 0.7 -MathOptInterface 0.6 0.7 +MathOptInterface 0.7 0.8 Mosek Compat 1 diff --git a/src/MathOptInterfaceMosek.jl b/src/MathOptInterfaceMosek.jl index f5cc627..a08bc33 100644 --- a/src/MathOptInterfaceMosek.jl +++ b/src/MathOptInterfaceMosek.jl @@ -250,7 +250,7 @@ mutable struct MosekModel <: MOI.AbstractOptimizer conecounter :: Int ########################### - trm :: Rescode + trm :: Union{Nothing, Rescode} solutions :: Vector{MosekSolution} ########################### @@ -336,7 +336,7 @@ function MosekOptimizer(; kws...) Int[], # c_block_slack Int[], # c_coneid 0, # cone counter - Mosek.MSK_RES_OK,# trm + nothing,# trm MosekSolution[], true) # feasibility_sense end @@ -418,11 +418,12 @@ function MOI.empty!(model::MosekModel) model.c_block_slack = Int[] model.c_coneid = Int[] model.conecounter = 0 - model.trm = Mosek.MSK_RES_OK + model.trm = nothing model.solutions = MosekSolution[] model.feasibility = true end +MOIU.supports_default_copy_to(::MosekModel, copy_names::Bool) = !copy_names function MOI.copy_to(dest::MosekModel, src::MOI.ModelLike; copy_names=true) return MOIU.default_copy_to(dest, src, copy_names) end diff --git a/src/attributes.jl b/src/attributes.jl index d8520d4..693699e 100644 --- a/src/attributes.jl +++ b/src/attributes.jl @@ -486,8 +486,17 @@ end #### Status codes function MOI.get(m::MosekModel,attr::MOI.TerminationStatus) - if m.trm == MSK_RES_OK - MOI.Success + if m.trm === nothing + MOI.OptimizeNotCalled + elseif m.trm == MSK_RES_OK + if any(sol -> sol.solsta == MSK_SOL_STA_PRIM_INFEAS_CER, m.solutions) + MOI.Infeasible + elseif any(sol -> sol.solsta == MSK_SOL_STA_DUAL_INFEAS_CER, + m.solutions) + MOI.DualInfeasible + else + MOI.Optimal + end elseif m.trm == MSK_RES_TRM_MAX_ITERATIONS MOI.IterationLimit elseif m.trm == MSK_RES_TRM_MAX_TIME @@ -495,9 +504,9 @@ function MOI.get(m::MosekModel,attr::MOI.TerminationStatus) elseif m.trm == MSK_RES_TRM_OBJECTIVE_RANGE MOI.ObjectiveLimit elseif m.trm == MSK_RES_TRM_MIO_NEAR_REL_GAP - MOI.AlmostSuccess + MOI.AlmostOptimal elseif m.trm == MSK_RES_TRM_MIO_NEAR_ABS_GAP - MOI.AlmostSuccess + MOI.AlmostOptimal elseif m.trm == MSK_RES_TRM_MIO_NUM_RELAXS MOI.OtherLimit elseif m.trm == MSK_RES_TRM_MIO_NUM_BRANCHES @@ -505,12 +514,14 @@ function MOI.get(m::MosekModel,attr::MOI.TerminationStatus) elseif m.trm == MSK_RES_TRM_NUM_MAX_NUM_INT_SOLUTIONS MOI.SolutionLimit elseif m.trm == MSK_RES_TRM_STALL + println("STALL") MOI.SlowProgress elseif m.trm == MSK_RES_TRM_USER_CALLBACK MOI.Interrupted elseif m.trm == MSK_RES_TRM_MAX_NUM_SETBACKS MOI.OtherLimit elseif m.trm == MSK_RES_TRM_NUMERICAL_PROBLEM + println("NUMERICAL_PROBLEM") MOI.SlowProgress elseif m.trm == MSK_RES_TRM_INTERNAL MOI.OtherError