Skip to content

Commit

Permalink
Merge branch 'master' into as/fix-sii
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas authored Nov 18, 2024
2 parents 73e381f + 7f90cf4 commit 3b6f21a
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 52 deletions.
4 changes: 2 additions & 2 deletions 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 = "4.1.0"
version = "4.2.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down Expand Up @@ -96,9 +96,9 @@ NonlinearSolveSpectralMethods = "1"
OrdinaryDiffEqTsit5 = "1.1.0"
PETSc = "0.3"
Pkg = "1.10"
PolyesterForwardDiff = "0.1"
PrecompileTools = "1.2"
Preferences = "1.4"
PolyesterForwardDiff = "0.1"
Random = "1.10"
ReTestItems = "1.24"
Reexport = "1.2"
Expand Down
3 changes: 2 additions & 1 deletion lib/NonlinearSolveFirstOrder/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NonlinearSolveFirstOrder"
uuid = "5959db7a-ea39-4486-b5fe-2dd0bf03d60d"
authors = ["Avik Pal <[email protected]> and contributors"]
version = "1.0.0"
version = "1.1.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand All @@ -13,6 +13,7 @@ FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
LineSearch = "87fe0de2-c867-4266-b59a-2f0a94fc965b"
MaybeInplace = "bb5d69b7-63fc-4a16-80bd-7e42200c7bdb"
NonlinearSolveBase = "be0214bd-f91f-a760-ac4e-3421ce2b2da0"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Expand Down
8 changes: 7 additions & 1 deletion lib/NonlinearSolveFirstOrder/src/NonlinearSolveFirstOrder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ using Setfield: @set!
using ADTypes: ADTypes
using ArrayInterface: ArrayInterface
using LinearAlgebra: LinearAlgebra, Diagonal, dot, diagind
using LineSearch: BackTracking
using StaticArraysCore: SArray

using CommonSolve: CommonSolve
Expand All @@ -19,7 +20,7 @@ using NonlinearSolveBase: NonlinearSolveBase, AbstractNonlinearSolveAlgorithm,
AbstractDampingFunctionCache, AbstractTrustRegionMethod,
AbstractTrustRegionMethodCache,
Utils, InternalAPI, get_timer_output, @static_timeit,
update_trace!, L2_NORM,
update_trace!, L2_NORM, NonlinearSolvePolyAlgorithm,
NewtonDescent, DampedNewtonDescent, GeodesicAcceleration,
Dogleg
using SciMLBase: SciMLBase, AbstractNonlinearProblem, NLStats, ReturnCode,
Expand All @@ -36,6 +37,8 @@ include("levenberg_marquardt.jl")
include("trust_region.jl")
include("pseudo_transient.jl")

include("poly_algs.jl")

include("solve.jl")

@setup_workload begin
Expand Down Expand Up @@ -100,4 +103,7 @@ export RadiusUpdateSchemes

export GeneralizedFirstOrderAlgorithm

# Polyalgorithms
export RobustMultiNewton

