Skip to content

Commit

Permalink
Add a default for NLLS
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Nov 4, 2023
1 parent b8d43a3 commit 08d25cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NonlinearSolve"
uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
authors = ["SciML"]
version = "2.6.1"
version = "2.7.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
21 changes: 15 additions & 6 deletions src/default.jl
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,21 @@ end

## Defaults

function SciMLBase.__init(prob::NonlinearProblem{uType, iip}, alg::Nothing, args...;
kwargs...) where {uType, iip}
SciMLBase.__init(prob, FastShortcutNonlinearPolyalg(), args...; kwargs...)
function SciMLBase.__init(prob::NonlinearProblem, ::Nothing, args...; kwargs...)
return SciMLBase.__init(prob, FastShortcutNonlinearPolyalg(), args...; kwargs...)
end

function SciMLBase.__solve(prob::NonlinearProblem{uType, iip}, alg::Nothing, args...;
kwargs...) where {uType, iip}
SciMLBase.__solve(prob, FastShortcutNonlinearPolyalg(), args...; kwargs...)
function SciMLBase.__solve(prob::NonlinearProblem, ::Nothing, args...; kwargs...)
return SciMLBase.__solve(prob, FastShortcutNonlinearPolyalg(), args...; kwargs...)
end

# FIXME: We default to using LM currently. But once we have line searches for GN implemented
# we should default to a polyalgorithm.
function SciMLBase.__init(prob::NonlinearLeastSquaresProblem, ::Nothing, args...; kwargs...)
return SciMLBase.__init(prob, LevenbergMarquardt(), args...; kwargs...)

Check warning on line 282 in src/default.jl

View check run for this annotation

Codecov / codecov/patch

src/default.jl#L281-L282

Added lines #L281 - L282 were not covered by tests
end

function SciMLBase.__solve(prob::NonlinearLeastSquaresProblem, ::Nothing, args...;
kwargs...)
return SciMLBase.__solve(prob, LevenbergMarquardt(), args...; kwargs...)
end
1 change: 1 addition & 0 deletions test/nonlinear_least_squares.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ solvers = [
LevenbergMarquardt(; linsolve = LUFactorization()),
LeastSquaresOptimJL(:lm),
LeastSquaresOptimJL(:dogleg),
nothing
]

for prob in nlls_problems, solver in solvers
Expand Down

0 comments on commit 08d25cc

Please sign in to comment.