JuliaOpt / CoinOptServices.jl

Julia interface to COIN-OR Optimization Services https://projects.coin-or.org/OS
Other
16 stars 4 forks source link

SOS constraints for Bonmin? #33

Open michaellindon opened 7 years ago

michaellindon commented 7 years ago

Please see this thread:

https://discourse.julialang.org/t/sos1-constraints-in-bonmin-solver-jump-amplnlwriter/5450

SOS constraints should be allowed with Bonmins branch and bound algorithm.

When I try to implement the following model:


using CoinOptServices
m = Model(solver=OsilBonminSolver())
@variable(m, B[1:p])
@variable(m, G[1:p], Bin)
@variable(m, Z[1:p], Bin)
for i=1:p
    addSOS1(m, [B[i],Z[i]])
end
@constraint(m, Z .== 1 .-G )
@constraint(m, sum(G[j] for j=1:p) <= 3)
@NLobjective(m, Min, sum((Y[i]-sum( X[i,j]*B[j] for j=1:p))^2 for i=1:n))

solve(m)

I get the following error


julia> solve(m)
ERROR: Not implemented for SOS constraints
Stacktrace:
 [1] constraintbounds(::JuMP.Model, ::JuMP.ProblemTraits) at /home/michael/.julia/v0.6/JuMP/src/solvers.jl:1033
 [2] _buildInternalModel_nlp(::JuMP.Model, ::JuMP.ProblemTraits) at /home/michael/.julia/v0.6/JuMP/src/nlp.jl:1243
 [3] #build#119(::Bool, ::Bool, ::JuMP.ProblemTraits, ::Function, ::JuMP.Model) at /home/michael/.julia/v0.6/JuMP/src/solvers.jl:303
 [4] (::JuMP.#kw##build)(::Array{Any,1}, ::JuMP.#build, ::JuMP.Model) at ./<missing>:0
 [5] #solve#116(::Bool, ::Bool, ::Bool, ::Array{Any,1}, ::Function, ::JuMP.Model) at /home/michael/.julia/v0.6/JuMP/src/solvers.jl:168
 [6] solve(::JuMP.Model) at /home/michael/.julia/v0.6/JuMP/src/solvers.jl:150
 [7] macro expansion at ./REPL.jl:97 [inlined]
 [8] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
tkelman commented 7 years ago

Are sos constraints included in the osil spec? I can't remember if I tried connecting them here. Maybe try hand writing a trivial tiny problem with sos constraints in osil format and see if it can work through OSSolverService?