Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 625b8f3

Browse files
committed
Reuse criteria computation
1 parent 8fd63c6 commit 625b8f3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/dfsane.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,13 @@ function SciMLBase.__solve(prob::NonlinearProblem, alg::SimpleDFSane{batched},
180180
inner_iterations += 1
181181

182182
if batched
183+
criteria = @.+ η - γ * α_p^2 * f_k
183184
# NOTE: This is simply a heuristic, ideally we check using `all` but that is
184185
# typically very expensive for large problems
185-
norm(f_new) norm(@.+ η - γ * α_p^2 * f_k) && break
186+
(sum(f_new .≤ criteria) batch_size ÷ 2) && break
186187
else
187-
f_new + η - γ * α_p^2 * f_k && break
188+
criteria =+ η - γ * α_p^2 * f_k
189+
f_new criteria && break
188190
end
189191

190192
α_tp = @. α_p^2 * f_k / (f_new + (2 * α_p - 1) * f_k)
@@ -194,9 +196,9 @@ function SciMLBase.__solve(prob::NonlinearProblem, alg::SimpleDFSane{batched},
194196
if batched
195197
# NOTE: This is simply a heuristic, ideally we check using `all` but that is
196198
# typically very expensive for large problems
197-
norm(f_new) norm(@.+ η - γ * α_p^2 * f_k) && break
199+
(sum(f_new .≤ criteria) batch_size ÷ 2) && break
198200
else
199-
f_new + η - γ * α_p^2 * f_k && break
201+
f_new criteria && break
200202
end
201203

202204
α_tm = @. α_m^2 * f_k / (f_new + (2 * α_m - 1) * f_k)

0 commit comments

Comments
 (0)