Skip to content

Add R2N and R2NLS solvers with HSL and QRMumps support - #347

Open
farhadrclass wants to merge 94 commits into
JuliaSmoothOptimizers:mainfrom
Farhad-phd:R2N_R2NLS_2026_Jan
Open

Add R2N and R2NLS solvers with HSL and QRMumps support#347
farhadrclass wants to merge 94 commits into
JuliaSmoothOptimizers:mainfrom
Farhad-phd:R2N_R2NLS_2026_Jan

Conversation

@farhadrclass

Copy link
Copy Markdown
Contributor

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.

Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated
Comment thread src/R2N.jl Outdated

@dpo dpo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lots more comments on R2NLS.

Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated

@dpo dpo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I propose a cleaner subsolver API.

Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
@farhadrclass

Copy link
Copy Markdown
Contributor Author

@dpo I have refactor the R2NLS,

@dpo dpo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That looks great. Here are a few minor comments.

Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
@farhadrclass

Copy link
Copy Markdown
Contributor Author

@dpo pushed the R2NLS now,
moving to the R2N

@dpo dpo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few more comments. Starting to look great!

Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl Outdated
@farhadrclass

Copy link
Copy Markdown
Contributor Author

@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

@farhadrclass

Copy link
Copy Markdown
Contributor Author

@dpo This is ready for review

@github-actions

Copy link
Copy Markdown
Contributor
Package name latest stable
FletcherPenaltySolver
JSOSuite
PartiallySeparableNLPModels
Percival

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 / R2NLS solver 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.

Comment thread src/R2NLS.jl Outdated
Comment thread src/R2NLS.jl
Comment thread src/R2NLS.jl
Comment thread src/R2N.jl
Comment thread test/allocs.jl
Comment thread test/runtests.jl
Comment thread docs/src/solvers.md Outdated
Comment thread docs/src/index.md
farhadrclass and others added 2 commits June 17, 2026 18:51
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor
Package name latest stable
FletcherPenaltySolver
JSOSuite
PartiallySeparableNLPModels
Percival

@github-actions

Copy link
Copy Markdown
Contributor
Package name latest stable
FletcherPenaltySolver
JSOSuite
PartiallySeparableNLPModels
Percival

@github-actions

Copy link
Copy Markdown
Contributor
Package name latest stable
FletcherPenaltySolver
JSOSuite
PartiallySeparableNLPModels
Percival

@farhadrclass
farhadrclass requested a review from dpo June 19, 2026 11:45
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor
Package name latest stable
FletcherPenaltySolver
JSOSuite
PartiallySeparableNLPModels
Percival

Introduces `finalize_subsolver!` and `reset_subsolver!` to the subsolver interface. The default `reset_subsolver!` finalizes then re-initializes the subsolver, and is now called in `R2NSolver.reset!` to avoid stale state.

For `HSLR2NSubsolver`, adds a `_finalized` guard flag and a `finalizer` hook to ensure HSL (Ma97) C/Fortran memory is freed exactly once, preventing double-free bugs on GC collection.

Also renames `r2n_subsolver_common.jl` → `R2N_subsolver_common.jl` for naming consistency, and updates the HSL subsolver test to verify explicit cleanup and GC safety.
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
Package name latest stable
FletcherPenaltySolver
JSOSuite
PartiallySeparableNLPModels
Percival

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