|
| 1 | +# Copyright (c) 2014: Madeleine Udell and contributors |
| 2 | +# Copyright (c) 2021: Hamza Fawzi |
| 3 | +# |
| 4 | +# Use of this source code is governed by an MIT-style license that can be found |
| 5 | +# in the LICENSE.md file or at https://opensource.org/licenses/MIT. |
| 6 | + |
| 7 | +""" |
| 8 | + GeometricMeanEpiConeSquare(t::Rational, side_dimension::Int) |
| 9 | +
|
| 10 | +The constraint `(T, A, B) in GeometricMeanEpiConeSquare(t, side_dimension)` |
| 11 | +constrains T to |
| 12 | +
|
| 13 | + A #_t B ⪯ T |
| 14 | +
|
| 15 | +where: |
| 16 | +
|
| 17 | + * A #_t B is the t-weighted geometric mean of A and B: |
| 18 | + A^{1/2} (A^{-1/2} B A^{-1/2})^t A^{1/2} |
| 19 | + * Parameter t must be in [-1, 0] or [1, 2]. |
| 20 | + * Constraints A ⪰ 0, B ⪰ 0 are added. |
| 21 | +
|
| 22 | +## Reference |
| 23 | +
|
| 24 | +Ported from CVXQUAD which is based on the paper: "Lieb's concavity theorem, |
| 25 | +matrix geometric means and semidefinite optimization" by Hamza Fawzi and James |
| 26 | +Saunderson (arXiv:1512.03401) |
| 27 | +""" |
| 28 | +struct GeometricMeanEpiConeSquare <: MOI.AbstractVectorSet |
| 29 | + t::Rational |
| 30 | + side_dimension::Int |
| 31 | + |
| 32 | + function GeometricMeanEpiConeSquare(t::Rational, side_dimension::Int) |
| 33 | + if !(-1 <= t <= 0 || 1 <= t <= 2) |
| 34 | + throw(DomainError(t, "t must be in the range [-1, 0] or [1, 2]")) |
| 35 | + end |
| 36 | + return new(t, side_dimension) |
| 37 | + end |
| 38 | +end |
| 39 | + |
| 40 | +MOI.dimension(set::GeometricMeanEpiConeSquare) = 3 * set.side_dimension^2 |
| 41 | + |
| 42 | +function head(io::IO, ::GeometricMeanEpiConeSquare) |
| 43 | + return print(io, "GeometricMeanEpiConeSquare") |
| 44 | +end |
| 45 | + |
| 46 | +function GenericConstraint(func::Tuple, set::GeometricMeanEpiConeSquare) |
| 47 | + for f in func |
| 48 | + n = LinearAlgebra.checksquare(f) |
| 49 | + if n != set.side_dimension |
| 50 | + throw( |
| 51 | + DimensionMismatch( |
| 52 | + "Matrix of side dimension `$n` does not match set of side dimension `$(set.side_dimension)`", |
| 53 | + ), |
| 54 | + ) |
| 55 | + end |
| 56 | + end |
| 57 | + return GenericConstraint(vcat(vec.(func)...), set) |
| 58 | +end |
| 59 | + |
| 60 | +function _get_matrices(c::GenericConstraint{GeometricMeanEpiConeSquare}) |
| 61 | + n = c.set.side_dimension |
| 62 | + d = n^2 |
| 63 | + T = reshape(c.child[1:d], n, n) |
| 64 | + A = reshape(c.child[d.+(1:d)], n, n) |
| 65 | + B = reshape(c.child[2d.+(1:d)], n, n) |
| 66 | + return T, A, B |
| 67 | +end |
| 68 | + |
| 69 | +# For t ∈ [-1, 0] ∪ [1, 2] the t-weighted matrix geometric mean is matrix convex |
| 70 | +# (arxiv:1512.03401). |
| 71 | +# So if A and B are convex sets, then T ⪰ A #_t B will be a convex set. |
| 72 | +function vexity(constraint::GenericConstraint{GeometricMeanEpiConeSquare}) |
| 73 | + T, A, B = _get_matrices(constraint) |
| 74 | + if vexity(A) in (ConcaveVexity(), NotDcp()) || |
| 75 | + vexity(B) in (ConcaveVexity(), NotDcp()) |
| 76 | + return NotDcp() |
| 77 | + end |
| 78 | + return ConvexVexity() + -vexity(T) |
| 79 | +end |
| 80 | + |
| 81 | +function _add_constraint!( |
| 82 | + context::Context, |
| 83 | + constraint::GenericConstraint{GeometricMeanEpiConeSquare}, |
| 84 | +) |
| 85 | + T, A, B = _get_matrices(constraint) |
| 86 | + t = constraint.set.t |
| 87 | + Z = if sign(constraint.child) == ComplexSign() |
| 88 | + HermitianSemidefinite(size(A, 1)) |
| 89 | + else |
| 90 | + Semidefinite(size(A, 1)) |
| 91 | + end |
| 92 | + if t <= 0 |
| 93 | + add_constraint!(context, [T A; A Z] ⪰ 0) |
| 94 | + add_constraint!(context, Z in GeomMeanHypoCone(A, B, -t, false)) |
| 95 | + else |
| 96 | + # range of t checked in GeometricMeanEpiConeSquare constructor. |
| 97 | + @assert t >= 1 |
| 98 | + add_constraint!(context, [T B; B Z] ⪰ 0) |
| 99 | + add_constraint!(context, Z in GeomMeanHypoCone(A, B, 2 - t, false)) |
| 100 | + end |
| 101 | + return |
| 102 | +end |
0 commit comments