-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for quadratic constraints #92
Conversation
Codecov Report
@@ Coverage Diff @@
## master #92 +/- ##
=======================================
Coverage 98.26% 98.26%
=======================================
Files 9 9
Lines 635 635
=======================================
Hits 624 624
Misses 11 11
Continue to review full report at Codecov.
|
1090df6
to
6947bcb
Compare
6947bcb
to
bebb2b1
Compare
@rdeits, there are no free solvers with an MOI interface that supports quadratic constraints, is there? |
c44a887
to
7b7fa2d
Compare
Not that I'm aware of. SCS.jl supports conic constraints, but not quadratic ones, as far as I can tell. |
7b7fa2d
to
3178b58
Compare
OK, thanks. |
SCS supports quadratic constraints through the QuadtoSOC bridgz but the bridge does not support modification yet |
OK, great. I'll give that a shot. |
@blegat, I first tried optimizer = MOIB.QuadtoSOC{Float64}(SCS.Optimizer(verbose=0)) but that resulted in ERROR: MathOptInterface.AddVariableNotAllowed: Adding variables cannot be performed. You may want to use a `CachingOptimizer` in `Automatic` mode or you may need to call `resetoptimizer!` before doing this operation if the `CachingOptimizer` is in `Manual` mode.
Stacktrace:
[1] add_variable(::SCS.Optimizer) at /home/twan/.julia/packages/MathOptInterface/zxv73/src/variables.jl:35
[2] add_variable(::MathOptInterface.Bridges.SingleBridgeOptimizer{MathOptInterface.Bridges.QuadtoSOCBridge{Float64},MathOptInterface.Bridges.QuadtoSOCInstance{Float64},SCS.Optimizer}) at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Bridges/bridgeoptimizer.jl:320
[3] default_copy_to(::MathOptInterface.Bridges.SingleBridgeOptimizer{MathOptInterface.Bridges.QuadtoSOCBridge{Float64},MathOptInterface.Bridges.QuadtoSOCInstance{Float64},SCS.Optimizer}, ::Parametron.ParametronMOIModel{Float64}, ::Bool) at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Utilities/copy.jl:175
[4] #copy_to#1 at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Bridges/bridgeoptimizer.jl:91 [inlined]
[5] copy_to at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Bridges/bridgeoptimizer.jl:91 [inlined]
[6] initialize!(::Model{Float64,MathOptInterface.Bridges.SingleBridgeOptimizer{MathOptInterface.Bridges.QuadtoSOCBridge{Float64},MathOptInterface.Bridges.QuadtoSOCInstance{Float64},SCS.Optimizer}}) at /home/twan/.julia/dev/Parametron/src/model.jl:118
[7] solve!(::Model{Float64,MathOptInterface.Bridges.SingleBridgeOptimizer{MathOptInterface.Bridges.QuadtoSOCBridge{Float64},MathOptInterface.Bridges.QuadtoSOCInstance{Float64},SCS.Optimizer}}) at /home/twan/.julia/dev/Parametron/src/model.jl:153
[8] top-level scope at ./REPL[47]:2 [inlined]
[9] top-level scope at ./none:0 I then tried optimizer = MOIB.QuadtoSOC{Float64}(MOIU.CachingOptimizer(MOIB.QuadtoSOCInstance{Float64}(), SCS.Optimizer(verbose=0))) but that resulted in ERROR: MathOptInterface.UnsupportedConstraint{MathOptInterface.VectorAffineFunction{Float64},MathOptInterface.RotatedSecondOrderCone}: `MathOptInterface.VectorAffineFunction{Float64}`-in-`MathOptInterface.RotatedSecondOrderCone` constraints is not supported by the the model.
Stacktrace:
[1] add_constraint(::MathOptInterface.Bridges.QuadtoSOCInstance{Float64}, ::MathOptInterface.VectorAffineFunction{Float64}, ::MathOptInterface.RotatedSecondOrderCone) at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Utilities/model.jl:330
[2] add_constraint(::MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Bridges.QuadtoSOCInstance{Float64}}, ::MathOptInterface.VectorAffineFunction{Float64}, ::MathOptInterface.RotatedSecondOrderCone) at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Utilities/cachingoptimizer.jl:241
[3] add_constraint(::MathOptInterface.Bridges.SingleBridgeOptimizer{MathOptInterface.Bridges.QuadtoSOCBridge{Float64},MathOptInterface.Bridges.QuadtoSOCInstance{Float64},MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Bridges.QuadtoSOCInstance{Float64}}}, ::MathOptInterface.VectorAffineFunction{Float64}, ::MathOptInterface.RotatedSecondOrderCone) at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Bridges/bridgeoptimizer.jl:300
[4] MathOptInterface.Bridges.QuadtoSOCBridge{Float64}(::MathOptInterface.Bridges.SingleBridgeOptimizer{MathOptInterface.Bridges.QuadtoSOCBridge{Float64},MathOptInterface.Bridges.QuadtoSOCInstance{Float64},MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Bridges.QuadtoSOCInstance{Float64}}}, ::MathOptInterface.ScalarQuadraticFunction{Float64}, ::MathOptInterface.LessThan{Float64}) at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Bridges/quadtosocbridge.jl:106
[5] add_constraint(::MathOptInterface.Bridges.SingleBridgeOptimizer{MathOptInterface.Bridges.QuadtoSOCBridge{Float64},MathOptInterface.Bridges.QuadtoSOCInstance{Float64},MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Bridges.QuadtoSOCInstance{Float64}}}, ::MathOptInterface.ScalarQuadraticFunction{Float64}, ::MathOptInterface.LessThan{Float64}) at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Bridges/bridgeoptimizer.jl:297
[6] copyconstraints!(::MathOptInterface.Bridges.SingleBridgeOptimizer{MathOptInterface.Bridges.QuadtoSOCBridge{Float64},MathOptInterface.Bridges.QuadtoSOCInstance{Float64},MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Bridges.QuadtoSOCInstance{Float64}}}, ::Parametron.ParametronMOIModel{Float64}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Type{MathOptInterface.ScalarQuadraticFunction{Float64}}, ::Type{MathOptInterface.LessThan{Float64}}) at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Utilities/copy.jl:145
[7] default_copy_to(::MathOptInterface.Bridges.SingleBridgeOptimizer{MathOptInterface.Bridges.QuadtoSOCBridge{Float64},MathOptInterface.Bridges.QuadtoSOCInstance{Float64},MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Bridges.QuadtoSOCInstance{Float64}}}, ::Parametron.ParametronMOIModel{Float64}, ::Bool) at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Utilities/copy.jl:187
[8] #copy_to#1 at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Bridges/bridgeoptimizer.jl:91 [inlined]
[9] copy_to at /home/twan/.julia/packages/MathOptInterface/zxv73/src/Bridges/bridgeoptimizer.jl:91 [inlined]
[10] initialize!(::Model{Float64,MathOptInterface.Bridges.SingleBridgeOptimizer{MathOptInterface.Bridges.QuadtoSOCBridge{Float64},MathOptInterface.Bridges.QuadtoSOCInstance{Float64},MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Bridges.QuadtoSOCInstance{Float64}}}}) at /home/twan/.julia/dev/Parametron/src/model.jl:118
[11] solve!(::Model{Float64,MathOptInterface.Bridges.SingleBridgeOptimizer{MathOptInterface.Bridges.QuadtoSOCBridge{Float64},MathOptInterface.Bridges.QuadtoSOCInstance{Float64},MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Bridges.QuadtoSOCInstance{Float64}}}}) at /home/twan/.julia/dev/Parametron/src/model.jl:153
[12] top-level scope at ./REPL[61]:2 [inlined]
[13] top-level scope at ./none:0 Ideally, the first would work, right? I'm not very familiar with this part of MOI, but I noticed this |
(see this branch: https://github.com/tkoolen/Parametron.jl/tree/tk/scs) |
|
OK, thanks. I think I might wait until the dust settles a bit then.
I think that's fine. I wouldn't expect it to be slower than what's currently there, but if it is a bit slower, no worries. I need the modification functions to be fast and not allocate, but the performance requirements for |
Unfortunately, I don't think there are currently any MOI optimizers that support modification of quadratic constraints (as I found out after making these changes).
Still useful sans function modification though.