Skip to content

Commit 8eac8b5

Browse files
committed
fix: remove uses of LineSearches.jl backtracking
1 parent e7e218b commit 8eac8b5

File tree

4 files changed

+43
-25
lines changed

4 files changed

+43
-25
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "NonlinearSolve"
22
uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
33
authors = ["SciML"]
4-
version = "3.15.1"
4+
version = "3.15.2"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -80,7 +80,7 @@ Hwloc = "3"
8080
InteractiveUtils = "<0.0.1, 1"
8181
LazyArrays = "1.8.2, 2"
8282
LeastSquaresOptim = "0.8.5"
83-
LineSearch = "0.1.2"
83+
LineSearch = "0.1.4"
8484
LineSearches = "7.3"
8585
LinearAlgebra = "1.10"
8686
LinearSolve = "2.35"

src/NonlinearSolve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export NewtonDescent, SteepestDescent, Dogleg, DampedNewtonDescent, GeodesicAcce
176176
## Line Search Algorithms
177177
export LineSearchesJL, LiFukushimaLineSearch # FIXME: deprecated. use LineSearch.jl directly
178178
export Static, HagerZhang, MoreThuente, StrongWolfe, BackTracking # FIXME: deprecated
179-
export NoLineSearch, RobustNonMonotoneLineSearch
179+
export LineSearch, NoLineSearch, RobustNonMonotoneLineSearch
180180
## Trust Region Algorithms
181181
export RadiusUpdateSchemes
182182

src/default.jl

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,7 @@ function RobustMultiNewton(::Type{T} = Float64; concrete_jac = nothing, linsolve
364364
radius_update_scheme = RadiusUpdateSchemes.Bastin),
365365
NewtonRaphson(; concrete_jac, linsolve, precs, autodiff),
366366
NewtonRaphson(; concrete_jac, linsolve, precs,
367-
linesearch = LineSearch.LineSearchesJL(;
368-
method = LineSearches.BackTracking()),
369-
autodiff),
367+
linesearch = LineSearch.BackTracking(), autodiff),
370368
TrustRegion(; concrete_jac, linsolve, precs,
371369
radius_update_scheme = RadiusUpdateSchemes.NLsolve, autodiff),
372370
TrustRegion(; concrete_jac, linsolve, precs,
@@ -407,9 +405,7 @@ function FastShortcutNonlinearPolyalg(
407405
else
408406
algs = (NewtonRaphson(; concrete_jac, linsolve, precs, autodiff),
409407
NewtonRaphson(; concrete_jac, linsolve, precs,
410-
linesearch = LineSearch.LineSearchesJL(;
411-
method = LineSearches.BackTracking()),
412-
autodiff),
408+
linesearch = LineSearch.BackTracking(), autodiff),
413409
TrustRegion(; concrete_jac, linsolve, precs, autodiff),
414410
TrustRegion(; concrete_jac, linsolve, precs,
415411
radius_update_scheme = RadiusUpdateSchemes.Bastin, autodiff))
@@ -430,9 +426,7 @@ function FastShortcutNonlinearPolyalg(
430426
SimpleKlement(),
431427
NewtonRaphson(; concrete_jac, linsolve, precs, autodiff),
432428
NewtonRaphson(; concrete_jac, linsolve, precs,
433-
linesearch = LineSearch.LineSearchesJL(;
434-
method = LineSearches.BackTracking()),
435-
autodiff),
429+
linesearch = LineSearch.BackTracking(), autodiff),
436430
TrustRegion(; concrete_jac, linsolve, precs,
437431
radius_update_scheme = RadiusUpdateSchemes.Bastin, autodiff))
438432
end
@@ -451,9 +445,7 @@ function FastShortcutNonlinearPolyalg(
451445
Klement(; linsolve, precs, autodiff),
452446
NewtonRaphson(; concrete_jac, linsolve, precs, autodiff),
453447
NewtonRaphson(; concrete_jac, linsolve, precs,
454-
linesearch = LineSearch.LineSearchesJL(;
455-
method = LineSearches.BackTracking()),
456-
autodiff),
448+
linesearch = LineSearch.BackTracking(), autodiff),
457449
TrustRegion(; concrete_jac, linsolve, precs, autodiff),
458450
TrustRegion(; concrete_jac, linsolve, precs,
459451
radius_update_scheme = RadiusUpdateSchemes.Bastin, autodiff))
@@ -489,9 +481,7 @@ function FastShortcutNLLSPolyalg(
489481
linsolve, precs, disable_geodesic = Val(true), autodiff, kwargs...),
490482
TrustRegion(; concrete_jac, linsolve, precs, autodiff, kwargs...),
491483
GaussNewton(; concrete_jac, linsolve, precs,
492-
linesearch = LineSearch.LineSearchesJL(;
493-
method = LineSearches.BackTracking()),
494-
autodiff, kwargs...),
484+
linesearch = LineSearch.BackTracking(), autodiff, kwargs...),
495485
TrustRegion(; concrete_jac, linsolve, precs,
496486
radius_update_scheme = RadiusUpdateSchemes.Bastin, autodiff, kwargs...),
497487
LevenbergMarquardt(; linsolve, precs, autodiff, kwargs...))

