Skip to content

Add (R)SOCtoNonConvexQuad Bridge #1046

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

Merged
merged 15 commits into from
Jun 10, 2020
Merged

Add (R)SOCtoNonConvexQuad Bridge #1046

merged 15 commits into from
Jun 10, 2020

Conversation

joaquimg
Copy link
Member

@joaquimg joaquimg commented Mar 9, 2020

Simpler version of: #478
Bridge not included by default in Lazy bridge optimizer, but can be used by advanced users.
Tried to include caveats in the doc strings.

@joaquimg joaquimg added the Submodule: Bridges About the Bridges submodule label Mar 9, 2020
@codecov-io
Copy link

codecov-io commented Mar 9, 2020

Codecov Report

Merging #1046 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1046      +/-   ##
==========================================
+ Coverage   95.26%   95.28%   +0.01%     
==========================================
  Files         100      101       +1     
  Lines       11436    11484      +48     
==========================================
+ Hits        10895    10943      +48     
  Misses        541      541
Impacted Files Coverage Δ
src/Bridges/Constraint/Constraint.jl 96.55% <ø> (ø) ⬆️
src/Bridges/Constraint/soc_to_nonconvex_quad.jl 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3bbd5b...e6c0bb8. Read the comment docs.

fq = MOI.ScalarQuadraticFunction(a_terms, q_terms, zero(T))
quad = MOI.add_constraint(model, fq, MOI.LessThan(zero(T)))
fp = MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(one(T),t)], zero(T))
var_pos = MOI.add_constraint(model, fp, MOI.GreaterThan(zero(T)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooooo. This is a nice way to avoid the double bound issue. Don't know why I didn't think of that for Gurobi et al. Nice job.

@joaquimg
Copy link
Member Author

Bump, @mlubin can you take a quick look?

Copy link
Member

@mlubin mlubin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry for missing this review.

`ScalarAffineFunction`-in-`GreaterThan`. Indeed, the definition of the
second-order cone
```math
t \\ge || x ||_2 \\ (1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the (1), (2), (3) labels display in the REPL? (Is it correct markdown?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will check the best way to do so.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not proper markdown, but it renders as:

help?> MathOptInterface.Bridges.Constraint.RSOCtoNonConvexQuadBridge
  RSOCtoNonConvexQuadBridge{T}

  Constraints of the form VectorOfVariables-in-SecondOrderCone can be transformed into a
  ScalarQuadraticFunction-in-LessThan and a ScalarAffineFunction-in-GreaterThan. Indeed, the definition of the
  second-order cone

2tu \ge \lVert x \rVert_2^2, t,u \ge 0  (1)

  is equivalent to

\sum x_i^2 \le 2tu  (2)

  with t,u \ge 0. (3)

  WARNING This transformation starts from a convex constraint (1) and creates a non-convex constraint (2), because the
  Q matrix associated with the constraint 2 has two negative eigenvalues. This might be wrongly interpreted by a
  solver. Some solvers can look at (2) and understand that it is a rotated second order cone, but this is not a
  general rule. For these reasons this bridge is not automatically added to the LazyBridgeOptimizer. Care is
  recommended when adding this bridge to a optimizer.

Which is not bad in my opinion.

@joaquimg joaquimg requested review from mlubin and odow June 1, 2020 02:14
@joaquimg joaquimg requested a review from blegat June 2, 2020 20:08
@joaquimg joaquimg requested a review from blegat June 8, 2020 02:46
[`Bridges.Constraint.SOCtoNonConvexQuadBridge`](@ref).

The first option is to add the specific bridges to a
`bridged_model` optimizer, with coefficient type `T`, using
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to specify that it is a LazyBridgeOptimizer

@joaquimg
Copy link
Member Author

joaquimg commented Jun 8, 2020

I added docstring with ref to full_bridge, but there are doc errors:

┌ Warning: unable to get the binding for '[`Bridges.full_bridge_optimizer`](@ref)' in src/apireference.md from expression ':(Bridges.full_bridge_optimizer)' in module MathOptInterface.Bridges.Constraint
│   exception = UndefVarError: Bridges not defined
└ @ Documenter.CrossReferences ~/.julia/packages/Documenter/PLD7m/src/CrossReferences.jl:137

you know how to reference functions from outside?

@joaquimg joaquimg requested a review from blegat June 9, 2020 13:43
@joaquimg
Copy link
Member Author

joaquimg commented Jun 9, 2020

Tests passed, there is som communication issue with travis

@joaquimg joaquimg merged commit 5896072 into master Jun 10, 2020
@joaquimg joaquimg mentioned this pull request Jun 10, 2020
@odow odow deleted the jg/socncquad branch June 22, 2020 02:57
@blegat blegat added this to the v0.9.15 milestone Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Submodule: Bridges About the Bridges submodule
Development

Successfully merging this pull request may close these issues.

5 participants