@@ -294,6 +294,7 @@ function SciMLBase.__init(prob::NonlinearProblem{uType, iip}, alg::TrustRegion,
294
294
p2 = convert (eltype (u), 0.1 ) # β
295
295
p3 = convert (eltype (u), 0.15 ) # γ1
296
296
p4 = convert (eltype (u), 0.15 ) # γ2
297
+ initial_trust_radius = convert (eltype (u), 1.0 )
297
298
elseif radius_update_scheme === RadiusUpdateSchemes. Yuan
298
299
step_threshold = convert (eltype (u), 0.0001 )
299
300
shrink_threshold = convert (eltype (u), 0.25 )
@@ -302,6 +303,12 @@ function SciMLBase.__init(prob::NonlinearProblem{uType, iip}, alg::TrustRegion,
302
303
p2 = convert (eltype (u), 1 / 6 ) # c5
303
304
p3 = convert (eltype (u), 6.0 ) # c6
304
305
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))
305
312
elseif radius_update_scheme === RadiusUpdateSchemes. Fan
306
313
step_threshold = convert (eltype (u), 0.0001 )
307
314
shrink_threshold = convert (eltype (u), 0.25 )
@@ -310,6 +317,7 @@ function SciMLBase.__init(prob::NonlinearProblem{uType, iip}, alg::TrustRegion,
310
317
p2 = convert (eltype (u), 1 / 4 ) # c5
311
318
p3 = convert (eltype (u), 12 ) # c6
312
319
p4 = convert (eltype (u), 1.0e18 ) # M
320
+ initial_trust_radius = convert (eltype (u), p1 * (norm (fu)^ 0.99 ))
313
321
end
314
322
315
323
return TrustRegionCache {iip} (f, alg, u, fu, p, uf, linsolve, J, jac_config,
0 commit comments