Skip to content

Commit 66ff3d7

Browse files
authored
Merge pull request #36 from JuliaOpt/bl/moi7
Update to MOI v0.7
2 parents c7b0f6c + 28a0aec commit 66ff3d7

File tree

8 files changed

+40
-17
lines changed

8 files changed

+40
-17
lines changed

REQUIRE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
julia 0.6
22
BinDeps
33
Glob
4-
MathOptInterface 0.6 0.7
5-
SemidefiniteOptInterface 0.3 0.4
4+
MathOptInterface 0.7 0.8
5+
SemidefiniteOptInterface 0.4 0.5
66
MathProgBase 0.7 0.8
77
SemidefiniteModels 0.1 0.2
88
Compat 1.0

src/CSDP.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ include("declarations.h.jl")
1919
include("declarations.jl")
2020
include("debug-mat.jl")
2121
include("options.jl")
22-
include("MOIWrapper.jl")
23-
include("MPBWrapper.jl")
22+
include("MOI_wrapper.jl")
23+
include("MPB_wrapper.jl")
2424

2525
end # module

src/MOIWrapper.jl renamed to src/MOI_wrapper.jl

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ using MathOptInterface
55
MOI = MathOptInterface
66

77
mutable struct SDOptimizer <: SDOI.AbstractSDOptimizer
8-
C
9-
b
10-
As
11-
X
12-
y
13-
Z
8+
C::Union{Nothing, BlockMatrix}
9+
b::Union{Nothing, Vector{Cdouble}}
10+
As::Union{Nothing, Vector{ConstraintMatrix}}
11+
X::Union{Nothing, BlockMatrix}
12+
y::Union{Nothing, Vector{Cdouble}}
13+
Z::Union{Nothing, BlockMatrix}
1414
status::Cint
1515
pobj::Cdouble
1616
dobj::Cdouble
@@ -22,6 +22,20 @@ mutable struct SDOptimizer <: SDOI.AbstractSDOptimizer
2222
end
2323
Optimizer(; kws...) = SDOI.SDOIOptimizer(SDOptimizer(; kws...))
2424

25+
MOI.get(::SDOptimizer, ::MOI.SolverName) = "CSDP"
26+
27+
function MOI.empty!(optimizer::SDOptimizer)
28+
optimizer.C = nothing
29+
optimizer.b = nothing
30+
optimizer.As = nothing
31+
optimizer.X = nothing
32+
optimizer.y = nothing
33+
optimizer.Z = nothing
34+
optimizer.status = -1
35+
optimizer.pobj = 0.0
36+
optimizer.dobj = 0.0
37+
end
38+
2539
function SDOI.init!(m::SDOptimizer, blkdims::Vector{Int}, nconstrs::Int)
2640
@assert nconstrs >= 0
2741
dummy = nconstrs == 0
@@ -66,10 +80,16 @@ end
6680

6781
function MOI.get(m::SDOptimizer, ::MOI.TerminationStatus)
6882
status = m.status
69-
if 0 <= status <= 2
70-
return MOI.Success
83+
if status == -1
84+
return MOI.OptimizeNotCalled
85+
elseif status == 0
86+
return MOI.Optimal
87+
elseif status == 1
88+
return MOI.Infeasible
89+
elseif status == 2
90+
return MOI.DualInfeasible
7191
elseif status == 3
72-
return MOI.AlmostSuccess
92+
return MOI.AlmostOptimal
7393
elseif status == 4
7494
return MOI.IterationLimit
7595
elseif 5 <= status <= 7
File renamed without changes.

src/declarations.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ function setupAs!(As::Vector{ConstraintMatrix}, C::BlockMatrix)
1616

1717
nblocks = length(C.blocks)
1818

19-
byblocks = Vector{Ptr{sparseblock}}(undef, nblocks)
20-
fill!(byblocks, C_NULL)
19+
byblocks = fill(Ptr{sparseblock}(C_NULL), nblocks)
2120

2221
for constr in length(As):-1:1
2322
A = As[constr]

test/MOIWrapper.jl renamed to test/MOI_wrapper.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ MOIU.@model(SDModelData,
1818
const optimizer = MOIU.CachingOptimizer(SDModelData{Float64}(), CSDP.Optimizer(printlevel=0))
1919
const config = MOIT.TestConfig(atol=1e-4, rtol=1e-4)
2020

21+
@testset "SolverName" begin
22+
@test MOI.get(optimizer, MOI.SolverName()) == "CSDP"
23+
end
24+
2125
@testset "Unit" begin
2226
MOIT.unittest(MOIB.SplitInterval{Float64}(optimizer), config,
2327
[# Quadratic functions are not supported
File renamed without changes.

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ end
6363
end
6464

6565
@testset "MathOptInterface" begin
66-
include("MOIWrapper.jl")
66+
include("MOI_wrapper.jl")
6767
end
6868
@testset "MathProgBase" begin
69-
include("MPBWrapper.jl")
69+
include("MPB_wrapper.jl")
7070
end

0 commit comments

Comments
 (0)