diff --git a/Project.toml b/Project.toml index 1651aab2a..725aa5c9d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "NonlinearSolve" uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec" authors = ["SciML"] -version = "3.15.1" +version = "3.15.2" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" @@ -80,7 +80,7 @@ Hwloc = "3" InteractiveUtils = "<0.0.1, 1" LazyArrays = "1.8.2, 2" LeastSquaresOptim = "0.8.5" -LineSearch = "0.1.2" +LineSearch = "0.1.4" LineSearches = "7.3" LinearAlgebra = "1.10" LinearSolve = "2.35" @@ -96,7 +96,7 @@ Pkg = "1.10" PrecompileTools = "1.2" Preferences = "1.4" Printf = "1.10" -Random = "1.91" +Random = "1.10" ReTestItems = "1.24" RecursiveArrayTools = "3.27" Reexport = "1.2" diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index 6babbdbdc..5e2dc5555 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -176,7 +176,7 @@ export NewtonDescent, SteepestDescent, Dogleg, DampedNewtonDescent, GeodesicAcce ## Line Search Algorithms export LineSearchesJL, LiFukushimaLineSearch # FIXME: deprecated. use LineSearch.jl directly export Static, HagerZhang, MoreThuente, StrongWolfe, BackTracking # FIXME: deprecated -export NoLineSearch, RobustNonMonotoneLineSearch +export LineSearch, NoLineSearch, RobustNonMonotoneLineSearch ## Trust Region Algorithms export RadiusUpdateSchemes diff --git a/src/default.jl b/src/default.jl index 5623c553f..c0924e2ff 100644 --- a/src/default.jl +++ b/src/default.jl @@ -364,9 +364,7 @@ function RobustMultiNewton(::Type{T} = Float64; concrete_jac = nothing, linsolve radius_update_scheme = RadiusUpdateSchemes.Bastin), NewtonRaphson(; concrete_jac, linsolve, precs, autodiff), NewtonRaphson(; concrete_jac, linsolve, precs, - linesearch = LineSearch.LineSearchesJL(; - method = LineSearches.BackTracking()), - autodiff), + linesearch = LineSearch.BackTracking(), autodiff), TrustRegion(; concrete_jac, linsolve, precs, radius_update_scheme = RadiusUpdateSchemes.NLsolve, autodiff), TrustRegion(; concrete_jac, linsolve, precs, @@ -407,9 +405,7 @@ function FastShortcutNonlinearPolyalg( else algs = (NewtonRaphson(; concrete_jac, linsolve, precs, autodiff), NewtonRaphson(; concrete_jac, linsolve, precs, - linesearch = LineSearch.LineSearchesJL(; - method = LineSearches.BackTracking()), - autodiff), + linesearch = LineSearch.BackTracking(), autodiff), TrustRegion(; concrete_jac, linsolve, precs, autodiff), TrustRegion(; concrete_jac, linsolve, precs, radius_update_scheme = RadiusUpdateSchemes.Bastin, autodiff)) @@ -430,9 +426,7 @@ function FastShortcutNonlinearPolyalg( SimpleKlement(), NewtonRaphson(; concrete_jac, linsolve, precs, autodiff), NewtonRaphson(; concrete_jac, linsolve, precs, - linesearch = LineSearch.LineSearchesJL(; - method = LineSearches.BackTracking()), - autodiff), + linesearch = LineSearch.BackTracking(), autodiff), TrustRegion(; concrete_jac, linsolve, precs, radius_update_scheme = RadiusUpdateSchemes.Bastin, autodiff)) end @@ -451,9 +445,7 @@ function FastShortcutNonlinearPolyalg( Klement(; linsolve, precs, autodiff), NewtonRaphson(; concrete_jac, linsolve, precs, autodiff), NewtonRaphson(; concrete_jac, linsolve, precs, - linesearch = LineSearch.LineSearchesJL(; - method = LineSearches.BackTracking()), - autodiff), + linesearch = LineSearch.BackTracking(), autodiff), TrustRegion(; concrete_jac, linsolve, precs, autodiff), TrustRegion(; concrete_jac, linsolve, precs, radius_update_scheme = RadiusUpdateSchemes.Bastin, autodiff)) @@ -489,9 +481,7 @@ function FastShortcutNLLSPolyalg( linsolve, precs, disable_geodesic = Val(true), autodiff, kwargs...), TrustRegion(; concrete_jac, linsolve, precs, autodiff, kwargs...), GaussNewton(; concrete_jac, linsolve, precs, - linesearch = LineSearch.LineSearchesJL(; - method = LineSearches.BackTracking()), - autodiff, kwargs...), + linesearch = LineSearch.BackTracking(), autodiff, kwargs...), TrustRegion(; concrete_jac, linsolve, precs, radius_update_scheme = RadiusUpdateSchemes.Bastin, autodiff, kwargs...), LevenbergMarquardt(; linsolve, precs, autodiff, kwargs...)) diff --git a/test/core/rootfind_tests.jl b/test/core/rootfind_tests.jl index 6a56c6ac6..b4219539c 100644 --- a/test/core/rootfind_tests.jl +++ b/test/core/rootfind_tests.jl @@ -54,9 +54,18 @@ end @testitem "NewtonRaphson" setup=[CoreRootfindTesting] tags=[:core] begin @testset "LineSearch: $(_nameof(lsmethod)) LineSearch AD: $(_nameof(ad))" for lsmethod in ( - Static(), StrongWolfe(), BackTracking(), HagerZhang(), MoreThuente()), + Static(), StrongWolfe(), BackTracking(), + LineSearch.BackTracking, HagerZhang(), MoreThuente()), ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()) + linesearch = if !(lsmethod isa LineSearch.AbstractLineSearchAlgorithm) + LineSearchesJL(; method = lsmethod, autodiff = ad) + elseif lsmethod <: LineSearch.AbstractLineSearchAlgorithm + lsmethod(; autodiff = ad) + else + lsmethod + end + linesearch = LineSearchesJL(; method = lsmethod, autodiff = ad) u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0) @@ -464,13 +473,19 @@ end @testitem "Broyden" setup=[CoreRootfindTesting] tags=[:core] begin @testset "LineSearch: $(_nameof(lsmethod)) LineSearch AD: $(_nameof(ad)) Init Jacobian: $(init_jacobian) Update Rule: $(update_rule)" for lsmethod in ( - Static(), StrongWolfe(), BackTracking(), + Static(), StrongWolfe(), BackTracking(), LineSearch.BackTracking, HagerZhang(), MoreThuente(), LiFukushimaLineSearch()), ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()), init_jacobian in (Val(:identity), Val(:true_jacobian)), update_rule in (Val(:good_broyden), Val(:bad_broyden), Val(:diagonal)) - linesearch = LineSearchesJL(; method = lsmethod, autodiff = ad) + linesearch = if !(lsmethod isa LineSearch.AbstractLineSearchAlgorithm) + LineSearchesJL(; method = lsmethod, autodiff = ad) + elseif lsmethod <: LineSearch.AbstractLineSearchAlgorithm + lsmethod(; autodiff = ad) + else + lsmethod + end u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0) @testset "[OOP] u0: $(typeof(u0))" for u0 in u0s @@ -514,11 +529,18 @@ end @testitem "Klement" setup=[CoreRootfindTesting] tags=[:core] begin @testset "LineSearch: $(_nameof(lsmethod)) LineSearch AD: $(_nameof(ad)) Init Jacobian: $(init_jacobian)" for lsmethod in ( - Static(), StrongWolfe(), BackTracking(), HagerZhang(), MoreThuente()), + Static(), StrongWolfe(), BackTracking(), + LineSearch.BackTracking, HagerZhang(), MoreThuente()), ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()), init_jacobian in (Val(:identity), Val(:true_jacobian), Val(:true_jacobian_diagonal)) - linesearch = LineSearchesJL(; method = lsmethod, autodiff = ad) + linesearch = if !(lsmethod isa LineSearch.AbstractLineSearchAlgorithm) + LineSearchesJL(; method = lsmethod, autodiff = ad) + elseif lsmethod <: LineSearch.AbstractLineSearchAlgorithm + lsmethod(; autodiff = ad) + else + lsmethod + end u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0) @testset "[OOP] u0: $(typeof(u0))" for u0 in u0s @@ -563,11 +585,17 @@ end @testitem "LimitedMemoryBroyden" setup=[CoreRootfindTesting] tags=[:core] begin @testset "LineSearch: $(_nameof(lsmethod)) LineSearch AD: $(_nameof(ad))" for lsmethod in ( - Static(), StrongWolfe(), BackTracking(), + Static(), StrongWolfe(), BackTracking(), LineSearch.BackTracking, HagerZhang(), MoreThuente(), LiFukushimaLineSearch()), ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()) - linesearch = LineSearchesJL(; method = lsmethod, autodiff = ad) + linesearch = if !(lsmethod isa LineSearch.AbstractLineSearchAlgorithm) + LineSearchesJL(; method = lsmethod, autodiff = ad) + elseif lsmethod <: LineSearch.AbstractLineSearchAlgorithm + lsmethod(; autodiff = ad) + else + lsmethod + end u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0) @testset "[OOP] u0: $(typeof(u0))" for u0 in u0s