@@ -51,31 +51,31 @@ HagerZhang() = LineSearchesJL(; method = LineSearches.HagerZhang())
51
51
MoreThuente() = LineSearchesJL(; method = LineSearches.MoreThuente())
52
52
53
53
solvers_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))),
66
66
(; pkg = :nonlinearsolve, type = :LM, name = "Levenberg-Marquardt", solver = Dict(:alg => LevenbergMarquardt(; linsolve = QRFactorization()))),
67
67
(; pkg = :nonlinearsolve, type = :LM, name = "LM with Cholesky", solver = Dict(:alg => LevenbergMarquardt(; linsolve = CholeskyFactorization()))),
68
68
(; pkg = :nonlinearsolve, type = :LM, name = "LM (α_geodesic=0.5)", solver = Dict(:alg => LevenbergMarquardt(; linsolve = QRFactorization(), α_geodesic=0.5))),
69
69
(; pkg = :nonlinearsolve, type = :LM, name = "LM (α_geodesic=0.5) Chol.", solver = Dict(:alg => LevenbergMarquardt(; linsolve = CholeskyFactorization(), α_geodesic=0.5))),
70
70
(; pkg = :nonlinearsolve, type = :LM, name = "LM (no Accln.)", solver = Dict(:alg => LevenbergMarquardt(; linsolve = QRFactorization(), disable_geodesic = Val(true)))),
71
71
(; 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))),
73
73
(; 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)))
79
79
];
80
80
81
81
solver_tracker = [];
@@ -95,22 +95,26 @@ Prepares various helper functions for benchmarking a specific problem.
95
95
function set_ad_chunksize(solvers, u0)
96
96
ck = NonlinearSolve.pickchunksize(u0)
97
97
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) )
99
99
end
100
100
return solvers
101
101
end
102
102
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
105
109
return GeneralizedFirstOrderAlgorithm(; solver.descent, solver.linesearch,
106
110
solver.trustregion, jvp_autodiff = ad, solver.max_shrink_times, solver.vjp_autodiff,
107
111
concrete_jac = solver.concrete_jac, name = solver.name)
108
112
end
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]
111
115
return NonlinearSolvePolyAlgorithm(algs; solver.start_index)
112
116
end
113
- __set_ad_chunksize(solver, ck) = solver
117
+ __set_ad_chunksize(solver, ck, N ) = solver
114
118
115
119
# Benchmarks a specific problem, checks which solvers can solve it and their performance
116
120
function benchmark_problem!(prob_name; solver_tracker=solver_tracker)
@@ -147,7 +151,8 @@ function benchmark_problem!(prob_name; solver_tracker=solver_tracker)
147
151
148
152
wp_general = WorkPrecisionSet(prob.prob, abstols, reltols,
149
153
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)))
151
156
152
157
push!(wp_general_tracker, prob_name => wp_general)
153
158
321
326
322
327
# Benchmarks
323
328
324
- We here run benchmarks for each of the 23 models.
329
+ We here run benchmarks for each of the 23 models.
325
330
326
331
### Problem 1 (Generalized Rosenbrock function)
327
332
0 commit comments