Skip to content

Commit adb7878

Browse files
committed
Fixes
1 parent d224de2 commit adb7878

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ version = "0.2.0"
66
[deps]
77
DSDP_jll = "1065e140-e56c-5613-be8b-7480bf7138df"
88
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
9+
LowRankOpt = "607ca3ad-272e-43c8-bcbe-fc71b56c935c"
910
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
1011

1112
[compat]

src/MOI_wrapper.jl

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
55

66
import MathOptInterface as MOI
7+
import LowRankOpt as LRO
8+
9+
const _RankOneMatrix{F<:AbstractVector{Cdouble},D<:AbstractArray{Cdouble,0}} =
10+
LRO.Factorization{Cdouble,F,D}
11+
12+
const _SetDotProd{F<:AbstractMatrix{Cdouble},D<:AbstractVector{Cdouble}} =
13+
LRO.SetDotProducts{
14+
LRO.WITH_SET,
15+
MOI.PositiveSemidefiniteConeTriangle,
16+
LRO.TriangleVectorization{Cdouble,_RankOneMatrix{F,D}},
17+
}
718

819
mutable struct Optimizer <: MOI.AbstractOptimizer
920
dsdp::DSDPT
@@ -16,7 +27,7 @@ mutable struct Optimizer <: MOI.AbstractOptimizer
1627
# * `d` means a symmetric `d x d` block
1728
blockdims::Vector{Int}
1829
# MOI variable index -> rank 1 matrix it corresponds to
19-
rank_one::Vector{Union{Nothing,MOI.LowRankMatrix{Cdouble}}}
30+
rank_one::Vector{Union{Nothing,_RankOneMatrix}}
2031
# To avoid it being free'd
2132
cached_ind::Vector{Vector{Cint}}
2233
varmap::Vector{Tuple{Int,Int,Int}} # Variable Index vi -> blk, i, j
@@ -48,7 +59,7 @@ mutable struct Optimizer <: MOI.AbstractOptimizer
4859
1,
4960
Cdouble[],
5061
Int[],
51-
Union{Nothing,MOI.LowRankMatrix{Cdouble}}[],
62+
Union{Nothing,_RankOneMatrix}[],
5263
Vector{Cint}[],
5364
Tuple{Int,Int,Int}[],
5465
Int[],
@@ -229,13 +240,8 @@ end
229240

230241
MOI.supports_add_constrained_variables(::Optimizer, ::Type{MOI.Reals}) = false
231242

232-
const _SetWithDotProd = MOI.SetWithDotProducts{
233-
MOI.PositiveSemidefiniteConeTriangle,
234-
MOI.TriangleVectorization{Cdouble,MOI.LowRankMatrix{Cdouble}},
235-
}
236-
237243
const SupportedSets =
238-
Union{MOI.Nonnegatives,MOI.PositiveSemidefiniteConeTriangle,_SetWithDotProd}
244+
Union{MOI.Nonnegatives,MOI.PositiveSemidefiniteConeTriangle,_SetDotProd}
239245

240246
function MOI.supports_add_constrained_variables(
241247
::Optimizer,
@@ -277,8 +283,7 @@ function new_block(
277283
return
278284
end
279285

280-
function new_block(model::Optimizer, set::_SetWithDotProd)
281-
println("______________________Low-Rank")
286+
function new_block(model::Optimizer, set::_SetDotProd)
282287
blk = length(model.blockdims) + 1
283288
for i in eachindex(set.vectors)
284289
push!(model.varmap, (blk, 0, 0))
@@ -390,16 +395,6 @@ end
390395
function _set_A_matrices(m::Optimizer, i)
391396
for (blk, blkdim) in zip(m.blk, m.blockdims)
392397
if blkdim > 0 && !isempty(m.sdpdcoefs[end][blk])
393-
@show (
394-
blk - 1,
395-
i,
396-
blkdim,
397-
1.0,
398-
0,
399-
m.sdpdinds[end][blk],
400-
m.sdpdcoefs[end][blk],
401-
length(m.sdpdcoefs[end][blk]),
402-
)
403398
SDPCone.SetASparseVecMat(
404399
m.sdpcone,
405400
blk - 1,
@@ -440,7 +435,7 @@ function MOI.copy_to(dest::Optimizer, src::MOI.ModelLike)
440435
index_map,
441436
MOI.PositiveSemidefiniteConeTriangle,
442437
)
443-
constrain_variables_on_creation(dest, src, index_map, _SetWithDotProd)
438+
constrain_variables_on_creation(dest, src, index_map, _SetDotProd)
444439
vis_src = MOI.get(src, MOI.ListOfVariableIndices())
445440
if length(vis_src) < length(index_map.var_map)
446441
_error(

0 commit comments

Comments
 (0)