end
44 changes: 44 additions & 0 deletions lib/NonlinearSolveFirstOrder/src/poly_algs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""
RobustMultiNewton(
::Type{T} = Float64;
concrete_jac = nothing,
linsolve = nothing,
autodiff = nothing, vjp_autodiff = nothing, jvp_autodiff = nothing
)
A polyalgorithm focused on robustness. It uses a mixture of Newton methods with different
globalizing techniques (trust region updates, line searches, etc.) in order to find a
method that is able to adequately solve the minimization problem.
Basically, if this algorithm fails, then "most" good ways of solving your problem fail and
you may need to think about reformulating the model (either there is an issue with the model,
or more precision / more stable linear solver choice is required).
### Arguments
- `T`: The eltype of the initial guess. It is only used to check if some of the algorithms
are compatible with the problem type. Defaults to `Float64`.
"""
function RobustMultiNewton(
::Type{T} = Float64;
concrete_jac = nothing,
linsolve = nothing,
autodiff = nothing, vjp_autodiff = nothing, jvp_autodiff = nothing
) where {T}
common_kwargs = (; concrete_jac, linsolve, autodiff, vjp_autodiff, jvp_autodiff)
if T <: Complex # Let's atleast have something here for complex numbers
algs = (
NewtonRaphson(; common_kwargs...),
)
else
algs = (
TrustRegion(; common_kwargs...),
TrustRegion(; common_kwargs..., radius_update_scheme = RUS.Bastin),
NewtonRaphson(; common_kwargs...),
NewtonRaphson(; common_kwargs..., linesearch = BackTracking()),
TrustRegion(; common_kwargs..., radius_update_scheme = RUS.NLsolve),
TrustRegion(; common_kwargs..., radius_update_scheme = RUS.Fan)
)
end
return NonlinearSolvePolyAlgorithm(algs)
end
5 changes: 2 additions & 3 deletions src/NonlinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using StaticArraysCore: StaticArray

# Default Algorithm
using NonlinearSolveFirstOrder: NewtonRaphson, TrustRegion, LevenbergMarquardt, GaussNewton,
RUS
RUS, RobustMultiNewton
using NonlinearSolveQuasiNewton: Broyden, Klement
using SimpleNonlinearSolve: SimpleBroyden, SimpleKlement

Expand Down Expand Up @@ -125,8 +125,7 @@ end
@reexport using LinearSolve

# Poly Algorithms
export NonlinearSolvePolyAlgorithm,
RobustMultiNewton, FastShortcutNonlinearPolyalg, FastShortcutNLLSPolyalg
export NonlinearSolvePolyAlgorithm, FastShortcutNonlinearPolyalg, FastShortcutNLLSPolyalg

# Extension Algorithms
export LeastSquaresOptimJL, FastLevenbergMarquardtJL, NLsolveJL, NLSolversJL,
Expand Down
45 changes: 0 additions & 45 deletions src/poly_algs.jl
Original file line number Diff line number Diff line change
@@ -1,48 +1,3 @@
"""
RobustMultiNewton(
::Type{T} = Float64;
concrete_jac = nothing,
linsolve = nothing,
autodiff = nothing, vjp_autodiff = nothing, jvp_autodiff = nothing
)
A polyalgorithm focused on robustness. It uses a mixture of Newton methods with different
globalizing techniques (trust region updates, line searches, etc.) in order to find a
method that is able to adequately solve the minimization problem.
Basically, if this algorithm fails, then "most" good ways of solving your problem fail and
you may need to think about reformulating the model (either there is an issue with the model,
or more precision / more stable linear solver choice is required).
### Arguments
- `T`: The eltype of the initial guess. It is only used to check if some of the algorithms
are compatible with the problem type. Defaults to `Float64`.
"""
function RobustMultiNewton(
::Type{T} = Float64;
concrete_jac = nothing,
linsolve = nothing,
autodiff = nothing, vjp_autodiff = nothing, jvp_autodiff = nothing
) where {T}
common_kwargs = (; concrete_jac, linsolve, autodiff, vjp_autodiff, jvp_autodiff)
if T <: Complex # Let's atleast have something here for complex numbers
algs = (
NewtonRaphson(; common_kwargs...),
)
else
algs = (
TrustRegion(; common_kwargs...),
TrustRegion(; common_kwargs..., radius_update_scheme = RUS.Bastin),
NewtonRaphson(; common_kwargs...),
NewtonRaphson(; common_kwargs..., linesearch = BackTracking()),
TrustRegion(; common_kwargs..., radius_update_scheme = RUS.NLsolve),
TrustRegion(; common_kwargs..., radius_update_scheme = RUS.Fan)
)
end
return NonlinearSolvePolyAlgorithm(algs)
end

"""
FastShortcutNonlinearPolyalg(
::Type{T} = Float64;
Expand Down

0 comments on commit 3b6f21a

Please sign in to comment.