@@ -250,6 +250,42 @@ function FastShortcutNonlinearPolyalg(; concrete_jac = nothing, linsolve = nothi
250
250
return NonlinearSolvePolyAlgorithm (algs, Val (:NLS ))
251
251
end
252
252
253
+ """
254
+ FastShortcutNLLSPolyalg(; concrete_jac = nothing, linsolve = nothing,
255
+ precs = DEFAULT_PRECS, adkwargs...)
256
+
257
+ A polyalgorithm focused on balancing speed and robustness. It first tries less robust methods
258
+ for more performance and then tries more robust techniques if the faster ones fail.
259
+
260
+ ### Keyword Arguments
261
+
262
+ - `autodiff`: determines the backend used for the Jacobian. Note that this argument is
263
+ ignored if an analytical Jacobian is passed, as that will be used instead. Defaults to
264
+ `AutoForwardDiff()`. Valid choices are types from ADTypes.jl.
265
+ - `concrete_jac`: whether to build a concrete Jacobian. If a Krylov-subspace method is used,
266
+ then the Jacobian will not be constructed and instead direct Jacobian-vector products
267
+ `J*v` are computed using forward-mode automatic differentiation or finite differencing
268
+ tricks (without ever constructing the Jacobian). However, if the Jacobian is still needed,
269
+ for example for a preconditioner, `concrete_jac = true` can be passed in order to force
270
+ the construction of the Jacobian.
271
+ - `linsolve`: the [LinearSolve.jl](https://github.com/SciML/LinearSolve.jl) used for the
272
+ linear solves within the Newton method. Defaults to `nothing`, which means it uses the
273
+ LinearSolve.jl default algorithm choice. For more information on available algorithm
274
+ choices, see the [LinearSolve.jl documentation](https://docs.sciml.ai/LinearSolve/stable/).
275
+ - `precs`: the choice of preconditioners for the linear solver. Defaults to using no
276
+ preconditioners. For more information on specifying preconditioners for LinearSolve
277
+ algorithms, consult the
278
+ [LinearSolve.jl documentation](https://docs.sciml.ai/LinearSolve/stable/).
279
+ """
280
+ function FastShortcutNLLSPolyalg (; concrete_jac = nothing , linsolve = nothing ,
281
+ precs = DEFAULT_PRECS, adkwargs... )
282
+ algs = (GaussNewton (; concrete_jac, linsolve, precs, adkwargs... ),
283
+ GaussNewton (; concrete_jac, linsolve, precs, linesearch = BackTracking (),
284
+ adkwargs... ),
285
+ LevenbergMarquardt (; concrete_jac, linsolve, precs, adkwargs... ))
286
+ return NonlinearSolvePolyAlgorithm (algs, Val (:NLLS ))
287
+ end
288
+
253
289
# # Defaults
254
290
255
291
function SciMLBase. __init (prob:: NonlinearProblem , :: Nothing , args... ; kwargs... )
@@ -263,10 +299,10 @@ end
263
299
# FIXME : We default to using LM currently. But once we have line searches for GN implemented
264
300
# we should default to a polyalgorithm.
265
301
function SciMLBase. __init (prob:: NonlinearLeastSquaresProblem , :: Nothing , args... ; kwargs... )
266
- return SciMLBase. __init (prob, LevenbergMarquardt (), args... ; kwargs... )
302
+ return SciMLBase. __init (prob, FastShortcutNLLSPolyalg (), args... ; kwargs... )
267
303
end
268
304
269
305
function SciMLBase. __solve (prob:: NonlinearLeastSquaresProblem , :: Nothing , args... ;
270
306
kwargs... )
271
- return SciMLBase. __solve (prob, LevenbergMarquardt (), args... ; kwargs... )
307
+ return SciMLBase. __solve (prob, FastShortcutNLLSPolyalg (), args... ; kwargs... )
272
308
end
0 commit comments