Skip to content

Commit 43227e5

Browse files
Fix handling of singular Jacobians in default solver
Fixes #635
1 parent 566aa40 commit 43227e5

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/poly_algs.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ function FastShortcutNonlinearPolyalg(
3434
) where {T}
3535
start_index = 1
3636
common_kwargs = (; concrete_jac, linsolve, autodiff, vjp_autodiff, jvp_autodiff)
37+
common_kwargs_nocj = (; linsolve, autodiff, vjp_autodiff, jvp_autodiff)
3738
if must_use_jacobian isa Val{true}
3839
if T <: Complex
3940
algs = (NewtonRaphson(; common_kwargs...),)
4041
else
4142
algs = (
4243
NewtonRaphson(; common_kwargs...),
4344
TrustRegion(; common_kwargs...),
44-
TrustRegion(; common_kwargs..., radius_update_scheme = RUS.Bastin)
45+
TrustRegion(; common_kwargs..., radius_update_scheme = RUS.Bastin),
46+
LevenbergMarquardt(; common_kwargs_nocj...)
4547
)
4648
end
4749
else
@@ -61,7 +63,8 @@ function FastShortcutNonlinearPolyalg(
6163
SimpleKlement(),
6264
NewtonRaphson(; common_kwargs...),
6365
TrustRegion(; common_kwargs...),
64-
TrustRegion(; common_kwargs..., radius_update_scheme = RUS.Bastin)
66+
TrustRegion(; common_kwargs..., radius_update_scheme = RUS.Bastin),
67+
LevenbergMarquardt(; common_kwargs_nocj...)
6568
)
6669
end
6770
else
@@ -79,7 +82,8 @@ function FastShortcutNonlinearPolyalg(
7982
Klement(; linsolve, autodiff),
8083
NewtonRaphson(; common_kwargs...),
8184
TrustRegion(; common_kwargs...),
82-
TrustRegion(; common_kwargs..., radius_update_scheme = RUS.Bastin)
85+
TrustRegion(; common_kwargs..., radius_update_scheme = RUS.Bastin),
86+
LevenbergMarquardt(; common_kwargs_nocj...)
8387
)
8488
end
8589
end

test/core_tests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,4 +435,11 @@ end
435435
sol = solve(prob)
436436
@test SciMLBase.successful_retcode(sol)
437437
@test sol.retcode == ReturnCode.StalledSuccess
438+
end
439+
440+
@testitem "Default Algorithm Singular Handling" tags=[:core] begin
441+
f(u, p) = [u[1]^2 - 2u[1] + 1, sum(u)]
442+
prob = NonlinearProblem(f, [1.0, 1.0])
443+
sol = solve(prob)
444+
@test SciMLBase.successful_retcode(sol)
438445
end

0 commit comments

Comments
 (0)