# Can't get the example dualization to work

**URL:** <https://discourse.julialang.org/t/cant-get-the-example-dualization-to-work/129478>\
**Category:** Optimization (Mathematical)\
**Tags:** question\
**Created:** [May 30, 2025, 2:47pm UTC](https://discourse.julialang.org/t/cant-get-the-example-dualization-to-work/129478 "2025-05-30T14:47:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![brandon-lee-17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brandon-lee-17/32/217067_2.png) [@brandon-lee-17](https://discourse.julialang.org/u/brandon-lee-17)\
**Post date:** [May 30, 2025, 2:47pm UTC](https://discourse.julialang.org/t/cant-get-the-example-dualization-to-work/129478/1 "2025-05-30T14:47:25Z")

</div>

I can’t seem to get the first motivating example in Dualization.jl to work (at `https://jump.dev/Dualization.jl/dev/examples/`)

```julia
using JuMP, Dualization
model = Model()
@variable(model, x)
@variable(model, y)
@variable(model, z)
@constraint(model, soccon, [x; y; z] in SecondOrderCone())
@constraint(model, eqcon, x == 1)
@objective(model, Min, y + z)
dual_model = dualize(model)

```

yields

```julia
julia> print(model)
Min y + z
Subject to
 eqcon : x = 1
 soccon : [x, y, z] ∈ MathOptInterface.SecondOrderCone(3)

julia> print(dual_model)
Max _[1]
Subject to
 [-_[1], 1, 1] ∈ MathOptInterface.SecondOrderCone(3)

```

and in particular `dual_model` doesn’t recover all the constraints.

I’m on the following versions:

```julia
⌃ [191a621a] Dualization v0.5.9
⌃ [4076af6c] JuMP v1.25.0
⌃ [b8f27783] MathOptInterface v1.38.0

```

---

<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:** [June 1, 2025, 7:25am UTC](https://discourse.julialang.org/t/cant-get-the-example-dualization-to-work/129478/2 "2025-06-01T07:25:45Z")

</div>

Welcome to the forum. I believe the dual you get is correct.  
The dual of the standard form conic model:

```julia
min c'x
Ax = b
x in K

```

is

```julia
max b'y
c - A'y in K

```

In this case, `A = [1 0 0]`, `b = [1]`, `c = [0, 1, 1]` and `K = SecondOrderCone(3)`.  
Let me know if that clarifies things.  
It may be clearer to enable names:

```julia
julia> println(dualize(model, dual_names = DualNames()))
┌ Warning: dual names for constrained vector of variables not supported yet.
└ @ Dualization ~/.julia/dev/Dualization/src/dual_equality_constraints.jl:178
Max eqcon
Subject to
 [-eqcon, 1, 1] ∈ MathOptInterface.SecondOrderCone(3)

```

The warning is because we should set the name `soccon` to the SOC constraints of the dual but this is not implemented yet.

---

<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:** [June 1, 2025, 9:18pm UTC](https://discourse.julialang.org/t/cant-get-the-example-dualization-to-work/129478/3 "2025-06-01T21:18:49Z")

</div>

Hi @brandon-lee-17, welcome to the forum.

I guess your point is that the docs say

 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/1/41780942c20cc8cd9cba424b778ad5c37676860e.png)

but we have substituted `soccon` out of the formulation.

@blegat: is this intended behavior? If so, we should update the docs.

---

<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:** [June 2, 2025, 5:35am UTC](https://discourse.julialang.org/t/cant-get-the-example-dualization-to-work/129478/4 "2025-06-02T05:35:50Z")

</div>

Yes, the doc was written before we add constrained variables, we should update it

---

<div class="post-metadata">

**Author:** ![Mathis\_3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mathis_3/32/215843_2.png) [@Mathis\_3](https://discourse.julialang.org/u/Mathis_3)\
**Post date:** [November 3, 2025, 6:15pm UTC](https://discourse.julialang.org/t/cant-get-the-example-dualization-to-work/129478/5 "2025-11-03T18:15:43Z")

</div>

Hello !

I understand that this simplification of the dual is useful, but is there a way to disable it and keep the soccon variables in the example?

---

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [November 4, 2025, 7:07am UTC](https://discourse.julialang.org/t/cant-get-the-example-dualization-to-work/129478/6 "2025-11-04T07:07:27Z")

</div>

```julia-auto
 model = Model()
 @variable(model, x)
 @variable(model, y >= 0)
 @variable(model, z)
 @constraint(model, soccon, [1.0 * x + 2.0, y, z] in SecondOrderCone())
 @constraint(model, eqcon, x == 1)
 @constraint(model, con_le, x + y >= 1)
 @objective(model, Min, y + z)

```

The `soccon` here is strange.

I would write an aux line  
`@constraint(model, auxcon, aux_decision == 1.0x + 2)`  
`@constraint(model, [aux_decision, y, z] in SecondOrderCone()) # [*]`

As far as I can tell: in practice you _won’t_ need a dual variable for a SOC constraint like the `[*]` above. Having `auxcon`, `eqcon` and `con_le` should be sufficient.

Dual variables are used in, e.g. robust optimization ([doi.org/10.1287/opre.2018.1799](http://doi.org/10.1287/opre.2018.1799)).
