# Set MathOptInterface.SecondOrderCone is not accepted when solution method is BilevelJuMP.SOS1Mode{Float64}

**URL:** <https://discourse.julialang.org/t/set-mathoptinterface-secondordercone-is-not-accepted-when-solution-method-is-bileveljump-sos1mode-float64/77737>\
**Category:** Optimization (Mathematical)\
**Tags:** question, package\
**Created:** [March 11, 2022, 6:10am UTC](https://discourse.julialang.org/t/set-mathoptinterface-secondordercone-is-not-accepted-when-solution-method-is-bileveljump-sos1mode-float64/77737 "2022-03-11T06:10:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zlq178](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zlq178/32/17952_2.png) [@zlq178](https://discourse.julialang.org/u/zlq178)\
**Post date:** [March 11, 2022, 6:10am UTC](https://discourse.julialang.org/t/set-mathoptinterface-secondordercone-is-not-accepted-when-solution-method-is-bileveljump-sos1mode-float64/77737/1 "2022-03-11T06:10:37Z")

</div>

Here is an example:

```julia
using JuMP, BilevelJuMP, Gurobi
model=BilevelModel(Gurobi.Optimizer)
set_optimizer_attribute(model,"NonConvex",2)
@variable(Lower(model), x)
@variable(Upper(model), y)

@objective(Upper(model), Min, 3x + y)
@constraints(Upper(model), begin
    x <= 5
    y <= 8
    y >= 0
end)

@objective(Lower(model), Min, -x)
@constraint(Lower(model), x + y <= 8)

@constraint(Lower(model), [1; [x;y]] in SecondOrderCone())  

optimize!(model)

```

I want to add the SOCP constraint in BilevelJuMP.  
But after running the code, the error shows Set MathOptInterface.SecondOrderCone is not accepted when solution method is BilevelJuMP.SOS1Mode{Float64}  
Stacktrace:  
[1] error(::String) at .\error.jl:33  
[2] accept\_vector\_set at C:\Users\zlq.julia\packages\BilevelJuMP\wSyR2\src\moi.jl:214 [inlined]  
[3] build\_bilevel(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64,MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}}, ::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64,MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}}, ::Dict{MathOptInterface.VariableIndex,MathOptInterface.VariableIndex}, ::Array{MathOptInterface.VariableIndex,1}, ::BilevelJuMP.SOS1Mode{Float64}, ::Dict{MathOptInterface.VariableIndex,MathOptInterface.ConstraintIndex}; copy\_names::Bool, pass\_start::Bool) at C:\Users\zlq.julia\packages\BilevelJuMP\wSyR2\src\moi.jl:381  
[4] optimize!(::BilevelModel; lower\_prob::String, upper\_prob::String, bilevel\_prob::String, solver\_prob::String, file\_format::MathOptInterface.FileFormats.FileFormat) at C:\Users\zlq.julia\packages\BilevelJuMP\wSyR2\src\jump.jl:394  
[5] optimize!(::BilevelModel) at C:\Users\zlq.julia\packages\BilevelJuMP\wSyR2\src\jump.jl:354  
[6] top-level scope at untitled-7bc4389150e9b12048a3abbe3ef0022f:18  
[7] include\_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1088  
in expression starting at untitled-7bc4389150e9b12048a3abbe3ef0022f:18

Can’t model the SecondOrderCone problem in BilevelJuMP?

---

<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:** [March 12, 2022, 9:22pm UTC](https://discourse.julialang.org/t/set-mathoptinterface-secondordercone-is-not-accepted-when-solution-method-is-bileveljump-sos1mode-float64/77737/2 "2022-03-12T21:22:11Z")

</div>

cc @joaquimg

---

<div class="post-metadata">

**Author:** ![joaquimg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joaquimg/32/223_2.png) [@joaquimg](https://discourse.julialang.org/u/joaquimg)\
**Post date:** [March 12, 2022, 10:33pm UTC](https://discourse.julialang.org/t/set-mathoptinterface-secondordercone-is-not-accepted-when-solution-method-is-bileveljump-sos1mode-float64/77737/3 "2022-03-12T22:33:49Z")

</div>

Hey,

As described in the last section of the README.md: [https://github.com/joaquimg/BilevelJuMP.jl#conic-lower-level](https://github.com/joaquimg/BilevelJuMP.jl#conic-lower-level)  
It can model second order cone problem, but they are way more challenging.  
First thing you need is to force the BilevelJuMP `mode` to `BilevelJuMP.ProductMode` as in:

```julia
model=BilevelModel(Gurobi.Optimizer, mode = BilevelJuMP.ProductMode(1e-5))

```

---

<div class="post-metadata">

**Author:** ![zlq178](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zlq178/32/17952_2.png) [@zlq178](https://discourse.julialang.org/u/zlq178)\
**Post date:** [March 13, 2022, 12:45am UTC](https://discourse.julialang.org/t/set-mathoptinterface-secondordercone-is-not-accepted-when-solution-method-is-bileveljump-sos1mode-float64/77737/4 "2022-03-13T00:45:12Z")

</div>

> [@joaquimg](#):
>
> `model=BilevelModel(Gurobi.Optimizer, mode = BilevelJuMP.ProductMode(1e-5))`

It works! Thanks!
