Skip to content

Commit 82c30ba

Browse files
committed
try fix using pdata with shifts for least-squares (segfault locally)
1 parent a3ea61b commit 82c30ba

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/main.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,21 @@ function preprocess(
9191
return PData
9292
end
9393

94+
function preprocess(
95+
stp::NLPStopping,
96+
PData::PDataIterLS,
97+
workspace::TRARCWorkspace{T,S,Hess},
98+
∇f,
99+
norm_∇f,
100+
α,
101+
) where {T,S,Hess<:HessGaussNewtonOp}
102+
max_hprod = stp.meta.max_cntrs[:neval_jprod_residual]
103+
Fx = workspace.Fx
104+
Jx = jac_op_residual!(stp.pb, workspace.xt, workspace.Hstruct.Jv, workspace.Hstruct.Jtv)
105+
PData = ARCTR.preprocess(PData, Jx, Fx, norm_∇f, neval_jprod_residual(stp.pb), max_hprod, α)
106+
return PData
107+
end
108+
94109
function compute_direction(
95110
stp::NLPStopping,
96111
PData::TPData,
@@ -148,8 +163,8 @@ function TRARC(
148163
) where {Pb,M,SRC,MStp,LoS,Score,S,T,Hess,ParamData}
149164
nlp = nlp_stop.pb
150165

151-
if ParamData == PDataNLSST
152-
PData = PDataNLSST(S, T, nlp.meta.nvar, nlp.nls_meta.nequ; kwargs...)
166+
if ParamData in (PDataNLSST, PDataLSKARC)
167+
PData = ParamData(S, T, nlp.meta.nvar, nlp.nls_meta.nequ; kwargs...)
153168
else
154169
PData = ParamData(S, T, nlp.meta.nvar; kwargs...)
155170
end

src/utils/pdata_struct.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ end
119119
PDataLSKARC(::Type{S}, ::Type{T}, n)
120120
Return a structure used for the preprocessing of ARCqK methods.
121121
"""
122-
mutable struct PDataLSKARC{T} <: PDataIter{T}
122+
mutable struct PDataLSKARC{T} <: PDataIterLS{T}
123123
d::Array{T,1} # (H+λI)\g ; on first call = g
124124
λ::T # "active" value of λ; on first call = 0
125125
ζ::T # Inexact Newton order parameter: stop when ||∇q|| < ξ * ||g||^(1+ζ)
@@ -144,7 +144,8 @@ end
144144
function PDataLSKARC(
145145
::Type{S},
146146
::Type{T},
147-
n;
147+
n,
148+
m;
148149
ζ = T(0.5),
149150
ξ = T(0.01),
150151
maxtol = T(0.01),
@@ -167,9 +168,9 @@ function PDataLSKARC(
167168
norm_dirs = S(undef, nshifts)
168169
OK = true
169170
solver = if solver_method == :cgls
170-
CglsLanczosShiftSolver(n, n, nshifts, S)
171+
CglsLanczosShiftSolver(m, n, nshifts, S)
171172
else
172-
LsqrShiftSolver(n, n, nshifts, S)
173+
LsqrShiftSolver(m, n, nshifts, S)
173174
end
174175
return PDataLSKARC(
175176
d,

0 commit comments

Comments
 (0)