You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been using NonlinearSolve to solve nonlinear least squares problems in an algorithm I have been developing, but when I upgraded to version v4.x.x the Levenberg Marquardt solver started giving poor results. When I pin the package back at v3.15.1 all my issues resolve, and all the v4.x.x versions I have tried have the behavior below. I can recreate the behavior on a linear least squares problem, I saved the input matrices at the bottom of this issue.
Expected behavior
When I run this code in v3.15.1, the linear least squares problem is solved to a high level of accuracy:
Status `~/nolinearsolveissue/Project.toml`
[8bb1440f] DelimitedFiles v1.9.1
⌃ [8913a72c] NonlinearSolve v3.15.1 ⚲
Info Packages marked with ⌃ have new versions available and may be upgradable.
[ Info: Relative Error 4.280111795651271e-9
Minimal Reproducible Example 👇
## Load dependenciesusing NonlinearSolve: NonlinearLeastSquaresProblem, NonlinearFunction, LevenbergMarquardt, solve
using DelimitedFiles: readdlm
using Pkg
Pkg.status()
## Build linear least square problem for testing
A =readdlm(joinpath(@__DIR__,"A.csv"),',',Float64)
b =readdlm(joinpath(@__DIR__,"b.csv"),',',Float64)[:]
M,N =size(A)
functionr!(r,x, ::Any)
r .= A*x - b
nothingendfunction∇r!(J, p, ::Any)
J .= A
nothingend# Run NonlinearSolve.solve
x0 =zeros(N)
sol =solve(
NonlinearLeastSquaresProblem(
NonlinearFunction(
r!;
jac=∇r!,
resid_prototype=zeros(M)
),
x0
),
LevenbergMarquardt()
)
xhat = sol.u
x = A \ b
relErr =norm(xhat- x)/norm(x)
@info"Relative Error $relErr"
Describe the bug 🐞
I have been using NonlinearSolve to solve nonlinear least squares problems in an algorithm I have been developing, but when I upgraded to version v4.x.x the Levenberg Marquardt solver started giving poor results. When I pin the package back at v3.15.1 all my issues resolve, and all the v4.x.x versions I have tried have the behavior below. I can recreate the behavior on a linear least squares problem, I saved the input matrices at the bottom of this issue.
Expected behavior
When I run this code in v3.15.1, the linear least squares problem is solved to a high level of accuracy:
Minimal Reproducible Example 👇
Error & Stacktrace⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context
Here are the CSV files for the example:
A.csv
b.csv
The text was updated successfully, but these errors were encountered: