Add R2N and R2NLS solvers with HSL and QRMumps support#347
Add R2N and R2NLS solvers with HSL and QRMumps support#347farhadrclass wants to merge 70 commits into
Conversation
dpo
left a comment
There was a problem hiding this comment.
I propose a cleaner subsolver API.
|
@dpo I have refactor the R2NLS, |
dpo
left a comment
There was a problem hiding this comment.
That looks great. Here are a few minor comments.
|
@dpo pushed the R2NLS now, |
dpo
left a comment
There was a problem hiding this comment.
Just a few more comments. Starting to look great!
|
@dpo I didn't move x_init to x0 since by doing so, we would remove the connection between LinearOp jac relying on x to be update to update the Jacobean, I can however add a new x_op to solver structure but that would allocate a memory and at the end do the same thing, In the constructor, I am linking x which will be updated in each iteration to jacobean Let me know what you think |
Replace the generic update!(...) subsolver API with a more specific update_subsolver!(...) across the codebase. Updated call sites (src/R2N.jl, src/R2NLS.jl), subsolver implementations (src/R2NLS_subsolvers.jl, src/R2N_subsolvers.jl), and the exported symbol in src/r2n_subsolver_common.jl. Also adjusted the QRM update call to qrm_update_subsolver! where the subsolver updates the sparse values. This clarifies the API, avoids potential name collisions, and makes subsolver update intent explicit.
Call the subsolver with an explicit zero atol (pass T(0.0)) and set the subsolver operator's σ on sub.A.data.σ instead of sub.A. Adjust the adaptive subtol update to use sqrt(eps(T)) as the lower bound rather than rtol. Minor whitespace tidy and TODO comments left in place for future cleanup.
Allow passing subsolvers as Functions (constructors) or Types in R2N and R2NLS by extending the param unions and updating instantiation logic to call subsolver(nlp) when subsolver is a Type or Function. Adjusted default parameter types accordingly. Add Quadmath to Project.toml and add Float128/Quadmath and LBFGS usage examples to the test script (R2N_test.jl) to exercise the new constructor-style subsolver and quasi-Newton wrapping.
fix H not updating
a4a2221 to
941631d
Compare
Remove stored gradient-difference state and inline quasi-Newton updates from R2NSolver/solve!. Introduce a callback_quasi_newton argument (with default) and invoke it before the main callbacks and again each iteration, so quasi-Newton models can update their Hessian approximations externally. Removed the y field, its allocations and uses, and the direct push! of s,y into QuasiNewtonModel; added set_step_status! calls when steps are accepted/rejected. This decouples quasi-Newton bookkeeping from the solver core and provides a flexible callback hook for Hessian updates.
Convert symbol-based subsolver options to concrete subsolver types across code and tests, update test names accordingly, and make related fixes. Key changes: - Use max(T(1e-8), nextfloat(zero(T))) for R2N_ls_min_alpha to avoid denormals. - Add an error check in R2N to require minimization problems. - Ensure R2NLS σ is stored with correct type via T(eps(...) ). - Replace symbol subsolver args (e.g. :qrmumps, :lsmr, :cgls, :lsqr, :shifted_lbfgs, :ma97, :ma57) with corresponding subsolver types (QRMumpsSubsolver, LSMRSubsolver, CGLSSubsolver, LSQRSubsolver, ShiftedLBFGSSolver, MA97R2NSubsolver, MA57R2NSubsolver) and adjust npc_handler naming where applicable. - Rename several test entries to reflect the new solver identifiers (e.g. R2N_exact -> R2N_ShiftedLBFGS) and update allocation, consistency, restart, runtests, and solver test suites. - Add callback tests for R2N and R2NLS ensuring solver.σ > 0 at an intermediate iteration. - Use NLPModels.reset! explicitly in tests and apply minor whitespace/newline tidying. These changes standardize subsolver usage, fix type and behaviour issues, and align tests with the new API.
|
@dpo the tests fail because we need OpNorm to be pushed on the LinearOperator and then I can update the LinearOperator here |
Add an "Unconstrained Benchmark" section to docs/src/benchmark.md demonstrating how to benchmark unconstrained solvers (example comparing R2N vs trunk on pnames_unconstrained), including sample code to run bmark_solvers and inspect stats, plus a note about using the same pattern for R2NLS on NLS problems. Update docs/src/index.md to clarify that Krylov.jl is used by TRON, TRUNK, R2N, and R2NLS for solving Newton/regularized/trust-region subproblems, and list R2N as supported for callback_quasi_newton. Also include a minor whitespace/formatting adjustment.
Introduces new second-order quadratic regularization solvers R2N and R2NLS for unconstrained and nonlinear least-squares optimization. Adds support for HSL (MA97, MA57) and QRMumps direct solvers, updates documentation and README, and extends test coverage for the new solvers. Updates dependencies and compat entries in Project.toml.