@@ -11,6 +11,7 @@ struct TRARCWorkspace{T,S,Hess}
1111 ∇f:: S
1212 ∇fnext:: S
1313 Hstruct:: Hess
14+ Fx:: S
1415 function TRARCWorkspace (nlp:: AbstractNLPModel{T,S} , :: Type{Hess} ) where {T,S,Hess}
1516 n = nlp. meta. nvar
1617 return new {T,S,Hess} (
@@ -20,6 +21,19 @@ struct TRARCWorkspace{T,S,Hess}
2021 S (undef, n), # ∇f
2122 S (undef, n), # ∇fnext
2223 Hess (nlp, n),
24+ S (undef, 0 ),
25+ )
26+ end
27+ function TRARCWorkspace (nlp:: AbstractNLSModel{T,S} , :: Type{Hess} ) where {T,S,Hess}
28+ n = nlp. meta. nvar
29+ return new {T,S,Hess} (
30+ S (undef, n), # xt
31+ S (undef, n), # xtnext
32+ S (undef, n), # d
33+ S (undef, n), # ∇f
34+ S (undef, n), # ∇fnext
35+ Hess (nlp, n),
36+ S (undef, nlp. nls_meta. nequ),
2337 )
2438 end
2539end
@@ -37,6 +51,26 @@ function NLPModels.grad!(nlp::AbstractNLPModel, x, workspace::TRARCWorkspace)
3751 return grad! (nlp, x, workspace.∇f)
3852end
3953
54+
55+ function NLPModels. objgrad! (nls:: AbstractNLSModel , x, workspace:: TRARCWorkspace )
56+ increment! (nls, :neval_obj )
57+ increment! (nls, :neval_grad )
58+ Fx = residual! (nls, x, workspace. Fx)
59+ ∇f = jtprod_residual! (nls, x, Fx, workspace.∇f)
60+ return dot (Fx, Fx) / 2 , ∇f
61+ end
62+
63+ function NLPModels. obj (nls:: AbstractNLSModel , x, workspace:: TRARCWorkspace )
64+ increment! (nls, :neval_obj )
65+ Fx = residual! (nls, x, workspace. Fx)
66+ return dot (Fx, Fx) / 2
67+ end
68+
69+ function NLPModels. grad! (nls:: AbstractNLSModel , x, workspace:: TRARCWorkspace )
70+ increment! (nls, :neval_grad )
71+ Fx = workspace. Fx
72+ return jtprod_residual! (nls, x, Fx, workspace.∇f)
73+
4074function preprocess (stp:: NLPStopping , PData:: TPData , workspace:: TRARCWorkspace , ∇f, norm_∇f, α)
4175 max_hprod = stp. meta. max_cntrs[:neval_hprod ]
4276 Hx = stp. current_state. Hx
0 commit comments