Skip to content

Commit 15043b2

Browse files
Fixed nuclearnorm and sumlargesteigs for complex variables (#409)
* added tests for hcat fix * nuclearnorm fix for complex variables * sumlargesteigs fix for non-positive and complex variables * Update src/problem_depot/problems/sdp.jl Co-authored-by: Eric Hanson <[email protected]> * Revert hcat tests which were already added Co-authored-by: Eric Hanson <[email protected]> * sumlargesteigs: updated comment to reflect support for non-PSD arguments * nuclearnorm: added reference to Watrous' TQI for complex case * added sumlargesteigs to docs/src/operations.md * fix sumlargesteigs: sign is now NoSign Co-authored-by: Eric Hanson <[email protected]>
1 parent 621c212 commit 15043b2

File tree

4 files changed

+76
-16
lines changed

4 files changed

+76
-16
lines changed

docs/src/operations.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,14 @@ Semidefinite Program Representable Functions
106106
An optimization problem using these functions can be solved by any SDP
107107
solver (including SCS and Mosek).
108108

109-
| operation | description | vexity | slope | notes |
110-
| ------------------ | --------------------------------- | ------- | ------------- | ------------------------------ |
111-
| `nuclearnorm(x)` | sum of singular values of $x$ | convex | not monotonic | none |
112-
| `operatornorm(x)` | max of singular values of $x$ | convex | not monotonic | none |
113-
| `eigmax(x)` | max eigenvalue of $x$ | convex | not monotonic | none |
114-
| `eigmin(x)` | min eigenvalue of $x$ | concave | not monotonic | none |
115-
| `matrixfrac(x, P)` | $x^TP^{-1}x$ | convex | not monotonic | IC: P is positive semidefinite |
109+
| operation | description | vexity | slope | notes |
110+
| ------------------ | --------------------------------- | ------- | ------------- | ------------------------------ |
111+
| `nuclearnorm(x)` | sum of singular values of $x$ | convex | not monotonic | none |
112+
| `operatornorm(x)` | max of singular values of $x$ | convex | not monotonic | none |
113+
| `eigmax(x)` | max eigenvalue of $x$ | convex | not monotonic | none |
114+
| `eigmin(x)` | min eigenvalue of $x$ | concave | not monotonic | none |
115+
| `matrixfrac(x, P)` | $x^TP^{-1}x$ | convex | not monotonic | IC: P is positive semidefinite |
116+
| `sumlargesteigs(x, k)` | sum of top $k$ eigenvalues of $x$ | convex | not monotonic | IC: P symmetric |
116117

117118
Exponential + SDP representable Functions
118119
-----------------------------------------

src/atoms/sdp_cone/nuclearnorm.jl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,22 @@ nuclearnorm(x::AbstractExpr) = NuclearNormAtom(x)
4444
# [U A; A' V] ⪰ 0
4545
# see eg Recht, Fazel, Parillo 2008 "Guaranteed Minimum-Rank Solutions of Linear Matrix Equations via Nuclear Norm Minimization"
4646
# http://arxiv.org/pdf/0706.4138v1.pdf
47+
#
48+
# The complex case is example 1.20 of Watrous' "The Theory of Quantum Information"
49+
# (the operator A is negated but this doesn't affect the norm)
50+
# https://cs.uwaterloo.ca/~watrous/TQI/TQI.pdf
4751
function conic_form!(x::NuclearNormAtom, unique_conic_forms)
4852
if !has_conic_form(unique_conic_forms, x)
4953
A = x.children[1]
5054
m, n = size(A)
51-
U = Variable(m,m)
52-
V = Variable(n,n)
53-
p = minimize(.5*(tr(U) + tr(V)), [U A; A' V] 0)
55+
if sign(A) == ComplexSign()
56+
U = ComplexVariable(m,m)
57+
V = ComplexVariable(n,n)
58+
else
59+
U = Variable(m,m)
60+
V = Variable(n,n)
61+
end
62+
p = minimize(.5*real(tr(U) + tr(V)), [U A; A' V] 0)
5463
cache_conic_form!(unique_conic_forms, x, p)
5564
end
5665
return get_conic_form(unique_conic_forms, x)

src/atoms/sdp_cone/sumlargesteigs.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#############################################################################
22
# sumlargesteigs.jl
3-
# Handles top k eigenvalues of a symmetric positive definite matrix
4-
# (and imposes the constraint that its argument be PSD)
3+
# Handles top k eigenvalues of a symmetric or Hermitian matrix
4+
# (and imposes the constraint that its argument be symmetric or Hermitian)
55
# All expressions and atoms are subtypes of AbstractExpr.
66
# Please read expressions.jl first.
77
#############################################################################
@@ -27,7 +27,7 @@ struct SumLargestEigs <: AbstractExpr
2727
end
2828

2929
function sign(x::SumLargestEigs)
30-
return Positive()
30+
return NoSign()
3131
end
3232

3333
function monotonicity(x::SumLargestEigs)
@@ -58,11 +58,17 @@ function conic_form!(x::SumLargestEigs, unique_conic_forms)
5858
A = x.children[1]
5959
k = x.children[2]
6060
m, n = size(A)
61-
Z = Variable(n, n)
61+
if sign(A) == ComplexSign()
62+
Z = ComplexVariable(n, n)
63+
else
64+
Z = Variable(n, n)
65+
end
6266
s = Variable()
63-
p = minimize(s*k + tr(Z),
67+
# The two inequality constraints have the side effect of constraining A to be symmetric,
68+
# since only symmetric matrices can be positive semidefinite.
69+
p = minimize(s*k + real(tr(Z)),
6470
Z + s*Matrix(1.0I, n, n) - A 0,
65-
A 0, Z 0)
71+
Z 0)
6672
cache_conic_form!(unique_conic_forms, x, p)
6773
end
6874
return get_conic_form(unique_conic_forms, x)

src/problem_depot/problems/sdp.jl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ end
8383
end
8484
end
8585

86+
@add_problem sdp function sdp_nuclear_norm_atom_complex(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test}
87+
A = [1 2im 3 4; 4im 3im 2 1; 4 5 6 7]
88+
y = ComplexVariable(3, 4)
89+
p = minimize(nuclearnorm(y), y == A; numeric_type = T)
90+
91+
if test
92+
@test vexity(p) == ConvexVexity()
93+
end
94+
handle_problem!(p)
95+
if test
96+
@test p.optval sum(svdvals(A)) atol=atol rtol=rtol
97+
@test evaluate(nuclearnorm(y)) sum(svdvals(A)) atol=atol rtol=rtol
98+
end
99+
end
100+
86101
@add_problem sdp function sdp_operator_norm_atom(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test}
87102
y = Variable((3,3))
88103
p = minimize(opnorm(y), y[2,1]<=4, y[2,2]>=3, sum(y)>=12; numeric_type = T)
@@ -97,6 +112,21 @@ end
97112
end
98113
end
99114

115+
@add_problem sdp function sdp_operator_norm_atom_complex(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test}
116+
A = [1 2im 3 4; 4im 3im 2 1; 4 5 6 7]
117+
y = ComplexVariable(3, 4)
118+
p = minimize(opnorm(y), y == A; numeric_type = T)
119+
120+
if test
121+
@test vexity(p) == ConvexVexity()
122+
end
123+
handle_problem!(p)
124+
if test
125+
@test p.optval maximum(svdvals(A)) atol=atol rtol=rtol
126+
@test evaluate(opnorm(y)) maximum(svdvals(A)) atol=atol rtol=rtol
127+
end
128+
end
129+
100130
@add_problem sdp function sdp_sigma_max_atom(handle_problem!, ::Val{test}, atol, rtol, ::Type{T}) where {T, test}
101131
y = Variable((3,3))
102132
p = minimize(sigmamax(y), y[2,1]<=4, y[2,2]>=3, sum(y)>=12; numeric_type = T)
@@ -199,6 +229,20 @@ end
199229
@test p.optval 8.4853 atol=atol rtol=rtol
200230
end
201231

232+
A = [1 -2im 3 4
233+
2im 7 3im 5
234+
3 -3im 2 9
235+
4 5 9 4]
236+
237+
x = ComplexVariable(4, 4)
238+
p = minimize(sumlargesteigs(x, 3), x == A; numeric_type = T)
239+
240+
handle_problem!(p)
241+
242+
if test
243+
@test p.optval sum(eigvals(A)[2:end]) atol=atol rtol=rtol
244+
end
245+
202246
x1 = Semidefinite(3)
203247
p1 = minimize(eigmax(x1), x1[1,1]>=4; numeric_type = T)
204248

0 commit comments

Comments
 (0)