# SOS1 variables are not supported

**URL:** <https://discourse.julialang.org/t/sos1-variables-are-not-supported/22012>\
**Category:** Optimization (Mathematical)\
**Created:** [March 18, 2019, 10:22pm UTC](https://discourse.julialang.org/t/sos1-variables-are-not-supported/22012 "2019-03-18T22:22:50Z")\
**Posts on this page:** 6\
**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:** [March 18, 2019, 10:22pm UTC](https://discourse.julialang.org/t/sos1-variables-are-not-supported/22012/1 "2019-03-18T22:22:50Z")

</div>

I’m trying to build a SOS1 constraint using JuMP MOI (with Gurobi, CPLEX, Mosek).

```julia
m = Model(with_optimizer(Mosek.Optimizer))
@variable(m, x[1:3])
@constraint(m, x in MOI.SOS1([1, 2, 3]))

```

But it gives me an error saying:

```julia
ERROR: LoadError: Constraints of type MathOptInterface.VectorOfVariables-in-MathOptInterface.SOS1{Int64} are not supported by the solver and there are no bridges that can reformulate it into supported constraints.
Stacktrace:
 [1] moi_add_constraint(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}}, ::MathOptInterface.VectorOfVariables, ::MathOptInterface.SOS1{Int64}) at /Users/jipkim/.julia/packages/JuMP/jnmGG/src/constraints.jl:371
 [2] add_constraint(::Model, ::VectorConstraint{VariableRef,MathOptInterface.SOS1{Int64},VectorShape}, ::String) at /Users/jipkim/.julia/packages/JuMP/jnmGG/src/constraints.jl:385
 [3] top-level scope at /Users/jipkim/.julia/packages/JuMP/jnmGG/src/macros.jl:621
in expression starting at /Users/jipkim/Dropbox/Julia/Bilevel/SOStest.jl:7

```

Can anybody point me out how to handle this?

---

<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 19, 2019, 1:03am UTC](https://discourse.julialang.org/t/sos1-variables-are-not-supported/22012/2 "2019-03-19T01:03:52Z")

</div>

It doesn’t look like Mosek.jl supports SOS1 constraints. However Gurobi and CPLEX should. The issue is probably the `SOS1{Int64}`. Does `x in MOI.SOS1([1.0, 2.0, 3.0])` work?

If so, JuMP should probably promote SOS sets to `Float64`.

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [March 19, 2019, 1:07am UTC](https://discourse.julialang.org/t/sos1-variables-are-not-supported/22012/3 "2019-03-19T01:07:55Z")

</div>

> [@odow](#):
>
> If so, JuMP should probably promote SOS sets to `Float64` .

Agree. I’ve run into this as well with `MOI.SOS1(1 : 3)`, which additionally has the issue that `1 : 3` is a `UnitRange` instead of a `Vector`. Probably better to handle it centrally than to require all of the solver interfaces to widen their type signatures.

---

<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 19, 2019, 1:18am UTC](https://discourse.julialang.org/t/sos1-variables-are-not-supported/22012/4 "2019-03-19T01:18:35Z")

</div>

I’ve opened an issue: [Promote eltype of MOI sets like SOS to Float64 · Issue #1911 · jump-dev/JuMP.jl · GitHub](https://github.com/JuliaOpt/JuMP.jl/issues/1911)

---

<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:** [March 21, 2019, 9:31pm UTC](https://discourse.julialang.org/t/sos1-variables-are-not-supported/22012/5 "2019-03-21T21:31:02Z")

</div>

Hi Oscar,

Thank you for the response and opening an issue for this.  
Can it be allowed to define SOS variables without a weight (ordering) vector? So that below two constraints (con1 & con2) represent the same thing?

```julia
@variable(m, x[1:3])
@constraint(m, con1, x in MOI.SOS1([1.0, 2.0, 3.0]))
@constraint(m, con2, x in MOI.SOS1())

```

In the case of SOS1 variables, ordering is less critical than SOS2 and an automatic ordering would be more convenient.

---

<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 21, 2019, 9:40pm UTC](https://discourse.julialang.org/t/sos1-variables-are-not-supported/22012/6 "2019-03-21T21:40:06Z")

</div>

This seems like a reasonable thing to open a feature request for: [Sign in to GitHub · GitHub](https://github.com/JuliaOpt/JuMP.jl/issues/new/choose)
