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 optional preconditioner for linear solves #279

Merged
merged 12 commits into from
Oct 6, 2024

Conversation

mpf
Copy link
Contributor

@mpf mpf commented Sep 26, 2024

This PR allows for an optional preconditioner to be passed to the linear subsolver.

@tmigot tmigot linked an issue Sep 29, 2024 that may be closed by this pull request
Copy link
Member

@tmigot tmigot left a 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?

src/trunk.jl Outdated Show resolved Hide resolved
src/trunk.jl Outdated Show resolved Hide resolved
src/trunk.jl Outdated Show resolved Hide resolved
src/trunk.jl Outdated Show resolved Hide resolved
@tmigot tmigot requested a review from amontoison September 29, 2024 20:17
Copy link
Member

@amontoison amontoison left a 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.

mpf and others added 5 commits October 3, 2024 18:50
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.
@mpf
Copy link
Contributor Author

mpf commented Oct 6, 2024

@amontoison This isn't a great preconditioner, but it does test the new optional preconditioner argument.

@amontoison
Copy link
Member

amontoison commented Oct 6, 2024

@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.
Do you need a new release after that I merge this PR?

@amontoison amontoison merged commit 53a9419 into JuliaSmoothOptimizers:main Oct 6, 2024
17 of 19 checks passed
@mpf
Copy link
Contributor Author

mpf commented Oct 6, 2024

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)
Copy link
Member

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrating a preconditioner into Trunk's trust-region subsolver
4 participants