Skip to content

Commit 43436db

Browse files
committed
try fix using pdata with shifts for least-squares (segfault locally)
1 parent 36f0811 commit 43436db

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
@@ -86,6 +86,21 @@ function preprocess(
8686
return PData
8787
end
8888

89+
function preprocess(
90+
stp::NLPStopping,
91+
PData::PDataIterLS,
92+
workspace::TRARCWorkspace{T,S,Hess},
93+
∇f,
94+
norm_∇f,
95+
α,
96+
) where {T,S,Hess<:HessGaussNewtonOp}
97+
max_hprod = stp.meta.max_cntrs[:neval_jprod_residual]
98+
Fx = workspace.Fx
99+
Jx = jac_op_residual!(stp.pb, workspace.xt, workspace.Hstruct.Jv, workspace.Hstruct.Jtv)
100+
PData = ARCTR.preprocess(PData, Jx, Fx, norm_∇f, neval_jprod_residual(stp.pb), max_hprod, α)
101+
return PData
102+
end
103+
89104
function compute_direction(
90105
stp::NLPStopping,
91106
PData::TPData,
@@ -143,8 +158,8 @@ function TRARC(
143158
) where {Pb,M,SRC,MStp,LoS,S,T,Hess,ParamData}
144159
nlp = nlp_stop.pb
145160

146-
if ParamData == PDataNLSST
147-
PData = PDataNLSST(S, T, nlp.meta.nvar, nlp.nls_meta.nequ; kwargs...)
161+
if ParamData in (PDataNLSST, PDataLSKARC)
162+
PData = ParamData(S, T, nlp.meta.nvar, nlp.nls_meta.nequ; kwargs...)
148163
else
149164
PData = ParamData(S, T, nlp.meta.nvar; kwargs...)
150165
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)