@@ -51,31 +51,31 @@ HagerZhang() = LineSearchesJL(; method = LineSearches.HagerZhang())
5151MoreThuente() = LineSearchesJL(; method = LineSearches.MoreThuente())
5252
5353solvers_all = [
54- (; pkg = :nonlinearsolve, type = :general, name = "Default PolyAlg.", solver = Dict(:alg => FastShortcutNonlinearPolyalg(; u0_len = 10))),
55- (; pkg = :nonlinearsolve, type = :NR, name = "Newton Raphson", solver = Dict(:alg => NewtonRaphson())),
56- (; pkg = :nonlinearsolve, type = :NR, name = "NR (HagerZhang)", solver = Dict(:alg => NewtonRaphson(; linesearch = HagerZhang()))),
57- (; pkg = :nonlinearsolve, type = :NR, name = "NR (MoreThuente)", solver = Dict(:alg => NewtonRaphson(; linesearch = MoreThuente()))),
58- (; pkg = :nonlinearsolve, type = :NR, name = "NR (BackTracking)", solver = Dict(:alg => NewtonRaphson(; linesearch = BackTracking()))),
59- (; pkg = :nonlinearsolve, type = :TR, name = "Trust Region", solver = Dict(:alg => TrustRegion())),
60- (; pkg = :nonlinearsolve, type = :TR, name = "TR (NLsolve Update)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.NLsolve))),
61- (; pkg = :nonlinearsolve, type = :TR, name = "TR (Nocedal Wright)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.NocedalWright))),
62- (; pkg = :nonlinearsolve, type = :TR, name = "TR (Hei)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.Hei))),
63- (; pkg = :nonlinearsolve, type = :TR, name = "TR (Yuan)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.Yuan))),
64- (; pkg = :nonlinearsolve, type = :TR, name = "TR (Bastin)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.Bastin))),
65- (; pkg = :nonlinearsolve, type = :TR, name = "TR (Fan)", solver = Dict(:alg => TrustRegion(; radius_update_scheme = RUS.Fan))),
54+ (; pkg = :nonlinearsolve, type = :general, name = "Default PolyAlg.", solver = Dict(:alg => FastShortcutNonlinearPolyalg(; u0_len = 10, linsolve = \ ))),
55+ (; pkg = :nonlinearsolve, type = :NR, name = "Newton Raphson", solver = Dict(:alg => NewtonRaphson(; linsolve = \ ))),
56+ (; pkg = :nonlinearsolve, type = :NR, name = "NR (HagerZhang)", solver = Dict(:alg => NewtonRaphson(; linsolve = \, linesearch = HagerZhang()))),
57+ (; pkg = :nonlinearsolve, type = :NR, name = "NR (MoreThuente)", solver = Dict(:alg => NewtonRaphson(; linsolve = \, linesearch = MoreThuente()))),
58+ (; pkg = :nonlinearsolve, type = :NR, name = "NR (BackTracking)", solver = Dict(:alg => NewtonRaphson(; linsolve = \, linesearch = BackTracking()))),
59+ (; pkg = :nonlinearsolve, type = :TR, name = "Trust Region", solver = Dict(:alg => TrustRegion(; linsolve = \ ))),
60+ (; pkg = :nonlinearsolve, type = :TR, name = "TR (NLsolve Update)", solver = Dict(:alg => TrustRegion(; linsolve = \, radius_update_scheme = RUS.NLsolve))),
61+ (; pkg = :nonlinearsolve, type = :TR, name = "TR (Nocedal Wright)", solver = Dict(:alg => TrustRegion(; linsolve = \, radius_update_scheme = RUS.NocedalWright))),
62+ (; pkg = :nonlinearsolve, type = :TR, name = "TR (Hei)", solver = Dict(:alg => TrustRegion(; linsolve = \, radius_update_scheme = RUS.Hei))),
63+ (; pkg = :nonlinearsolve, type = :TR, name = "TR (Yuan)", solver = Dict(:alg => TrustRegion(; linsolve = \, radius_update_scheme = RUS.Yuan))),
64+ (; pkg = :nonlinearsolve, type = :TR, name = "TR (Bastin)", solver = Dict(:alg => TrustRegion(; linsolve = \, radius_update_scheme = RUS.Bastin))),
65+ (; pkg = :nonlinearsolve, type = :TR, name = "TR (Fan)", solver = Dict(:alg => TrustRegion(; linsolve = \, radius_update_scheme = RUS.Fan))),
6666 (; pkg = :nonlinearsolve, type = :LM, name = "Levenberg-Marquardt", solver = Dict(:alg => LevenbergMarquardt(; linsolve = QRFactorization()))),
6767 (; pkg = :nonlinearsolve, type = :LM, name = "LM with Cholesky", solver = Dict(:alg => LevenbergMarquardt(; linsolve = CholeskyFactorization()))),
6868 (; pkg = :nonlinearsolve, type = :LM, name = "LM (α_geodesic=0.5)", solver = Dict(:alg => LevenbergMarquardt(; linsolve = QRFactorization(), α_geodesic=0.5))),
6969 (; pkg = :nonlinearsolve, type = :LM, name = "LM (α_geodesic=0.5) Chol.", solver = Dict(:alg => LevenbergMarquardt(; linsolve = CholeskyFactorization(), α_geodesic=0.5))),
7070 (; pkg = :nonlinearsolve, type = :LM, name = "LM (no Accln.)", solver = Dict(:alg => LevenbergMarquardt(; linsolve = QRFactorization(), disable_geodesic = Val(true)))),
7171 (; pkg = :nonlinearsolve, type = :LM, name = "LM (no Accln.) Chol.", solver = Dict(:alg => LevenbergMarquardt(; linsolve = CholeskyFactorization(), disable_geodesic = Val(true)))),
72- (; pkg = :nonlinearsolve, type = :general, name = "Pseudo Transient", solver = Dict(:alg => PseudoTransient(; alpha_initial=10.0))),
72+ (; pkg = :nonlinearsolve, type = :general, name = "Pseudo Transient", solver = Dict(:alg => PseudoTransient(; linsolve = \, alpha_initial=10.0))),
7373 (; pkg = :wrapper, type = :general, name = "Powell [MINPACK]", solver = Dict(:alg => CMINPACK(; method=:hybr))),
74- (; pkg = :wrapper, type = :general, name = "LM [MINPACK]", solver = Dict(:alg => CMINPACK(; method=:lm))),
75- (; pkg = :wrapper, type = :general, name = "NR [NLsolve.jl]", solver = Dict(:alg => NLsolveJL(; method=:newton))),
76- (; pkg = :wrapper, type = :general, name = "TR [NLsolve.jl]", solver = Dict(:alg => NLsolveJL())),
77- (; pkg = :wrapper, type = :general, name = "NR [Sundials]", solver = Dict(:alg => KINSOL(; linear_solver = :LapackDense, maxsetupcalls=1))),
78- (; pkg = :wrapper, type = :general, name = "NR LineSearch [Sundials]", solver = Dict(:alg => KINSOL(; globalization_strategy=:LineSearch, maxsetupcalls=1)))
74+ (; pkg = :wrapper, type = :LM, name = "LM [MINPACK]", solver = Dict(:alg => CMINPACK(; method=:lm))),
75+ (; pkg = :wrapper, type = :NR, name = "NR [NLsolve.jl]", solver = Dict(:alg => NLsolveJL(; method=:newton))),
76+ (; pkg = :wrapper, type = :TR, name = "TR [NLsolve.jl]", solver = Dict(:alg => NLsolveJL())),
77+ (; pkg = :wrapper, type = :NR, name = "NR [Sundials]", solver = Dict(:alg => KINSOL(; linear_solver = :LapackDense, maxsetupcalls=1))),
78+ (; pkg = :wrapper, type = :NR, name = "NR LineSearch [Sundials]", solver = Dict(:alg => KINSOL(; linear_solver = :LapackDense, globalization_strategy=:LineSearch, maxsetupcalls=1)))
7979];
8080
8181solver_tracker = [];
@@ -95,22 +95,26 @@ Prepares various helper functions for benchmarking a specific problem.
9595function set_ad_chunksize(solvers, u0)
9696 ck = NonlinearSolve.pickchunksize(u0)
9797 for i in eachindex(solvers)
98- @set! solvers[i].solver[:alg] = __set_ad_chunksize(solvers[i].solver[:alg], ck)
98+ @set! solvers[i].solver[:alg] = __set_ad_chunksize(solvers[i].solver[:alg], ck, length(u0) )
9999 end
100100 return solvers
101101end
102102
103- function __set_ad_chunksize(solver::GeneralizedFirstOrderAlgorithm, ck)
104- ad = AutoPolyesterForwardDiff(; chunksize = ck)
103+ function __set_ad_chunksize(solver::GeneralizedFirstOrderAlgorithm, ck, N)
104+ if N > ck
105+ ad = AutoPolyesterForwardDiff(; chunksize = ck)
106+ else
107+ ad = AutoForwardDiff(; chunksize = ck)
108+ end
105109 return GeneralizedFirstOrderAlgorithm(; solver.descent, solver.linesearch,
106110 solver.trustregion, jvp_autodiff = ad, solver.max_shrink_times, solver.vjp_autodiff,
107111 concrete_jac = solver.concrete_jac, name = solver.name)
108112end
109- function __set_ad_chunksize(solver::NonlinearSolvePolyAlgorithm, ck)
110- algs = [__set_ad_chunksize(alg, ck) for alg in solver.algs]
113+ function __set_ad_chunksize(solver::NonlinearSolvePolyAlgorithm, ck, N )
114+ algs = [__set_ad_chunksize(alg, ck, N ) for alg in solver.algs]
111115 return NonlinearSolvePolyAlgorithm(algs; solver.start_index)
112116end
113- __set_ad_chunksize(solver, ck) = solver
117+ __set_ad_chunksize(solver, ck, N ) = solver
114118
115119# Benchmarks a specific problem, checks which solvers can solve it and their performance
116120function benchmark_problem!(prob_name; solver_tracker=solver_tracker)
@@ -147,7 +151,8 @@ function benchmark_problem!(prob_name; solver_tracker=solver_tracker)
147151
148152 wp_general = WorkPrecisionSet(prob.prob, abstols, reltols,
149153 getfield.(solvers_general, :solver); names=getfield.(solvers_general, :name),
150- numruns=100, error_estimate=:l∞, maxiters=1000)
154+ numruns=100, error_estimate=:l∞, maxiters=1000,
155+ termination_condition = NonlinearSolve.AbsNormTerminationMode(Base.Fix1(maximum, abs)))
151156
152157 push!(wp_general_tracker, prob_name => wp_general)
153158
321326
322327# Benchmarks
323328
324- We here run benchmarks for each of the 23 models.
329+ We here run benchmarks for each of the 23 models.
325330
326331### Problem 1 (Generalized Rosenbrock function)
327332
0 commit comments