Skip to content

Commit

Permalink
fix: remove uses of LineSearches.jl backtracking
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 21, 2024
1 parent e7e218b commit 14e80e4
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 26 deletions.
6 changes: 3 additions & 3 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 = "3.15.1"
version = "3.15.2"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/NonlinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 5 additions & 15 deletions src/default.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand All @@ -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))
Expand Down Expand Up @@ -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...))
Expand Down
42 changes: 35 additions & 7 deletions test/core/rootfind_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 14e80e4

Please sign in to comment.