Skip to content

Commit 9232d49

Browse files
add sub_kwargs parameter to LMSolver and solve! for subsolver keyword arguments
1 parent 84f3d1e commit 9232d49

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/LM_alg.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ For advanced usage, first define a solver "LMSolver" to preallocate the memory u
140140
- `θ::T = 1/(1 + eps(T)^(1 / 5))`: is the model decrease fraction with respect to the decrease of the Cauchy model;
141141
- `m_monotone::Int = 1`: monotonicity parameter. By default, LM is monotone but the non-monotone variant will be used if `m_monotone > 1`;
142142
- `subsolver = R2Solver`: the solver used to solve the subproblems.
143+
- `sub_kwargs::NamedTuple = NamedTuple()`: a named tuple containing the keyword arguments to be sent to the subsolver. The solver will fail if invalid keyword arguments are provided to the subsolver. For example, if the subsolver is `R2Solver`, you can pass `sub_kwargs = (max_iter = 100, σmin = 1e-6,)`.
143144
144145
The algorithm stops either when `√(ξₖ/νₖ) < atol + rtol*√(ξ₀/ν₀) ` or `ξₖ < 0` and `√(-ξₖ/νₖ) < neg_tol` where ξₖ := f(xₖ) + h(xₖ) - φ(sₖ; xₖ) - ψ(sₖ; xₖ), and √(ξₖ/νₖ) is a stationarity measure.
145146
@@ -202,6 +203,7 @@ function SolverCore.solve!(
202203
η2::T = T(0.9),
203204
γ::T = T(3),
204205
θ::T = 1/(1 + eps(T)^(1 / 5)),
206+
sub_kwargs::NamedTuple = NamedTuple(),
205207
) where {T, V, G}
206208
reset!(stats)
207209

@@ -334,15 +336,16 @@ function SolverCore.solve!(
334336
solver.subpb.model.σ = σk
335337
isa(solver.subsolver, R2DHSolver) && (solver.subsolver.D.d[1] = 1/ν)
336338
if isa(solver.subsolver, R2Solver) #FIXME
337-
solve!(solver.subsolver, solver.subpb, solver.substats, x = s, atol = sub_atol, ν = ν)
339+
solve!(solver.subsolver, solver.subpb, solver.substats; x = s, atol = sub_atol, ν = ν, sub_kwargs...)
338340
else
339341
solve!(
340342
solver.subsolver,
341343
solver.subpb,
342-
solver.substats,
344+
solver.substats;
343345
x = s,
344346
atol = sub_atol,
345347
σk = σk, #FIXME
348+
sub_kwargs...,
346349
)
347350
end
348351

0 commit comments

Comments
 (0)