From 74c0bdd6695d85436a591319aaacad6676424961 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Sat, 21 Jan 2023 12:12:06 -0500 Subject: [PATCH 1/2] Precompile trust region only on v1.7+ Fixes https://github.com/SciML/NonlinearSolve.jl/issues/121 --- src/NonlinearSolve.jl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index 305d9e5aa..1f0ca822f 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -38,13 +38,21 @@ import SnoopPrecompile SnoopPrecompile.@precompile_all_calls begin for T in (Float32, Float64) prob = NonlinearProblem{false}((u, p) -> u .* u .- p, T(0.1), T(2)) - for alg in (NewtonRaphson,) - solve(prob, alg(), abstol = T(1e-2)) + + precompile_algs = if VERSION >= v"1.7" + (NewtonRaphson(), TrustRegion()) + else + (NewtonRaphson(),) + end + + + for alg in precompile_algs + solve(prob, alg, abstol = T(1e-2)) end prob = NonlinearProblem{true}((du, u, p) -> du[1] = u[1] * u[1] - p[1], T[0.1], T[2]) - for alg in (NewtonRaphson,) - solve(prob, alg(), abstol = T(1e-2)) + for alg in precompile_algs + solve(prob, alg, abstol = T(1e-2)) end end end From dab302ca707d20cd95571e7b57f80f1bf33f729f Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Sat, 21 Jan 2023 12:43:02 -0500 Subject: [PATCH 2/2] format --- src/NonlinearSolve.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NonlinearSolve.jl b/src/NonlinearSolve.jl index 1f0ca822f..2719a5c56 100644 --- a/src/NonlinearSolve.jl +++ b/src/NonlinearSolve.jl @@ -45,7 +45,6 @@ SnoopPrecompile.@precompile_all_calls begin for T in (Float32, Float64) (NewtonRaphson(),) end - for alg in precompile_algs solve(prob, alg, abstol = T(1e-2)) end