Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
julia 0.6
BinDeps
Glob
MathOptInterface 0.6 0.7
SemidefiniteOptInterface 0.3 0.4
MathOptInterface 0.7 0.8
SemidefiniteOptInterface 0.4 0.5
MathProgBase 0.7 0.8
SemidefiniteModels 0.1 0.2
Compat 1.0
4 changes: 2 additions & 2 deletions src/CSDP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include("declarations.h.jl")
include("declarations.jl")
include("debug-mat.jl")
include("options.jl")
include("MOIWrapper.jl")
include("MPBWrapper.jl")
include("MOI_wrapper.jl")
include("MPB_wrapper.jl")

end # module
38 changes: 29 additions & 9 deletions src/MOIWrapper.jl → src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ using MathOptInterface
MOI = MathOptInterface

mutable struct SDOptimizer <: SDOI.AbstractSDOptimizer
C
b
As
X
y
Z
C::Union{Nothing, BlockMatrix}
b::Union{Nothing, Vector{Cdouble}}
As::Union{Nothing, Vector{ConstraintMatrix}}
X::Union{Nothing, BlockMatrix}
y::Union{Nothing, Vector{Cdouble}}
Z::Union{Nothing, BlockMatrix}
status::Cint
pobj::Cdouble
dobj::Cdouble
Expand All @@ -22,6 +22,20 @@ mutable struct SDOptimizer <: SDOI.AbstractSDOptimizer
end
Optimizer(; kws...) = SDOI.SDOIOptimizer(SDOptimizer(; kws...))

MOI.get(::SDOptimizer, ::MOI.SolverName) = "CSDP"

function MOI.empty!(optimizer::SDOptimizer)
optimizer.C = nothing
optimizer.b = nothing
optimizer.As = nothing
optimizer.X = nothing
optimizer.y = nothing
optimizer.Z = nothing
optimizer.status = -1
optimizer.pobj = 0.0
optimizer.dobj = 0.0
end

function SDOI.init!(m::SDOptimizer, blkdims::Vector{Int}, nconstrs::Int)
@assert nconstrs >= 0
dummy = nconstrs == 0
Expand Down Expand Up @@ -66,10 +80,16 @@ end

function MOI.get(m::SDOptimizer, ::MOI.TerminationStatus)
status = m.status
if 0 <= status <= 2
return MOI.Success
if status == -1
return MOI.OptimizeNotCalled
elseif status == 0
return MOI.Optimal
elseif status == 1
return MOI.Infeasible
elseif status == 2
return MOI.DualInfeasible
elseif status == 3
return MOI.AlmostSuccess
return MOI.AlmostOptimal
elseif status == 4
return MOI.IterationLimit
elseif 5 <= status <= 7
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions src/declarations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ function setupAs!(As::Vector{ConstraintMatrix}, C::BlockMatrix)

nblocks = length(C.blocks)

byblocks = Vector{Ptr{sparseblock}}(undef, nblocks)
fill!(byblocks, C_NULL)
byblocks = fill(Ptr{sparseblock}(C_NULL), nblocks)

for constr in length(As):-1:1
A = As[constr]
Expand Down
4 changes: 4 additions & 0 deletions test/MOIWrapper.jl → test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ MOIU.@model(SDModelData,
const optimizer = MOIU.CachingOptimizer(SDModelData{Float64}(), CSDP.Optimizer(printlevel=0))
const config = MOIT.TestConfig(atol=1e-4, rtol=1e-4)

@testset "SolverName" begin
@test MOI.get(optimizer, MOI.SolverName()) == "CSDP"
end

@testset "Unit" begin
MOIT.unittest(MOIB.SplitInterval{Float64}(optimizer), config,
[# Quadratic functions are not supported
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ end
end

@testset "MathOptInterface" begin
include("MOIWrapper.jl")
include("MOI_wrapper.jl")
end
@testset "MathProgBase" begin
include("MPBWrapper.jl")
include("MPB_wrapper.jl")
end