|
1 | 1 | # This file only include the algorithm struct to be exported by NonlinearSolve.jl. The main
|
2 | 2 | # functionality is implemented as package extensions
|
3 |
| -# """ |
4 |
| -# LeastSquaresOptimJL(alg = :lm; linsolve = nothing, autodiff::Symbol = :central) |
5 |
| - |
6 |
| -# Wrapper over [LeastSquaresOptim.jl](https://github.com/matthieugomez/LeastSquaresOptim.jl) |
7 |
| -# for solving `NonlinearLeastSquaresProblem`. |
8 |
| - |
9 |
| -# ## Arguments: |
10 |
| - |
11 |
| -# - `alg`: Algorithm to use. Can be `:lm` or `:dogleg`. |
12 |
| -# - `linsolve`: Linear solver to use. Can be `:qr`, `:cholesky` or `:lsmr`. If `nothing`, |
13 |
| -# then `LeastSquaresOptim.jl` will choose the best linear solver based on the Jacobian |
14 |
| -# structure. |
15 |
| -# - `autodiff`: Automatic differentiation / Finite Differences. Can be `:central` or |
16 |
| -# `:forward`. |
17 |
| - |
18 |
| -# !!! note |
19 |
| - |
20 |
| -# This algorithm is only available if `LeastSquaresOptim.jl` is installed. |
21 |
| -# """ |
22 |
| -# struct LeastSquaresOptimJL{alg, linsolve} <: AbstractNonlinearSolveExtensionAlgorithm |
23 |
| -# autodiff::Symbol |
24 |
| -# end |
25 |
| - |
26 |
| -# function LeastSquaresOptimJL(alg = :lm; linsolve = nothing, autodiff::Symbol = :central) |
27 |
| -# @assert alg in (:lm, :dogleg) |
28 |
| -# @assert linsolve === nothing || linsolve in (:qr, :cholesky, :lsmr) |
29 |
| -# @assert autodiff in (:central, :forward) |
30 |
| - |
31 |
| -# if Base.get_extension(@__MODULE__, :NonlinearSolveLeastSquaresOptimExt) === nothing |
32 |
| -# error("LeastSquaresOptimJL requires LeastSquaresOptim.jl to be loaded") |
33 |
| -# end |
34 |
| - |
35 |
| -# return LeastSquaresOptimJL{alg, linsolve}(autodiff) |
36 |
| -# end |
37 |
| - |
38 |
| -# """ |
39 |
| -# FastLevenbergMarquardtJL(linsolve = :cholesky; autodiff = nothing) |
40 |
| - |
41 |
| -# Wrapper over [FastLevenbergMarquardt.jl](https://github.com/kamesy/FastLevenbergMarquardt.jl) |
42 |
| -# for solving `NonlinearLeastSquaresProblem`. |
43 |
| - |
44 |
| -# !!! warning |
45 |
| - |
46 |
| -# This is not really the fastest solver. It is called that since the original package |
47 |
| -# is called "Fast". `LevenbergMarquardt()` is almost always a better choice. |
48 |
| - |
49 |
| -# ## Arguments: |
50 |
| - |
51 |
| -# - `linsolve`: Linear solver to use. Can be `:qr` or `:cholesky`. |
52 |
| -# - `autodiff`: determines the backend used for the Jacobian. Note that this argument is |
53 |
| -# ignored if an analytical Jacobian is passed, as that will be used instead. Defaults to |
54 |
| -# `nothing` which means that a default is selected according to the problem specification! |
55 |
| -# Valid choices are `nothing`, `AutoForwardDiff` or `AutoFiniteDiff`. |
56 |
| - |
57 |
| -# !!! note |
58 |
| - |
59 |
| -# This algorithm is only available if `FastLevenbergMarquardt.jl` is installed. |
60 |
| -# """ |
61 |
| -# @concrete struct FastLevenbergMarquardtJL{linsolve} <: AbstractNonlinearSolveExtensionAlgorithm |
62 |
| -# ad |
63 |
| -# factor |
64 |
| -# factoraccept |
65 |
| -# factorreject |
66 |
| -# factorupdate::Symbol |
67 |
| -# minscale |
68 |
| -# maxscale |
69 |
| -# minfactor |
70 |
| -# maxfactor |
71 |
| -# end |
72 |
| - |
73 |
| -# function set_ad(alg::FastLevenbergMarquardtJL{linsolve}, ad) where {linsolve} |
74 |
| -# return FastLevenbergMarquardtJL{linsolve}(ad, alg.factor, alg.factoraccept, |
75 |
| -# alg.factorreject, alg.factorupdate, alg.minscale, alg.maxscale, alg.minfactor, |
76 |
| -# alg.maxfactor) |
77 |
| -# end |
78 |
| - |
79 |
| -# function FastLevenbergMarquardtJL(linsolve::Symbol = :cholesky; factor = 1e-6, |
80 |
| -# factoraccept = 13.0, factorreject = 3.0, factorupdate = :marquardt, |
81 |
| -# minscale = 1e-12, maxscale = 1e16, minfactor = 1e-28, maxfactor = 1e32, |
82 |
| -# autodiff = nothing) |
83 |
| -# @assert linsolve in (:qr, :cholesky) |
84 |
| -# @assert factorupdate in (:marquardt, :nielson) |
85 |
| -# @assert autodiff === nothing || autodiff isa AutoFiniteDiff || |
86 |
| -# autodiff isa AutoForwardDiff |
87 |
| - |
88 |
| -# if Base.get_extension(@__MODULE__, :NonlinearSolveFastLevenbergMarquardtExt) === nothing |
89 |
| -# error("FastLevenbergMarquardtJL requires FastLevenbergMarquardt.jl to be loaded") |
90 |
| -# end |
91 |
| - |
92 |
| -# return FastLevenbergMarquardtJL{linsolve}(autodiff, factor, factoraccept, factorreject, |
93 |
| -# factorupdate, minscale, maxscale, minfactor, maxfactor) |
94 |
| -# end |
| 3 | +""" |
| 4 | + LeastSquaresOptimJL(alg = :lm; linsolve = nothing, autodiff::Symbol = :central) |
| 5 | +
|
| 6 | +Wrapper over [LeastSquaresOptim.jl](https://github.com/matthieugomez/LeastSquaresOptim.jl) |
| 7 | +for solving `NonlinearLeastSquaresProblem`. |
| 8 | +
|
| 9 | +### Arguments |
| 10 | +
|
| 11 | + - `alg`: Algorithm to use. Can be `:lm` or `:dogleg`. |
| 12 | +
|
| 13 | +### Keyword Arguments |
| 14 | +
|
| 15 | + - `linsolve`: Linear solver to use. Can be `:qr`, `:cholesky` or `:lsmr`. If `nothing`, |
| 16 | + then `LeastSquaresOptim.jl` will choose the best linear solver based on the Jacobian |
| 17 | + structure. |
| 18 | + - `autodiff`: Automatic differentiation / Finite Differences. Can be `:central` or |
| 19 | + `:forward`. |
| 20 | +
|
| 21 | +!!! note |
| 22 | +
|
| 23 | + This algorithm is only available if `LeastSquaresOptim.jl` is installed. |
| 24 | +""" |
| 25 | +struct LeastSquaresOptimJL{alg, linsolve} <: AbstractNonlinearSolveExtensionAlgorithm |
| 26 | + autodiff |
| 27 | +end |
| 28 | + |
| 29 | +function LeastSquaresOptimJL(alg = :lm; linsolve = nothing, autodiff = :central) |
| 30 | + @assert alg in (:lm, :dogleg) |
| 31 | + @assert linsolve === nothing || linsolve in (:qr, :cholesky, :lsmr) |
| 32 | + autodiff isa Symbol && @assert autodiff in (:central, :forward) |
| 33 | + |
| 34 | + if Base.get_extension(@__MODULE__, :NonlinearSolveLeastSquaresOptimExt) === nothing |
| 35 | + error("LeastSquaresOptimJL requires LeastSquaresOptim.jl to be loaded") |
| 36 | + end |
| 37 | + |
| 38 | + return LeastSquaresOptimJL{alg, linsolve}(autodiff) |
| 39 | +end |
| 40 | + |
| 41 | +""" |
| 42 | + FastLevenbergMarquardtJL(linsolve::Symbol = :cholesky; factor = 1e-6, |
| 43 | + factoraccept = 13.0, factorreject = 3.0, factorupdate = :marquardt, |
| 44 | + minscale = 1e-12, maxscale = 1e16, minfactor = 1e-28, maxfactor = 1e32, |
| 45 | + autodiff = nothing) |
| 46 | +
|
| 47 | +Wrapper over [FastLevenbergMarquardt.jl](https://github.com/kamesy/FastLevenbergMarquardt.jl) |
| 48 | +for solving `NonlinearLeastSquaresProblem`. For details about the other keyword arguments |
| 49 | +see the documentation for `FastLevenbergMarquardt.jl`. |
| 50 | +
|
| 51 | +!!! warning |
| 52 | +
|
| 53 | + This is not really the fastest solver. It is called that since the original package |
| 54 | + is called "Fast". `LevenbergMarquardt()` is almost always a better choice. |
| 55 | +
|
| 56 | +### Arguments |
| 57 | +
|
| 58 | + - `linsolve`: Linear solver to use. Can be `:qr` or `:cholesky`. |
| 59 | +
|
| 60 | +### Keyword Arguments |
| 61 | +
|
| 62 | + - `autodiff`: determines the backend used for the Jacobian. Note that this argument is |
| 63 | + ignored if an analytical Jacobian is passed, as that will be used instead. Defaults to |
| 64 | + `nothing` which means that a default is selected according to the problem specification! |
| 65 | +
|
| 66 | +!!! note |
| 67 | +
|
| 68 | + This algorithm is only available if `FastLevenbergMarquardt.jl` is installed. |
| 69 | +""" |
| 70 | +@concrete struct FastLevenbergMarquardtJL{linsolve} <: AbstractNonlinearSolveExtensionAlgorithm |
| 71 | + autodiff |
| 72 | + factor |
| 73 | + factoraccept |
| 74 | + factorreject |
| 75 | + factorupdate::Symbol |
| 76 | + minscale |
| 77 | + maxscale |
| 78 | + minfactor |
| 79 | + maxfactor |
| 80 | +end |
| 81 | + |
| 82 | +function FastLevenbergMarquardtJL(linsolve::Symbol = :cholesky; factor = 1e-6, |
| 83 | + factoraccept = 13.0, factorreject = 3.0, factorupdate = :marquardt, |
| 84 | + minscale = 1e-12, maxscale = 1e16, minfactor = 1e-28, maxfactor = 1e32, |
| 85 | + autodiff = nothing) |
| 86 | + @assert linsolve in (:qr, :cholesky) |
| 87 | + @assert factorupdate in (:marquardt, :nielson) |
| 88 | + |
| 89 | + if Base.get_extension(@__MODULE__, :NonlinearSolveFastLevenbergMarquardtExt) === nothing |
| 90 | + error("FastLevenbergMarquardtJL requires FastLevenbergMarquardt.jl to be loaded") |
| 91 | + end |
| 92 | + |
| 93 | + return FastLevenbergMarquardtJL{linsolve}(autodiff, factor, factoraccept, factorreject, |
| 94 | + factorupdate, minscale, maxscale, minfactor, maxfactor) |
| 95 | +end |
95 | 96 |
|
96 | 97 | """
|
97 | 98 | CMINPACK(; method::Symbol = :auto, autodiff = missing)
|
@@ -134,6 +135,10 @@ then the following methods are allowed:
|
134 | 135 |
|
135 | 136 | The default choice of `:auto` selects `:hybr` for NonlinearProblem and `:lm` for
|
136 | 137 | NonlinearLeastSquaresProblem.
|
| 138 | +
|
| 139 | +!!! note |
| 140 | +
|
| 141 | + This algorithm is only available if `MINPACK.jl` is installed. |
137 | 142 | """
|
138 | 143 | @concrete struct CMINPACK <: AbstractNonlinearSolveExtensionAlgorithm
|
139 | 144 | show_trace::Bool
|
@@ -206,6 +211,10 @@ Choices for methods in `NLsolveJL`:
|
206 | 211 |
|
207 | 212 | For more information on these arguments, consult the
|
208 | 213 | [NLsolve.jl documentation](https://github.com/JuliaNLSolvers/NLsolve.jl).
|
| 214 | +
|
| 215 | +!!! note |
| 216 | +
|
| 217 | + This algorithm is only available if `NLsolve.jl` is installed. |
209 | 218 | """
|
210 | 219 | @concrete struct NLsolveJL <: AbstractNonlinearSolveExtensionAlgorithm
|
211 | 220 | method::Symbol
|
@@ -289,6 +298,10 @@ Fixed Point Problems. We allow using this algorithm to solve root finding proble
|
289 | 298 |
|
290 | 299 | [1] N. Lepage-Saucier, Alternating cyclic extrapolation methods for optimization algorithms,
|
291 | 300 | arXiv:2104.04974 (2021). https://arxiv.org/abs/2104.04974.
|
| 301 | +
|
| 302 | +!!! note |
| 303 | +
|
| 304 | + This algorithm is only available if `SpeedMapping.jl` is installed. |
292 | 305 | """
|
293 | 306 | @concrete struct SpeedMappingJL <: AbstractNonlinearSolveExtensionAlgorithm
|
294 | 307 | σ_min
|
@@ -337,6 +350,10 @@ problems as well.
|
337 | 350 | `:SEA` and `:VEA`. For `:SEA` and `:VEA`, this must be a multiple of `2`.
|
338 | 351 | - `replace_invalids`: The method to use for replacing invalid iterates. Can be
|
339 | 352 | `:ReplaceInvalids`, `:ReplaceVector` or `:NoAction`.
|
| 353 | +
|
| 354 | +!!! note |
| 355 | +
|
| 356 | + This algorithm is only available if `FixedPointAcceleration.jl` is installed. |
340 | 357 | """
|
341 | 358 | @concrete struct FixedPointAccelerationJL <: AbstractNonlinearSolveExtensionAlgorithm
|
342 | 359 | algorithm::Symbol
|
|
411 | 428 | - `:pseudotransient`: Pseudo transient method.
|
412 | 429 | - `:secant`: Secant method for scalar equations.
|
413 | 430 | - `:anderson`: Anderson acceleration for fixed point iterations.
|
| 431 | +
|
| 432 | +!!! note |
| 433 | +
|
| 434 | + This algorithm is only available if `SIAMFANLEquations.jl` is installed. |
414 | 435 | """
|
415 | 436 | @concrete struct SIAMFANLEquationsJL{L <: Union{Symbol, Nothing}} <:
|
416 | 437 | AbstractNonlinearSolveExtensionAlgorithm
|
|
0 commit comments