# How does Dualization.jl solve a SOS but not compute it?

**URL:** <https://discourse.julialang.org/t/how-does-dualization-jl-solve-a-sos-but-not-compute-it/119966>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [September 27, 2024, 2:05pm UTC](https://discourse.julialang.org/t/how-does-dualization-jl-solve-a-sos-but-not-compute-it/119966 "2024-09-27T14:05:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashefa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ashefa/32/2525_2.png) [@ashefa](https://discourse.julialang.org/u/ashefa)\
**Post date:** [September 27, 2024, 2:05pm UTC](https://discourse.julialang.org/t/how-does-dualization-jl-solve-a-sos-but-not-compute-it/119966/1 "2024-09-27T14:05:45Z")

</div>

Hi,

While solving a conic optimization problem, I needed to compute its dual, so I used Dualization.jl. However, it does not support the constraints modeled by SumOfSquares.jl, resulting in the following error:

`Constraints of the Function MathOptInterface.VectorAffineFunction{Float64} in the set SumOfSquares.SOSPolynomialSet{FullSpace, DynamicPolynomials.Monomial{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, Graded{LexOrder}}, MonomialVector{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, Graded{LexOrder}}, SumOfSquares.Certificate.Newton{CopositiveInner{SOSCone}, MonomialBasis, SumOfSquares.Certificate.NewtonFilter{SumOfSquares.Certificate.NewtonDegreeBounds{Tuple{}}}}} are not yet implemented.`

I am wondering how it can solve the dual problem nonetheless.

```julia
using JuMP, MosekTools, LinearAlgebra, SumOfSquares, DynamicPolynomials, Dualization

# Define the data for the optimization problems
Q = [0.0 0.0 0.0; 0.0 1.0 2.0; 0.0 2.0 3.0]
A = [0.0 0.5 0.5; 0.5 0.0 0.0; 0.5 0.0 0.0]
b = 2
n = size(Q, 1)

# Define the dual optimization problem
model_dual = Model(dual_optimizer(Mosek.Optimizer))

@variable(model_dual, v)
@variable(model_dual, Y[1:n, 1:n], Symmetric)

# Using CopositiveInner
@polyvar x[1:n]
@constraint(model_dual, sum(x[i] * Y[i, j] * x[j] for i in 1:n for j in 1:n) in CopositiveInner(SOSCone()))

@objective(model_dual, Max, v * b)

@constraint(model_dual, Q - v * A - Y .== 0)

# Optimize the dual model
optimize!(model_dual)
solution_summary(model_dual)
# dual_model = dualize(model_dual)

```

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [September 27, 2024, 8:50pm UTC](https://discourse.julialang.org/t/how-does-dualization-jl-solve-a-sos-but-not-compute-it/119966/2 "2024-09-27T20:50:26Z")

</div>

This is a question for @blegat. I assume we know how to take the dual of `CopositiveInner(SOSCone())` but not `SumOfSquares.SOSPolynomialSet`.

---

<div class="post-metadata">

**Author:** ![blegat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blegat/32/217090_2.png) [@blegat](https://discourse.julialang.org/u/blegat)\
**Post date:** [October 4, 2024, 6:24am UTC](https://discourse.julialang.org/t/how-does-dualization-jl-solve-a-sos-but-not-compute-it/119966/3 "2024-10-04T06:24:43Z")

</div>

The duals of the SOS cones are not implemented yet. You can `Dualization.dual_optimizer` though. This will work because `Dualization` knows that it doesn’t support the SOS cones so they will get bridged to the PSD cones before the dualization layer and the solver gets the dual form of the SDP. See [On the importance of Dualization · SumOfSquares](https://jump.dev/SumOfSquares.jl/dev/generated/Getting%20started/dualization/) for more details