test/core/rootfind_tests.jl

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,18 @@ end
5454

5555
@testitem "NewtonRaphson" setup=[CoreRootfindTesting] tags=[:core] begin
5656
@testset "LineSearch: $(_nameof(lsmethod)) LineSearch AD: $(_nameof(ad))" for lsmethod in (
57-
Static(), StrongWolfe(), BackTracking(), HagerZhang(), MoreThuente()),
57+
Static(), StrongWolfe(), BackTracking(),
58+
LineSearch.BackTracking, HagerZhang(), MoreThuente()),
5859
ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff())
5960

61+
linesearch = if !(lsmethod isa LineSearch.AbstractLineSearchAlgorithm)
62+
LineSearchesJL(; method = lsmethod, autodiff = ad)
63+
elseif lsmethod <: LineSearch.AbstractLineSearchAlgorithm
64+
lsmethod(; autodiff = ad)
65+
else
66+
lsmethod
67+
end
68+
6069
linesearch = LineSearchesJL(; method = lsmethod, autodiff = ad)
6170
u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0)
6271

@@ -464,13 +473,19 @@ end
464473

465474
@testitem "Broyden" setup=[CoreRootfindTesting] tags=[:core] begin
466475
@testset "LineSearch: $(_nameof(lsmethod)) LineSearch AD: $(_nameof(ad)) Init Jacobian: $(init_jacobian) Update Rule: $(update_rule)" for lsmethod in (
467-
Static(), StrongWolfe(), BackTracking(),
476+
Static(), StrongWolfe(), BackTracking(), LineSearch.BackTracking,
468477
HagerZhang(), MoreThuente(), LiFukushimaLineSearch()),
469478
ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()),
470479
init_jacobian in (Val(:identity), Val(:true_jacobian)),
471480
update_rule in (Val(:good_broyden), Val(:bad_broyden), Val(:diagonal))
472481

473-
linesearch = LineSearchesJL(; method = lsmethod, autodiff = ad)
482+
linesearch = if !(lsmethod isa LineSearch.AbstractLineSearchAlgorithm)
483+
LineSearchesJL(; method = lsmethod, autodiff = ad)
484+
elseif lsmethod <: LineSearch.AbstractLineSearchAlgorithm
485+
lsmethod(; autodiff = ad)
486+
else
487+
lsmethod
488+
end
474489
u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0)
475490

476491
@testset "[OOP] u0: $(typeof(u0))" for u0 in u0s
@@ -514,11 +529,18 @@ end
514529

515530
@testitem "Klement" setup=[CoreRootfindTesting] tags=[:core] begin
516531
@testset "LineSearch: $(_nameof(lsmethod)) LineSearch AD: $(_nameof(ad)) Init Jacobian: $(init_jacobian)" for lsmethod in (
517-
Static(), StrongWolfe(), BackTracking(), HagerZhang(), MoreThuente()),
532+
Static(), StrongWolfe(), BackTracking(),
533+
LineSearch.BackTracking, HagerZhang(), MoreThuente()),
518534
ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff()),
519535
init_jacobian in (Val(:identity), Val(:true_jacobian), Val(:true_jacobian_diagonal))
520536

521-
linesearch = LineSearchesJL(; method = lsmethod, autodiff = ad)
537+
linesearch = if !(lsmethod isa LineSearch.AbstractLineSearchAlgorithm)
538+
LineSearchesJL(; method = lsmethod, autodiff = ad)
539+
elseif lsmethod <: LineSearch.AbstractLineSearchAlgorithm
540+
lsmethod(; autodiff = ad)
541+
else
542+
lsmethod
543+
end
522544
u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0)
523545

524546
@testset "[OOP] u0: $(typeof(u0))" for u0 in u0s
@@ -563,11 +585,17 @@ end
563585

564586
@testitem "LimitedMemoryBroyden" setup=[CoreRootfindTesting] tags=[:core] begin
565587
@testset "LineSearch: $(_nameof(lsmethod)) LineSearch AD: $(_nameof(ad))" for lsmethod in (
566-
Static(), StrongWolfe(), BackTracking(),
588+
Static(), StrongWolfe(), BackTracking(), LineSearch.BackTracking,
567589
HagerZhang(), MoreThuente(), LiFukushimaLineSearch()),
568590
ad in (AutoForwardDiff(), AutoZygote(), AutoFiniteDiff())
569591

570-
linesearch = LineSearchesJL(; method = lsmethod, autodiff = ad)
592+
linesearch = if !(lsmethod isa LineSearch.AbstractLineSearchAlgorithm)
593+
LineSearchesJL(; method = lsmethod, autodiff = ad)
594+
elseif lsmethod <: LineSearch.AbstractLineSearchAlgorithm
595+
lsmethod(; autodiff = ad)
596+
else
597+
lsmethod
598+
end
571599
u0s = ([1.0, 1.0], @SVector[1.0, 1.0], 1.0)
572600

573601
@testset "[OOP] u0: $(typeof(u0))" for u0 in u0s

0 commit comments

Comments
 (0)