jump-dev / Convex.jl

A Julia package for disciplined convex programming
https://jump.dev/Convex.jl/stable/
Other
567 stars 121 forks source link

`sumsquares` makes both a SOC and RSOC constraint #677

Closed ericphanson closed 4 months ago

ericphanson commented 4 months ago

I believe this could be a single RSOC constraint instead, but we would need to add an atom for it. I'm not sure how much this matters in practice.

julia> using Convex

julia> using Convex: MOI

julia> problem = minimize(sumsquares(Variable(2)));

julia> context = Convex.Context(problem, MOI.Utilities.Model{Float64});

julia> print(context.model)
Minimize ScalarAffineFunction{Float64}:
 0.0 + 1.0 v[1]

Subject to:

VectorAffineFunction{Float64}-in-SecondOrderCone
 ┌              ┐
 │0.0 + 1.0 v[2]│
 │0.0 + 1.0 v[3]│
 │0.0 + 1.0 v[4]│
 └              ┘ ∈ SecondOrderCone(3)

VectorAffineFunction{Float64}-in-RotatedSecondOrderCone
 ┌              ┐
 │0.0 + 1.0 v[1]│
 │0.5           │
 │0.0 + 1.0 v[2]│
 └              ┘ ∈ RotatedSecondOrderCone(3)

(This is since sumsquares is implemented by squaring norm, so we first create the SOC for the norm, then the RSOC for the result of norm.)