Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to get hermitian PSD example working #6

Closed
wants to merge 2 commits into from
Closed
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
9 changes: 5 additions & 4 deletions src/SDPT3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ const ALLOWED_OPTIONS = [
# `SparseMatrixCSC` is returned in SumOfSquares.jl test `sos_horn`
_array(x::AbstractMatrix) = x
_array(x::Vector) = x
_array(x::Float64) = [x]
_array(x::Union{Float64, Complex{Float64}}) = [x]

# TODO log in objective, OPTION, initial iterates X0, y0, Z0
# Solve the primal/dual pair
# min c'x, max b'y
# s.t. Ax = b, c - A'x ∈ K
# x ∈ K
function sdpt3(blk::Matrix,
At::Vector{<:Union{Matrix{Float64}, SparseMatrixCSC{Float64}}},
C::Vector{<:Union{Matrix{Float64}, Vector{Float64}}},
b::Vector{Float64}; kws...)
At::Vector{<:Union{Matrix{<:Union{Float64, Complex{Float64}}},
SparseMatrixCSC{<:Union{Float64, Complex{Float64}}}}},
C::Vector{<:Union{Matrix{<:Union{Float64, Complex{Float64}}}, Vector{<:Union{Float64, Complex{Float64}}}}},
b::Vector{<:Union{Float64, Complex{Float64}}}; kws...)
#C::Vector{<:Union{Vector{Float64}, SparseVector{Float64}}}, b::Vector{Float64})
options = Dict{String, Any}(string(key) => value for (key, value) in kws)
@assert all(i -> size(At[i], 2) == length(b), 1:length(At))
Expand Down
2 changes: 0 additions & 2 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ end

@testset "Unit" begin
MOIT.unittest(BRIDGED, CONFIG, [
# Need MOI v0.9.5
"solve_result_index",
# Get `termcode` -1, i.e. "relative gap < infeasibility".
"solve_blank_obj",
# Get `termcode` 3, i.e. "norm(X) or norm(Z) diverging".
Expand Down
31 changes: 31 additions & 0 deletions test/complex.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Test
using SDPT3

@testset "Project to hermitian PSD" begin
blk = ["q" 4.0
"s" 2.0]
C = Union{Matrix{Float64}, Vector{Float64}}[[1.0, 0.0, 0.0, 0.0], zeros(2, 2)]
A = Matrix{Float64}[
[0.0 1.0 0.0 0.0
0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0]',
[1.0 0.0 0.0
0.0 √2 0.0
0.0 0.0 1.0]']
b = [1.0, -√2 + √2 * im, -1.0]
# blk = ["s" 2.0]
# c = [0.0 1.0
# 1.0 0.0]
# A = [1.0 0.0 0.0
# 0.0 0.0 1.0]
# b = [1.0
# 1.0]
obj, X, y, Z, info, runhist = sdpt3(blk, A, C, b)
#obj, X, y, Z, info, runhist = sdpt3(blk, [Matrix(A')], C, b)
@show obj
@show X
@show y
@show Z
@show info
@show runhist
end