Skip to content

Commit c978794

Browse files
committed
changing so only iip=true copy
1 parent 679fdab commit c978794

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ docs/site/
2323
# environment.
2424
Manifest.toml
2525
docs/src/assets/Project.toml
26+
27+
.vscode
28+
TEST1.jl
29+
TEST2.jl
30+
TEST3.jl
31+
trustRegion copy.jl
32+
trustRegionHOLDER.jl

src/trustRegion.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ function trust_region_step!(cache::TrustRegionCache)
309309
if r > alg.step_threshold
310310

311311
# Take the step.
312-
cache.u = copy(u_tmp)
313-
cache.fu = copy(fu_new)
312+
take_step!(cache)
313+
314314
cache.loss = cache.loss_new
315315

316316
# Update the trust region radius.
@@ -356,6 +356,16 @@ function dogleg!(cache::TrustRegionCache)
356356
cache.step_size = δsd + τ * N_sd
357357
end
358358

359+
function take_step!(cache::TrustRegionCache{true})
360+
cache.u = copy(cache.u_tmp)
361+
cache.fu = copy(cache.fu_new)
362+
end
363+
364+
function take_step!(cache::TrustRegionCache{false})
365+
cache.u = cache.u_tmp
366+
cache.fu = cache.fu_new
367+
end
368+
359369
function SciMLBase.solve!(cache::TrustRegionCache)
360370
while !cache.force_stop && cache.iter < cache.maxiters &&
361371
cache.shrink_counter < cache.alg.max_shrink_times

0 commit comments

Comments
 (0)