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

Reuse Arpack in order to compute norm of Bk #159

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

MohamedLaghdafHABIBOULLAH
Copy link
Contributor

@MohamedLaghdafHABIBOULLAH
Copy link
Contributor Author

Please hold off on merging for now, as some tests are affected by #42 .

@nathanemac you can try to merge this PR locally with R2N in order to use ADNLPModels

@@ -130,7 +130,8 @@ function LMTR(
JdFk = similar(Fk) # temporary storage
Jt_Fk = similar(∇fk) # temporary storage

σmax = opnorm(Jk)
σmax, found_σ = opnorm(Jk)
found_σ || error("operator norm computation failed")
Copy link
Member

Choose a reason for hiding this comment

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

We should have a backup plan if the computation fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Working on understanding why it may not work ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

src/RegularizedOptimization.jl Outdated Show resolved Hide resolved
src/utils.jl Outdated Show resolved Hide resolved
src/utils.jl Show resolved Hide resolved
src/utils.jl Outdated Show resolved Hide resolved
@nathanemac
Copy link

@MohamedLaghdafHABIBOULLAH, using Arpack instead of TSVD indeed solves the Lapack issue for R2N on the dummy example:

nlp = ADNLPModel(x -> (1-x[1])^2 + 100(x[1]-x[2]^2)^2, [1., 1.], backend=:generic) h = NormL1(1.0) options = ROSolverOptions() res_r2n = R2N(nlp, h, options)

Co-authored-by: Dominique <[email protected]>
@MohamedLaghdafHABIBOULLAH
Copy link
Contributor Author

@nathanemac thanks for the confirmation, we believe that Arrack may be more accurate than TSVD, but still have some bugs...
If you encounter one, do not hesitate to share it.

Use alphabetical order for external dependencies and remove unused variables.
Enhance robustness of Arpack usage by catching NCV-related errors

Catch the XYAUPD_Exception error in Arpack calls and dynamically increase NCV as needed to handle convergence issues. This modification addresses instability in LSR1 computations due to insufficient NCV.
@MohamedLaghdafHABIBOULLAH
Copy link
Contributor Author

MohamedLaghdafHABIBOULLAH commented Nov 4, 2024

This PR should address the problem encountered in this issue #42
by catching the XYAUPD_Exception error in Arpack calls and dynamically increase NCV as needed to handle convergence issues. This modification addresses instability in LSR1 computations due to insufficient NCV.

while !(have_eig || attempt >= max_attempts)
attempt += 1
try
# Perform eigendecomposition
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Perform eigendecomposition
# Estimate largest eigenvalue in absolute value

catch e
if occursin("XYAUPD_Exception", string(e))
@warn "Arpack error: $e. Increasing NCV to $ncv and retrying."
ncv = min(2 * ncv, n) # Increase NCV but don't exceed matrix size
Copy link
Member

Choose a reason for hiding this comment

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

If we still get an error when ncv == n, we should abort.

while !(have_svd || attempt >= max_attempts)
attempt += 1
try
# Perform singular value decomposition
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Perform singular value decomposition
# Estimate largest singular value

@MaxenceGollier
Copy link
Contributor

Just wondering, @MohamedLaghdafHABIBOULLAH, is it possible to use the frobenius norm instead of the operator norm for your algorithm ? QRMumps has a function (see qrm_spmat_nrm) that allows to compute this quite efficiently I think and it could allow to reduce the number of dependencies because I am already adding QRMumps in my own PR #145.

@MohamedLaghdafHABIBOULLAH
Copy link
Contributor Author

MohamedLaghdafHABIBOULLAH commented Nov 27, 2024

@MaxenceGollier yes one could and it has been discussed in the paper and in this issue #133 , however I'm afraid that the solver will become slower as the step size is related to 1/|B_k|, in this case the Frobenius norm might represent a loose bound on the operator norm or the largest eig norm.

@dpo
Copy link
Member

dpo commented Nov 28, 2024

You can’t compute the Frobenius norm of a quasi-Newton operator without a lot of work.

@MaxenceGollier
Copy link
Contributor

@MohamedLaghdafHABIBOULLAH can we add a wrapped allocs unit test to be sure that opnorm does not allocate as well ?

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.

4 participants