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 6, 2023
1 parent c5c0176 commit 87203f4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/default.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,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...)
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 @@ -36,6 +36,7 @@ append!(solvers,
LevenbergMarquardt(; linsolve = LUFactorization()),
LeastSquaresOptimJL(:lm),
LeastSquaresOptimJL(:dogleg),
nothing,
])

for prob in nlls_problems, solver in solvers
Expand Down

0 comments on commit 87203f4

Please sign in to comment.