|
| 1 | +############################################################################# |
| 2 | +# geom_mean_epicone.jl |
| 3 | +# Constrains T to |
| 4 | +# A #_t B ⪯ T |
| 5 | +# where: |
| 6 | +# * A #_t B is the t-weighted geometric mean of A and B: |
| 7 | +# A^{1/2} (A^{-1/2} B A^{-1/2})^t A^{1/2} |
| 8 | +# Parameter t should be in [-1, 0] or [1, 2]. |
| 9 | +# * Constraints A ⪰ 0, B ⪰ 0 are added. |
| 10 | +# All expressions and atoms are subtypes of AbstractExpr. |
| 11 | +# Please read expressions.jl first. |
| 12 | +# |
| 13 | +# Note on fullhyp: GeomMeanEpiCone will always return a full epigraph cone |
| 14 | +# (unlike GeomMeanHypoCone) and so this parameter is not really used. It is |
| 15 | +# here just for consistency with the GeomMeanHypoCone function. |
| 16 | +# |
| 17 | +#REFERENCE |
| 18 | +# Ported from CVXQUAD which is based on the paper: "Lieb's concavity |
| 19 | +# theorem, matrix geometric means and semidefinite optimization" by Hamza |
| 20 | +# Fawzi and James Saunderson (arXiv:1512.03401) |
| 21 | +############################################################################# |
| 22 | + |
| 23 | +struct GeomMeanEpiCone |
| 24 | + A::AbstractExpr |
| 25 | + B::AbstractExpr |
| 26 | + t::Rational |
| 27 | + size::Tuple{Int, Int} |
| 28 | + |
| 29 | + function GeomMeanEpiCone(A::AbstractExpr, B::AbstractExpr, t::Rational, fullhyp::Bool=true) |
| 30 | + if size(A) != size(B) |
| 31 | + throw(DimensionMismatch("A and B must be the same size")) |
| 32 | + end |
| 33 | + n = size(A)[1] |
| 34 | + if size(A) != (n, n) |
| 35 | + throw(DimensionMismatch("A and B must be square")) |
| 36 | + end |
| 37 | + if t < -1 || (t > 0 && t < 1) || t > 2 |
| 38 | + throw(DomainError(t, "t must be in the range [-1, 0] or [1, 2]")) |
| 39 | + end |
| 40 | + return new(A, B, t, (n, n)) |
| 41 | + end |
| 42 | + |
| 43 | + GeomMeanEpiCone(A::Value, B::AbstractExpr, t::Rational, fullhyp::Bool=true) = GeomMeanEpiCone(Constant(A), B, t, fullhyp) |
| 44 | + GeomMeanEpiCone(A::AbstractExpr, B::Value, t::Rational, fullhyp::Bool=true) = GeomMeanEpiCone(A, Constant(B), t, fullhyp) |
| 45 | + GeomMeanEpiCone(A::Value, B::Value, t::Rational, fullhyp::Bool=true) = GeomMeanEpiCone(Constant(A), Constant(B), t, fullhyp) |
| 46 | + |
| 47 | + GeomMeanEpiCone(A::AbstractExprOrValue, B::AbstractExprOrValue, t::Integer, fullhyp::Bool=true) = GeomMeanEpiCone(A, B, t//1, fullhyp) |
| 48 | +end |
| 49 | + |
| 50 | +struct GeomMeanEpiConeConstraint <: Constraint |
| 51 | + head::Symbol |
| 52 | + id_hash::UInt64 |
| 53 | + T::AbstractExpr |
| 54 | + cone::GeomMeanEpiCone |
| 55 | + |
| 56 | + function GeomMeanEpiConeConstraint(T::AbstractExpr, cone::GeomMeanEpiCone) |
| 57 | + if size(T) != cone.size |
| 58 | + throw(DimensionMismatch("T must be size $(cone.size)")) |
| 59 | + end |
| 60 | + id_hash = hash((cone.A, cone.B, cone.t, :GeomMeanEpiCone)) |
| 61 | + return new(:GeomMeanEpiCone, id_hash, T, cone) |
| 62 | + end |
| 63 | + |
| 64 | + GeomMeanEpiConeConstraint(T::Value, cone::GeomMeanEpiCone) = GeomMeanEpiConeConstraint(Constant(T), cone) |
| 65 | +end |
| 66 | + |
| 67 | +in(T, cone::GeomMeanEpiCone) = GeomMeanEpiConeConstraint(T, cone) |
| 68 | + |
| 69 | +function AbstractTrees.children(constraint::GeomMeanEpiConeConstraint) |
| 70 | + return (constraint.T, constraint.cone.A, constraint.cone.B, "t=$(constraint.cone.t)") |
| 71 | +end |
| 72 | + |
| 73 | +# For t ∈ [-1, 0] ∪ [1, 2] the t-weighted matrix geometric mean is matrix convex (arxiv:1512.03401). |
| 74 | +# So if A and B are convex sets, then T ⪰ A #_t B will be a convex set. |
| 75 | +function vexity(constraint::GeomMeanEpiConeConstraint) |
| 76 | + A = vexity(constraint.cone.A) |
| 77 | + B = vexity(constraint.cone.B) |
| 78 | + T = vexity(constraint.T) |
| 79 | + |
| 80 | + # NOTE: can't say A == NotDcp() because the NotDcp constructor prints a warning message. |
| 81 | + if typeof(A) == ConcaveVexity || typeof(A) == NotDcp |
| 82 | + return NotDcp() |
| 83 | + end |
| 84 | + if typeof(B) == ConcaveVexity || typeof(B) == NotDcp |
| 85 | + return NotDcp() |
| 86 | + end |
| 87 | + # Copied from vexity(c::GtConstraint) |
| 88 | + vex = ConvexVexity() + (-T) |
| 89 | + if vex == ConcaveVexity() |
| 90 | + vex = NotDcp() |
| 91 | + end |
| 92 | + return vex |
| 93 | +end |
| 94 | + |
| 95 | +function conic_form!(constraint::GeomMeanEpiConeConstraint, unique_conic_forms::UniqueConicForms) |
| 96 | + if !has_conic_form(unique_conic_forms, constraint) |
| 97 | + A = constraint.cone.A |
| 98 | + B = constraint.cone.B |
| 99 | + t = constraint.cone.t |
| 100 | + T = constraint.T |
| 101 | + is_complex = sign(A) == ComplexSign() || sign(B) == ComplexSign() || sign(T) == ComplexSign() |
| 102 | + if is_complex |
| 103 | + make_temporary = () -> HermitianSemidefinite(size(A)[1]) |
| 104 | + else |
| 105 | + make_temporary = () -> Semidefinite(size(A)[1]) |
| 106 | + end |
| 107 | + |
| 108 | + Z = make_temporary() |
| 109 | + |
| 110 | + if t <= 0 |
| 111 | + conic_form!([T A; A Z] ⪰ 0, unique_conic_forms) |
| 112 | + conic_form!(Z in GeomMeanHypoCone(A, B, -t, false), unique_conic_forms) |
| 113 | + else |
| 114 | + @assert t >= 1 # range of t checked in GeomMeanEpiCone constructor |
| 115 | + conic_form!([T B; B Z] ⪰ 0, unique_conic_forms) |
| 116 | + conic_form!(Z in GeomMeanHypoCone(A, B, 2-t, false), unique_conic_forms) |
| 117 | + end |
| 118 | + |
| 119 | + cache_conic_form!(unique_conic_forms, constraint, Array{Convex.ConicConstr,1}()) |
| 120 | + end |
| 121 | + return get_conic_form(unique_conic_forms, constraint) |
| 122 | +end |
0 commit comments