-
Notifications
You must be signed in to change notification settings - Fork 16
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 optional preconditioner for linear solves #279
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mpf ! Thanks for the PR this a great addition. I made a few comments.
Two more that are not in the code:
- [ ] Can you add the new keyword argument L.18-29 in the docstring of the function
trunk
? - [ ] Would you also have a unit test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have a unit test that passed, we can merge the PR.
Co-authored-by: Tangi Migot <[email protected]>
Co-authored-by: Tangi Migot <[email protected]>
This doesn't seem to be a great preconditioner, but it does test the precon option.
@amontoison This isn't a great preconditioner, but it does test the new optional preconditioner argument. |
It's fine @mpf. The goal is just to ensure that we can provide a preconditioner without errors. |
A release would be great, and then I can let go of my fork. Thanks, @amontoison ! |
function DiagPrecon(x) | ||
H = Matrix(hess(nlp, x)) | ||
λmin = minimum(eigvals(H)) | ||
Diagonal(H + λmin * I) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just so users aren't confused, we should add a little more than λmin here. If H has a negative eigenvalue, this preconditioner is singular.
M = DiagPrecon(x0) | ||
function LinearAlgebra.ldiv!(y, M::Diagonal, x) | ||
y .= M \ x | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already part of LinearAlgebra.
This PR allows for an optional preconditioner to be passed to the linear subsolver.