Skip to content

Commit 54f104e

Browse files
committed
add new NLS solvers
1 parent 6c3b9f2 commit 54f104e

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

src/solvers.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ const solvers_nls_const = Dict(
3939
[:shifts => 10.0 .^ (collect(-10.0:0.5:20.0))],
4040
),
4141
:ST_TROpGN => (HessGaussNewtonOp, PDataST, solve_modelST_TR, ()),
42-
)
42+
:ST_TROpGNLS => (HessGaussNewtonOp, PDataNLSST, solve_modelNLSST_TR, ()),
43+
:ST_TROpLS => (HessOp, PDataNLSST, solve_modelNLSST_TR, ()),
44+
)

src/utils/pdata_struct.jl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ abstract type PDataFact{T} <: TPData{T} end # Variants using matricial factoriza
66

77
abstract type PDataIter{T} <: TPData{T} end # Variants using iterative (Krylov) solvers
88

9+
abstract type PDataIterLS{T} <: TPData{T} end # Variants using iterative (Krylov) solvers for least-square subproblem
10+
911
"""
1012
preprocess(PData::TPData, H, g, gNorm2, n1, n2, α)
1113
@@ -220,3 +222,41 @@ function PDataST(
220222
solver = CgSolver(n, n, S)
221223
return PDataST(d, λ, ζ, ξ, maxtol, mintol, cgatol, cgrtol, OK, solver)
222224
end
225+
226+
"""
227+
PDataNLSST(::Type{S}, ::Type{T}, n)
228+
Return a structure used for the preprocessing of Steihaug-Toint methods for Gauss-Newton approximation of nonlinear least squares.
229+
"""
230+
mutable struct PDataNLSST{S,T} <: PDataIterLS{T}
231+
d::S
232+
λ::T
233+
ζ::T # Inexact Newton order parameter: stop when ||∇q|| < ξ * ||g||^(1+ζ)
234+
ξ::T # Inexact Newton order parameter: stop when ||∇q|| < ξ * ||g||^(1+ζ)
235+
maxtol::T # Largest tolerance for Inexact Newton
236+
mintol::T # Smallest tolerance for Inexact Newton
237+
cgatol::Any
238+
cgrtol::Any
239+
240+
OK::Bool # preprocess success
241+
solver::Union{CglsSolver,LsqrSolver}
242+
end
243+
244+
function PDataNLSST(
245+
::Type{S},
246+
::Type{T},
247+
n,
248+
m;
249+
ζ = T(0.5),
250+
ξ = T(0.01),
251+
maxtol = T(0.01),
252+
mintol = sqrt(eps(T)),
253+
cgatol = (ζ, ξ, maxtol, mintol, gNorm2) -> max(mintol, min(maxtol, ξ * gNorm2^(1 + ζ))),
254+
cgrtol = (ζ, ξ, maxtol, mintol, gNorm2) -> max(mintol, min(maxtol, ξ * gNorm2^ζ)),
255+
kwargs...,
256+
) where {S,T}
257+
d = S(undef, n)
258+
λ = zero(T)
259+
OK = true
260+
solver = CglsSolver(m, n, S)
261+
return PDataNLSST(d, λ, ζ, ξ, maxtol, mintol, cgatol, cgrtol, OK, solver)
262+
end

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ using Stopping
1111
@testset "$name" for name in ALL_solvers
1212
solver = eval(name)
1313
unconstrained_nlp(solver)
14-
multiprecision_nlp(solver, :unc)
14+
multiprecision_nlp(solver, :unc, precisions = (Float32, Float64))
1515
end
1616
end
1717

1818
@testset "Testing NLS solvers" begin
1919
@testset "$name" for name in union(ALL_solvers, NLS_solvers)
2020
solver = eval(name)
2121
unconstrained_nls(solver)
22-
multiprecision_nls(solver, :unc)
22+
multiprecision_nls(solver, :unc, precisions = (Float32, Float64))
2323
end
2424
end
2525

0 commit comments

Comments
 (0)