# Mosek w/ multiple bound SecondOrderCones

**URL:** https://discourse.julialang.org/t/mosek-w-multiple-bound-secondordercones/22777
**Category:** Optimization (Mathematical)
**Created:** [April 4, 2019, 11:19pm UTC](https://discourse.julialang.org/t/mosek-w-multiple-bound-secondordercones/22777 "2019-04-04T23:19:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![SingingKim](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@SingingKim](https://discourse.julialang.org/u/SingingKim)
#### Post date: [April 4, 2019, 11:19pm UTC](https://discourse.julialang.org/t/mosek-w-multiple-bound-secondordercones/22777/1 "2019-04-04T23:19:46Z")

</div>

Good evening!

I have ‘multiple bound set’ issue regarding SecondOrderCone constraints with Mosek.  
(JuMP 0.19 / Mosek v8.1.0.80 )

```julia
using JuMP, Mosek, MosekTools, SCS
m = Model(with_optimizer(Mosek.Optimizer))
@variables(m, begin
   x >= 1
   y <= 2
   z <= 3
end)
@objective(m, Max, x)
@constraint(m, [y, x] in SecondOrderCone())
@constraint(m, [z, x] in SecondOrderCone())
optimize!(m)

```

SCS solves the same problem successfully without any issue.

```julia
m = Model(with_optimizer(SCS.Optimizer))

```

I’d like to know if Mosek does not accept multiple bound sets or this is related to the Mosek wrapper.

Thanks!

```julia
ERROR: LoadError: Cannot multiple bound sets of the same type to a variable
Stacktrace:
 [1] add_constraint(::MosekModel, ::MathOptInterface.VectorOfVariables, ::MathOptInterface.SecondOrderCone) at /Users/jipkim/.julia/packages/MosekTools/GeypE/src/constraint.jl:391
 [2] _broadcast_getindex_evalf at ./broadcast.jl:578 [inlined]
 [3] _broadcast_getindex at ./broadcast.jl:551 [inlined]
 [4] getindex at ./broadcast.jl:511 [inlined]
 [5] macro expansion at ./broadcast.jl:843 [inlined]
 [6] macro expansion at ./simdloop.jl:73 [inlined]
 [7] copyto! at ./broadcast.jl:842 [inlined]
 [8] copyto! at ./broadcast.jl:797 [inlined]
 [9] copy at ./broadcast.jl:773 [inlined]
 [10] materialize at ./broadcast.jl:753 [inlined]
 [11] add_constraints(::MosekModel, ::Array{MathOptInterface.VectorOfVariables,1}, ::Array{MathOptInterface.SecondOrderCone,1}) at /Users/jipkim/.julia/packages/MathOptInterface/C3lip/src/constraints.jl:139
 [12] add_constraints at /Users/jipkim/.julia/packages/MathOptInterface/C3lip/src/Bridges/bridgeoptimizer.jl:342 [inlined]
 [13] copyconstraints!(::MathOptInterface.Bridges.LazyBridgeOptimizer{MosekModel,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Type{MathOptInterface.VectorOfVariables}, ::Type{MathOptInterface.SecondOrderCone}) at /Users/jipkim/.julia/packages/MathOptInterface/C3lip/src/Utilities/copy.jl:157
 [14] default_copy_to(::MathOptInterface.Bridges.LazyBridgeOptimizer{MosekModel,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}, ::Bool) at /Users/jipkim/.julia/packages/MathOptInterface/C3lip/src/Utilities/copy.jl:200
 [15] #automatic_copy_to#61 at /Users/jipkim/.julia/packages/MathOptInterface/C3lip/src/Utilities/copy.jl:15 [inlined]
 [16] #automatic_copy_to at ./none:0 [inlined]
 [17] #copy_to#1 at /Users/jipkim/.julia/packages/MathOptInterface/C3lip/src/Bridges/bridgeoptimizer.jl:91 [inlined]
 [18] (::getfield(MathOptInterface, Symbol("#kw##copy_to")))(::NamedTuple{(:copy_names,),Tuple{Bool}}, ::typeof(MathOptInterface.copy_to), ::MathOptInterface.Bridges.LazyBridgeOptimizer{MosekModel,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}) at ./none:0
 [19] attach_optimizer(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}}) at /Users/jipkim/.julia/packages/MathOptInterface/C3lip/src/Utilities/cachingoptimizer.jl:130
 [20] optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}}) at /Users/jipkim/.julia/packages/MathOptInterface/C3lip/src/Utilities/cachingoptimizer.jl:166
 [21] #optimize!#77(::Bool, ::Bool, ::Function, ::Model, ::Nothing) at /Users/jipkim/.julia/packages/JuMP/jnmGG/src/optimizer_interface.jl:132
 [22] optimize! at /Users/jipkim/.julia/packages/JuMP/jnmGG/src/optimizer_interface.jl:105 [inlined] (repeats 2 times)
 [23] top-level scope at none:0

```

---

<div class="post-metadata">

### Author: ![leethargo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leethargo/32/6004_2.png) [@leethargo](https://discourse.julialang.org/u/leethargo)
#### Post date: [April 5, 2019, 6:42am UTC](https://discourse.julialang.org/t/mosek-w-multiple-bound-secondordercones/22777/2 "2019-04-05T06:42:25Z")

</div>

I don’t know about Mosek here, but SCIP would fail with an error, because it requires nonnegative lower bounds for `y` and `z`. Maybe Mosek is adding these bound constraints implictly, resulting in the error you posted.

Did you try

```julia
@variables(m, begin
   x >= 1
   0 <= y <= 2
   0 <= z <= 3
end)@variables(m, begin
   x >= 1
   y <= 2
   z <= 3
end)

```

---

<div class="post-metadata">

### Author: ![leethargo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leethargo/32/6004_2.png) [@leethargo](https://discourse.julialang.org/u/leethargo)
#### Post date: [April 5, 2019, 10:02am UTC](https://discourse.julialang.org/t/mosek-w-multiple-bound-secondordercones/22777/3 "2019-04-05T10:02:04Z")

</div>

Maybe this issue is relevant: [Disable add\_constraints tests for VectorOfVariables by blegat · Pull Request #703 · jump-dev/MathOptInterface.jl · GitHub](https://github.com/JuliaOpt/MathOptInterface.jl/pull/703)  
Apparently Mosek does not support having the same variable belong to multiple cones.

---

<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: [April 5, 2019, 10:23am UTC](https://discourse.julialang.org/t/mosek-w-multiple-bound-secondordercones/22777/4 "2019-04-05T10:23:24Z")

</div>

It is not an issue with the wrapper, the variables of a conic solver belong to a cartesian product of cones so the cones cannot overlap. For SCS, it works because the problem is written in the dual form where the variables are free and affine expressions belongs to a cartesian product of cones so the VectorOfVariables-in-SecondOrderCone is transformed by the VectorFunctionizeBridge into VectorAffineFunction-in-SecondOrderCone.  
If you manualy convert one of the constraint to VectorAffineFunction, e.g. by writing `1x` instead of `x`, the problem written to SCS will be the same and it will work with Mosek
