Skip to content

Commit bec197d

Browse files
committed
initial radius improvements
1 parent cf5c17e commit bec197d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/trustRegion.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ function SciMLBase.__init(prob::NonlinearProblem{uType, iip}, alg::TrustRegion,
294294
p2 = convert(eltype(u), 0.1) # β
295295
p3 = convert(eltype(u), 0.15) # γ1
296296
p4 = convert(eltype(u), 0.15) # γ2
297+
initial_trust_radius = convert(eltype(u), 1.0)
297298
elseif radius_update_scheme === RadiusUpdateSchemes.Yuan
298299
step_threshold = convert(eltype(u), 0.0001)
299300
shrink_threshold = convert(eltype(u), 0.25)
@@ -302,6 +303,12 @@ function SciMLBase.__init(prob::NonlinearProblem{uType, iip}, alg::TrustRegion,
302303
p2 = convert(eltype(u), 1/6) # c5
303304
p3 = convert(eltype(u), 6.0) # c6
304305
p4 = convert(eltype(u), 0.0)
306+
if iip
307+
J = ForwardDiff.jacobian(f, fu, u)
308+
else
309+
J = ForwardDiff.jacobian(f, u)
310+
end
311+
initial_trust_radius = convert(eltype(u), p1 * norm(J * fu))
305312
elseif radius_update_scheme === RadiusUpdateSchemes.Fan
306313
step_threshold = convert(eltype(u), 0.0001)
307314
shrink_threshold = convert(eltype(u), 0.25)
@@ -310,6 +317,7 @@ function SciMLBase.__init(prob::NonlinearProblem{uType, iip}, alg::TrustRegion,
310317
p2 = convert(eltype(u), 1/4) # c5
311318
p3 = convert(eltype(u), 12) # c6
312319
p4 = convert(eltype(u), 1.0e18) # M
320+
initial_trust_radius = convert(eltype(u), p1 * (norm(fu)^0.99))
313321
end
314322

315323
return TrustRegionCache{iip}(f, alg, u, fu, p, uf, linsolve, J, jac_config,

0 commit comments

Comments
 (0)