From 6c4cf4d69ffb2e5915a169b2dc74f97db0fb79cb Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Thu, 6 Apr 2023 11:32:47 -0400 Subject: [PATCH] Use a mutable struct instead of Dict for Safe termination --- lib/SimpleNonlinearSolve/.gitignore | 2 +- lib/SimpleNonlinearSolve/Project.toml | 2 +- lib/SimpleNonlinearSolve/ext/SimpleBatchedNonlinearSolveExt.jl | 3 ++- lib/SimpleNonlinearSolve/src/broyden.jl | 3 ++- lib/SimpleNonlinearSolve/src/lbroyden.jl | 3 ++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/SimpleNonlinearSolve/.gitignore b/lib/SimpleNonlinearSolve/.gitignore index e4cfbfe81..42affce03 100644 --- a/lib/SimpleNonlinearSolve/.gitignore +++ b/lib/SimpleNonlinearSolve/.gitignore @@ -1,3 +1,3 @@ Manifest.toml - +.vscode wip \ No newline at end of file diff --git a/lib/SimpleNonlinearSolve/Project.toml b/lib/SimpleNonlinearSolve/Project.toml index 0be404135..a0becaaca 100644 --- a/lib/SimpleNonlinearSolve/Project.toml +++ b/lib/SimpleNonlinearSolve/Project.toml @@ -23,7 +23,7 @@ SimpleBatchedNonlinearSolveExt = "NNlib" [compat] ArrayInterface = "6, 7" -DiffEqBase = "6.119" +DiffEqBase = "6.123.0" FiniteDiff = "2" ForwardDiff = "0.10.3" NNlib = "0.8" diff --git a/lib/SimpleNonlinearSolve/ext/SimpleBatchedNonlinearSolveExt.jl b/lib/SimpleNonlinearSolve/ext/SimpleBatchedNonlinearSolveExt.jl index 07c117f4f..e3f394c3b 100644 --- a/lib/SimpleNonlinearSolve/ext/SimpleBatchedNonlinearSolveExt.jl +++ b/lib/SimpleNonlinearSolve/ext/SimpleBatchedNonlinearSolveExt.jl @@ -59,7 +59,8 @@ function SciMLBase.__solve(prob::NonlinearProblem, alg::Broyden{true}, args...; error("Broyden currently doesn't support SAFE_BEST termination modes") end - storage = mode ∈ DiffEqBase.SAFE_TERMINATION_MODES ? Dict() : nothing + storage = mode ∈ DiffEqBase.SAFE_TERMINATION_MODES ? NLSolveSafeTerminationResult() : + nothing termination_condition = tc(storage) xₙ = x diff --git a/lib/SimpleNonlinearSolve/src/broyden.jl b/lib/SimpleNonlinearSolve/src/broyden.jl index e8d339c4c..e46469619 100644 --- a/lib/SimpleNonlinearSolve/src/broyden.jl +++ b/lib/SimpleNonlinearSolve/src/broyden.jl @@ -48,7 +48,8 @@ function SciMLBase.__solve(prob::NonlinearProblem, alg::Broyden{false}, args...; error("Broyden currently doesn't support SAFE_BEST termination modes") end - storage = mode ∈ DiffEqBase.SAFE_TERMINATION_MODES ? Dict() : nothing + storage = mode ∈ DiffEqBase.SAFE_TERMINATION_MODES ? NLSolveSafeTerminationResult() : + nothing termination_condition = tc(storage) xₙ = x diff --git a/lib/SimpleNonlinearSolve/src/lbroyden.jl b/lib/SimpleNonlinearSolve/src/lbroyden.jl index 6a3fc0947..6cca7c11e 100644 --- a/lib/SimpleNonlinearSolve/src/lbroyden.jl +++ b/lib/SimpleNonlinearSolve/src/lbroyden.jl @@ -63,7 +63,8 @@ end error("LBroyden currently doesn't support SAFE_BEST termination modes") end - storage = mode ∈ DiffEqBase.SAFE_TERMINATION_MODES ? Dict() : nothing + storage = mode ∈ DiffEqBase.SAFE_TERMINATION_MODES ? NLSolveSafeTerminationResult() : + nothing termination_condition = tc(storage) xₙ = x