Skip to content
This repository has been archived by the owner on Feb 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #58 from JuliaOpt/bl/moi7
Browse files Browse the repository at this point in the history
Add support for MOI v0.7
  • Loading branch information
blegat authored Dec 13, 2018
2 parents 5652c09 + 5c1558c commit d7c1be9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.7
MathOptInterface 0.6 0.7
MathOptInterface 0.7 0.8
Mosek
Compat 1
7 changes: 4 additions & 3 deletions src/MathOptInterfaceMosek.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ mutable struct MosekModel <: MOI.AbstractOptimizer
conecounter :: Int

###########################
trm :: Rescode
trm :: Union{Nothing, Rescode}
solutions :: Vector{MosekSolution}

###########################
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 15 additions & 4 deletions src/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -486,31 +486,42 @@ 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
MOI.TimeLimit
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
MOI.NodeLimit
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
Expand Down

0 comments on commit d7c1be9

Please sign in to comment.