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 77 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 |
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.
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.
6a9484b to
621e326
Compare
|
@dpo This is ready for review |
There was a problem hiding this comment.
Pull request overview
This PR adds two new inexact second-order quadratic regularization solvers—R2N (unconstrained NLP) and R2NLS (unconstrained NLS)—including new subsolver backends (HSL MA97/MA57 and QRMumps/Krylov), plus associated documentation and tests.
Changes:
- Introduces
R2N/R2NLSsolver implementations and shared subsolver interfaces. - Adds HSL and QRMumps/Krylov-based subsolvers and integrates them into the package.
- Updates tests, README, and docs; expands solver listings and benchmarks; updates dependencies/compat.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/JSOSolvers.jl |
Wires new solver/subsolver modules into the package entrypoint and updates imports/deps usage. |
src/r2n_subsolver_common.jl |
Adds shared abstract interfaces/utilities for R2N/R2NLS subsolvers. |
src/R2N_subsolvers.jl |
Implements R2N subsolvers (Krylov, Shifted-LBFGS, HSL MA97/MA57). |
src/R2N.jl |
Implements the new R2N solver + parameter set. |
src/R2NLS_subsolvers.jl |
Implements R2NLS subsolvers (QRMumps + Krylov-based). |
src/R2NLS.jl |
Implements the new R2NLS solver + parameter set. |
Project.toml |
Adds new dependencies and compat bounds needed by the new solvers/subsolvers. |
README.md |
Documents the new solvers at a high level and updates usage examples. |
docs/src/index.md |
Updates dependency descriptions to include R2N/R2NLS usage of Krylov + callback_quasi_newton support. |
docs/src/solvers.md |
Adds R2N/R2NLS to solver listings and categorization tables. |
docs/src/benchmark.md |
Adds an example benchmark section for unconstrained solvers (incl. R2N). |
test/runtests.jl |
Hooks new parameter-set tests and new HSL test file into the test runner. |
test/test_solvers.jl |
Extends solver test matrix to cover R2N and R2NLS variants/subsolvers. |
test/test_hsl_subsolver.jl |
Adds HSL-backed R2N solver tests gated by LIBHSL_isfunctional(). |
test/restart.jl |
Extends restart tests to cover R2N and R2NLS solver variants/subsolvers. |
test/incompatible.jl |
Adds incompatible-problem checks for R2N and R2NLS. |
test/consistency.jl |
Adds consistency checks for R2N and R2NLS (incl. shifted-LBFGS and QRMumps). |
test/callback.jl |
Adds callback behavior tests for R2N and R2NLS. |
test/allocs.jl |
Extends allocation tests to include R2N and R2NLS solver variants. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.