Skip to content

Commit 144f9a4

Browse files
add LM function signatures
1 parent 5101a10 commit 144f9a4

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/LM_alg.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,43 @@ Notably, you can access, and modify, the following:
160160
- `stats.status`: current status of the algorithm. Should be `:unknown` unless the algorithm has attained a stopping criterion. Changing this to anything other than `:unknown` will stop the algorithm, but you should use `:user` to properly indicate the intention;
161161
- `stats.elapsed_time`: elapsed time in seconds.
162162
"""
163+
function LM(
164+
nls::AbstractNLSModel,
165+
h::H,
166+
options::ROSolverOptions;
167+
kwargs...,
168+
) where {H}
169+
kwargs_dict = Dict(kwargs...)
170+
selected = pop!(kwargs_dict, :selected, 1:(nls.meta.nvar))
171+
x0 = pop!(kwargs_dict, :x0, nls.meta.x0)
172+
reg_nls = RegularizedNLPModel(nls, h, selected)
173+
return LM(
174+
reg_nls,
175+
x = x0,
176+
atol = options.ϵa,
177+
rtol = options.ϵr,
178+
neg_tol = options.neg_tol,
179+
verbose = options.verbose,
180+
max_iter = options.maxIter,
181+
max_time = options.maxTime,
182+
σmin = options.σmin,
183+
σk = options.σk,
184+
η1 = options.η1,
185+
η2 = options.η2,
186+
γ = options.γ,
187+
kwargs_dict...,
188+
)
189+
end
190+
191+
function LM(reg_nls::AbstractRegularizedNLPModel, kwargs...)
192+
kwargs_dict = Dict(kwargs...)
193+
subsolver = pop!(kwargs_dict, :subsolver, R2Solver)
194+
solver = LMSolver(reg_nls, subsolver = subsolver)
195+
stats = RegularizedExecutionStats(reg_nls.model)
196+
solve!(solver, reg_nls, stats; kwargs_dict...)
197+
return stats
198+
end
199+
163200
function SolverCore.solve!(
164201
solver::LMSolver{T, G, V},
165202
reg_nls::AbstractRegularizedNLPModel{T, V},

0 commit comments

Comments
 (0)