@@ -72,27 +72,58 @@ function NLPModels.grad!(nls::AbstractNLSModel, x, workspace::TRARCWorkspace)
7272 return jtprod_residual! (nls, x, Fx, workspace.∇f)
7373end
7474
75- function preprocess (stp:: NLPStopping , PData:: TPData , workspace:: TRARCWorkspace , ∇f, norm_∇f, α)
75+ function preprocess (
76+ stp:: NLPStopping ,
77+ PData:: TPData ,
78+ workspace:: TRARCWorkspace ,
79+ ∇f,
80+ norm_∇f,
81+ α,
82+ )
7683 max_hprod = stp. meta. max_cntrs[:neval_hprod ]
7784 Hx = stp. current_state. Hx
7885 PData = preprocess (PData, Hx, ∇f, norm_∇f, neval_hprod (stp. pb), max_hprod, α)
7986 return PData
8087end
8188
82- function compute_direction (stp:: NLPStopping , PData:: TPData , workspace:: TRARCWorkspace , ∇f, norm_∇f, α, solve_model)
89+ function compute_direction (
90+ stp:: NLPStopping ,
91+ PData:: TPData ,
92+ workspace:: TRARCWorkspace ,
93+ ∇f,
94+ norm_∇f,
95+ α,
96+ solve_model,
97+ )
8398 max_hprod = stp. meta. max_cntrs[:neval_hprod ]
8499 Hx = stp. current_state. Hx
85100 return solve_model (PData, Hx, ∇f, norm_∇f, neval_hprod (stp. pb), max_hprod, α)
86101end
87102
88- function compute_direction (stp:: NLPStopping , PData:: PDataIterLS , workspace:: TRARCWorkspace , ∇f, norm_∇f, α, solve_model)
103+ function compute_direction (
104+ stp:: NLPStopping ,
105+ PData:: PDataIterLS ,
106+ workspace:: TRARCWorkspace ,
107+ ∇f,
108+ norm_∇f,
109+ α,
110+ solve_model,
111+ )
89112 max_prod = stp. meta. max_cntrs[:neval_jprod_residual ]
90113 Jx = jac_op_residual (stp. pb, workspace. xt)
91114 Fx = workspace. Fx
92115 return solve_model (PData, Jx, Fx, norm_∇f, neval_jprod_residual (stp. pb), max_prod, α)
93116end
94117
95- function compute_direction (stp:: NLPStopping , PData:: PDataIterLS , workspace:: TRARCWorkspace{T,S,Hess} , ∇f, norm_∇f, α, solve_model) where {T,S,Hess <: HessGaussNewtonOp }
118+ function compute_direction (
119+ stp:: NLPStopping ,
120+ PData:: PDataIterLS ,
121+ workspace:: TRARCWorkspace{T,S,Hess} ,
122+ ∇f,
123+ norm_∇f,
124+ α,
125+ solve_model,
126+ ) where {T,S,Hess<: HessGaussNewtonOp }
96127 max_prod = stp. meta. max_cntrs[:neval_jprod_residual ]
97128 Jx = jac_op_residual! (stp. pb, workspace. xt, workspace. Hstruct. Jv, workspace. Hstruct. Jtv)
98129 Fx = workspace. Fx
@@ -148,11 +179,7 @@ function TRARC(
148179 nlp_stop. meta. optimality0 = norm_∇f
149180
150181 OK = update_and_start! (nlp_stop, x = xt, fx = ft, gx = ∇f)
151- ! OK && Stopping. update! (
152- nlp_at_x,
153- Hx = hessian! (workspace, nlp, xt),
154- convert = true ,
155- )
182+ ! OK && Stopping. update! (nlp_at_x, Hx = hessian! (workspace, nlp, xt), convert = true )
156183
157184 iter = 0 # counter different than stop count
158185 succ, unsucc, verysucc, unsuccinarow = 0 , 0 , 0 , 0
@@ -173,7 +200,8 @@ function TRARC(
173200
174201 success = false
175202 while ! success & (unsuccinarow < max_unsuccinarow)
176- d, λ = compute_direction (nlp_stop, PData, workspace, ∇f, norm_∇f, α, solve_model)
203+ d, λ =
204+ compute_direction (nlp_stop, PData, workspace, ∇f, norm_∇f, α, solve_model)
177205
178206 slope = ∇f ⋅ d
179207 Δq = - (∇f + 0.5 * (nlp_at_x. Hx * d)) ⋅ d
0 commit comments