jump-dev / Pavito.jl

A gradient-based outer approximation solver for convex mixed-integer nonlinear programming (MINLP)
Other
60 stars 10 forks source link

Can Pavito support RSOCP constraints? #38

Closed pqrz closed 3 years ago

pqrz commented 3 years ago

Hi Team,

I was trying to run a RSOCP problem with Pavito, but it seems Pavito doesn't support RSOCP constraints?

Minimum reproducible example:

using JuMP, LinearAlgebra, Cbc, Ipopt, Pavito
u0 = [3,5]
m = Model(optimizer_with_attributes(Pavito.Optimizer, "cont_solver"=>Ipopt.Optimizer, "mip_solver"=>Cbc.Optimizer))
@variable(m, x[1:2])
@objective(m, Min, dot(u0,x))
@constraint(m, [1, 5, x[1], x[2]] in RotatedSecondOrderCone())
optimize!(m)

If possible, kindly suggest a resolution for same.

blegat commented 3 years ago

Can you try adding the RSOCtoNonConvexQuadBridge bridge:

add_bridge(model, MOI.Bridges.Constraint.RSOCtoNonConvexQuadBridge)
pqrz commented 3 years ago

Hi @blegat,

Haha, was expecting this. So, I had indeed try adding this, specifically:

After this line: https://github.com/jump-dev/Pavito.jl/blob/1ebd714cae8f0b60f3fdb6a6e7876d654a7770da/src/MOI_wrapper.jl#L127 added this:

127    . 
128    MOI.Bridges.add_bridge(optimizer, MOI.Bridges.Constraint.SOCtoNonConvexQuadBridge{Float64})
129    MOI.Bridges.add_bridge(optimizer, MOI.Bridges.Constraint.RSOCtoNonConvexQuadBridge{Float64})
130    . 

but no success!

blegat commented 3 years ago

This time, it's Pavito itself that needs the bridge as it only support linear, quadratic and nonlinear constraints, not conic ones. So model is the JuMP model itself in the line of my previous message.

pqrz commented 3 years ago

Perfect! Works successfully now.

Thanks a lot, you are the best of the best!

pqrz commented 3 years ago

Just, for the record, this is the final code:

using JuMP, LinearAlgebra, Cbc, Ipopt, Pavito, MathOptInterface
MOI = MathOptInterface
u0 = [3,5]
m = Model(optimizer_with_attributes(Pavito.Optimizer, "cont_solver"=>Ipopt.Optimizer, "mip_solver"=>Cbc.Optimizer))
add_bridge(m, MOI.Bridges.Constraint.SOCtoNonConvexQuadBridge)
add_bridge(m, MOI.Bridges.Constraint.RSOCtoNonConvexQuadBridge)
@variable(m, x[1:2], Int)
@objective(m, Min, dot(u0,x))
@constraint(m, [1, 5, x[1], x[2]] in RotatedSecondOrderCone())
optimize!(m)