Skip to content
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 QuadtoSOC bridge #483

Merged
merged 12 commits into from
Oct 20, 2018
Merged

Add QuadtoSOC bridge #483

merged 12 commits into from
Oct 20, 2018

Conversation

blegat
Copy link
Member

@blegat blegat commented Aug 23, 2018

Currently, it only bridges x^T Q x + a^T x + b <= c for PSD matrix Q and does not support x^T Q x with one negative eigenvalue, the reason is discussed in the docstring.

Closes JuliaOpt/MathOptInterfaceBridges.jl#93

function MOI.get(model::MOI.ModelLike, attr::MOI.ConstraintPrimal,
bridge::QuadtoSOCBridge)
soc = MOI.get(model, attr, bridge.soc)
@show soc
Copy link
Member

Choose a reason for hiding this comment

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

Debugging output?

rmul!(Q, -1)
end
@show Q
U = cholesky(Symmetric(Q)).U
Copy link
Member

Choose a reason for hiding this comment

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

How are errors handled if Q is not PSD?

rmul!(Q, -1)
end
@show Q
U = cholesky(Symmetric(Q)).U
Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned about the use of a dense factorization. This is probably the wrong thing to do when Q isn't trivially small. (< 100x100). The fact that this bridge will be applied automatically means that users are going to run into a surprise performance bomb with no feedback about what was wrong.

@codecov-io
Copy link

codecov-io commented Oct 2, 2018

Codecov Report

Merging #483 into master will decrease coverage by 0.04%.
The diff coverage is 89.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #483      +/-   ##
==========================================
- Coverage   95.64%   95.59%   -0.05%     
==========================================
  Files          46       47       +1     
  Lines        4682     4839     +157     
==========================================
+ Hits         4478     4626     +148     
- Misses        204      213       +9
Impacted Files Coverage Δ
src/Bridges/Bridges.jl 100% <100%> (ø) ⬆️
src/Bridges/quadtosocbridge.jl 89.39% <89.39%> (ø)
src/constraints.jl 100% <0%> (ø) ⬆️
src/Utilities/copy.jl 94.44% <0%> (+0.61%) ⬆️
src/attributes.jl 97.29% <0%> (+1.64%) ⬆️
src/indextypes.jl 84.21% <0%> (+2.39%) ⬆️

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 38a4e88...4ae4827. Read the comment docs.

@blegat
Copy link
Member Author

blegat commented Oct 13, 2018

@mlubin All your comments have been addressed :)

@chriscoey
Copy link
Contributor

It would be cool if Julia could automatically use sparse cholesky if Q is very sparse but dense cholesky otherwise. There has been discussion of making the dense and sparse factorization interfaces fully consistent but no one has stepped up to the plate yet.

@blegat
Copy link
Member Author

blegat commented Oct 14, 2018

I also got confused by the inconsistency. For sparse cholesky, there is a permutation matrix and you have A = P' * L * L' * P while for dense cholesky, you have A = L * L'. Since P is identity most of the time, that could easily lead to code that works fine most of the time and suddenly fail. It is unclear from the cholesky doc if the permutation matrix can be non-identity if the perm argument is not provided. Should check in the SuiteSparse doc, I have opened an issue here: #538

The check for existence of bound can be implemented (but inefficiently) with the
current interface but if bound is removed or transformed (e.g. `≤ 0` transformed
into `≥ 0`) then the bridge is no longer valid. For this reason the homogeneous
version of the bridge is not implemented yet.
Copy link
Member

Choose a reason for hiding this comment

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

This sentence at the end is the only hint in this docstring about what the bridge actually does. Say more explicitly at the beginning which transformations are implemented.

" constraint of type: `$(typeof(func))`-in-`$(typeof(set))`.",
" A bridge attempted to transform the quadratic constraint",
" to a second order cone constraint but the constraint is not",
" convex.")
Copy link
Member

@mlubin mlubin Oct 14, 2018

Choose a reason for hiding this comment

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

This is incorrect. cholesky will fail when Q is only positive semi-definite, but that's a perfectly valid convex constraint.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could try LDLT instead right? Or bunch-kaufman if dense

" convex.")
" to a second order cone constraint but the constraint is",
" not strongly convex, i.e., the symmetric matrix of"
" quadratic coefficients is not positive definite.")
Copy link
Member

Choose a reason for hiding this comment

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

This wording suggests that the user did something wrong, while the issue is in the implementation of the bridge instead. Maybe "... not yet supported" is more appropriate.

@blegat blegat merged commit 6ba3cbe into master Oct 20, 2018
@odow odow deleted the bl/quadtosoc branch March 6, 2019 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants