Skip to content

Commit 6c3b9f2

Browse files
committed
fix typo and prepare NLS solvers with LS subproblem
1 parent c8273a0 commit 6c3b9f2

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/main.jl

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ function NLPModels.grad!(nls::AbstractNLSModel, x, workspace::TRARCWorkspace)
7070
increment!(nls, :neval_grad)
7171
Fx = workspace.Fx
7272
return jtprod_residual!(nls, x, Fx, workspace.∇f)
73+
end
7374

7475
function preprocess(stp::NLPStopping, PData::TPData, workspace::TRARCWorkspace, ∇f, norm_∇f, α)
7576
max_hprod = stp.meta.max_cntrs[:neval_hprod]
@@ -84,6 +85,20 @@ function compute_direction(stp::NLPStopping, PData::TPData, workspace::TRARCWork
8485
return solve_model(PData, Hx, ∇f, norm_∇f, neval_hprod(stp.pb), max_hprod, α)
8586
end
8687

88+
function compute_direction(stp::NLPStopping, PData::PDataIterLS, workspace::TRARCWorkspace, ∇f, norm_∇f, α, solve_model)
89+
max_prod = stp.meta.max_cntrs[:neval_jprod_residual]
90+
Jx = jac_op_residual(stp.pb, workspace.xt)
91+
Fx = workspace.Fx
92+
return solve_model(PData, Jx, Fx, norm_∇f, neval_jprod_residual(stp.pb), max_prod, α)
93+
end
94+
95+
function compute_direction(stp::NLPStopping, PData::PDataIterLS, workspace::TRARCWorkspace{T,S,Hess}, ∇f, norm_∇f, α, solve_model) where {T,S,Hess <: HessGaussNewtonOp}
96+
max_prod = stp.meta.max_cntrs[:neval_jprod_residual]
97+
Jx = jac_op_residual!(stp.pb, workspace.xt, workspace.Hstruct.Jv, workspace.Hstruct.Jtv)
98+
Fx = workspace.Fx
99+
return solve_model(PData, Jx, Fx, norm_∇f, neval_jprod_residual(stp.pb), max_prod, α)
100+
end
101+
87102
function hessian!(workspace::TRARCWorkspace, nlp, x)
88103
return hessian!(workspace.Hstruct, nlp, x)
89104
end
@@ -97,7 +112,11 @@ function TRARC(
97112
) where {Pb,M,SRC,MStp,LoS,S,T,Hess,ParamData}
98113
nlp = nlp_stop.pb
99114

100-
PData = ParamData(S, T, nlp.meta.nvar; kwargs...)
115+
if ParamData == PDataNLSST
116+
PData = PDataNLSST(S, T, nlp.meta.nvar, nlp.nls_meta.nequ; kwargs...)
117+
else
118+
PData = ParamData(S, T, nlp.meta.nvar; kwargs...)
119+
end
101120
workspace = TRARCWorkspace(nlp, Hess)
102121
return TRARC(nlp_stop, PData, workspace, TR; kwargs...)
103122
end
@@ -173,7 +192,7 @@ function TRARC(
173192
unsucc += 1
174193
unsuccinarow += 1
175194
η = (1 - acceptance_threshold) / 10 # ∈ (acceptance_threshold, 1)
176-
qksk = ft + slope + 0.5 * (nlp_at_x.Hx * d) d
195+
qksk = ft + slope + ((nlp_at_x.Hx * d) d) / 2
177196
αbad = (1 - η) * slope / ((1 - η) * (ft + slope) + η * qksk - ftnext)
178197
α = min(decrease(PData, α, TR), max(TR.large_decrease_factor, αbad) * α)
179198
elseif r < acceptance_threshold # unsucessful

0 commit comments

Comments
 (0)