Skip to content

Conversation

farhadrclass
Copy link
Contributor

This pull request introduces the new R2NLS solver for unconstrained nonlinear least-squares (NLS) problems, expands documentation and test coverage for this solver.

Major features and solver additions:

  • Added the R2NLS solver, an inexact second-order quadratic regularization method for unconstrained NLS, to the codebase and exported it for use. (src/JSOSolvers.jl, src/R2NLS.jl, README.md, docs/src/solvers.md) [1] [2] [3] [4]
  • Updated documentation tables and solver listings to include R2NLS as an available solver for unconstrained NLS problems. (docs/src/solvers.md, README.md) [1] [2] [3]

Utilities and infrastructure:

  • Added a new opnorm utility function in utilities.jl that computes operator norms for both standard numeric and arbitrary element types, using LAPACK, ARPACK, or TSVD as appropriate. This is now included and exported in the main module. (src/utilities.jl, src/JSOSolvers.jl) [1] [2]
  • Added comprehensive tests for the new opnorm utility, covering multiple numeric types and matrix shapes. (test/test_Utilities.jl)

Testing enhancements:

  • Expanded test coverage to include R2NLS and its subsolver variants in all relevant test suites, including allocation, callback, consistency, restart, and general solver tests. (test/allocs.jl, test/callback.jl, test/consistency.jl, test/restart.jl, test/runtests.jl, test/test_solvers.jl) [1] [2] [3] [4] [5] [6] [7]

Dependency and import updates:

  • Added necessary imports for Arpack, SparseArrays, and Krylov in both the main module and test files to support the new solver and utilities. (src/JSOSolvers.jl, test/runtests.jl) [1] [2]

Note:

  1. OpNorm will be moving to LinearOperator (@dpo?)
  2. QRMumps was added as a core sub-solver and will not be a separate PR as requested (by @dpo )

Introduces the R2NLS solver, an inexact second-order quadratic regularization method for nonlinear least-squares, with support for multiple subproblem solvers including QRMumps. Updates documentation, tests, and dependencies to include R2NLS and its utilities, and adds comprehensive test coverage for the new solver and its subsolvers.
The finalizer that calls close! on QRMumpsSolver has been commented out due to crashes in libdqrm.dll during object finalization, likely caused by a double free or invalid pointer reference. Additional minor changes include switching from view to direct indexing for SparseMatrixCOO construction to avoid pointer issues, and reordering some operations in SolverCore.solve! for clarity.
Copy link

codecov bot commented Aug 15, 2025

Codecov Report

❌ Patch coverage is 91.91489% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.40%. Comparing base (52caf59) to head (0744484).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
src/R2NLS.jl 91.91% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #311      +/-   ##
==========================================
+ Coverage   89.00%   89.40%   +0.40%     
==========================================
  Files           7        8       +1     
  Lines        1200     1435     +235     
==========================================
+ Hits         1068     1283     +215     
- Misses        132      152      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Eliminated a duplicate call to mul!(∇f, Jx', r) in the SolverCore.solve! function to avoid unnecessary computation.
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.

Thanks @farhadrclass for the PR. I made a first batch of comments (but didn't check the new algorithm)

src/R2NLS.jl Outdated
ls_subsolver.irn[1:ls_subsolver.nnzj],
ls_subsolver.jcn[1:ls_subsolver.nnzj],
ls_subsolver.val[1:ls_subsolver.nnzj],
) #For now till they fix the SparseMatrixCOO to accept pointers
Copy link
Member

Choose a reason for hiding this comment

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

Is there an open issue for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but @dpo and I thinking about this right now

@tmigot tmigot requested a review from dpo August 21, 2025 10:39
SolverCore = "0.3"
SolverParameters = "0.1"
SolverTools = "0.9"
SparseArrays = "1.11.0"
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
SparseArrays = "1.11.0"
SparseArrays = "1.10.0"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why do we want 1.10?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted utilities.jl and its tests, removing the opnorm/TSVD utilities and all related test coverage. Dropped Arpack and GenericLinearAlgebra from dependencies and compat, and updated code and tests to no longer use or include them. Fixed a typo in the CRLS subsolver dispatch in test_solvers.jl.
@farhadrclass
Copy link
Contributor Author

@tmigot thank you for the review, I applied most of what you recommend and asked some questions to confirm the rest
will push the new code soon

Introduces the R2NLSParameterSet struct to encapsulate all algorithmic parameters for the R2NLS solver, replacing individual keyword arguments. Updates R2SolverNLS and R2NLS constructors and solve! logic to use the new parameter set, improving type safety, maintainability, and clarity of parameter handling.
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.

2 participants