Skip to content

Commit 069b854

Browse files
add sub_kwargs dict for R2N
1 parent 15cfbf0 commit 069b854

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/R2N.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ For advanced usage, first define a solver "R2NSolver" to preallocate the memory
131131
- `γ::T = T(3)`: regularization parameter multiplier, σ := σ/γ when the iteration is very successful and σ := σγ when the iteration is unsuccessful.
132132
- `θ::T = 1/(1 + eps(T)^(1 / 5))`: is the model decrease fraction with respect to the decrease of the Cauchy model.
133133
- `m_monotone::Int = 1`: monotonicity parameter. By default, R2N is monotone but the non-monotone variant will be used if `m_monotone > 1`
134+
- `sub_kwargs::Dict{Symbol}`: a dictionary containing the keyword arguments to be sent to the subsolver. The solver will fail if invalid keyword arguments are provided to the subsolver.
134135
135136
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.
136137
@@ -164,6 +165,7 @@ function R2N(
164165
selected = pop!(kwargs_dict, :selected, 1:(nlp.meta.nvar))
165166
x0 = pop!(kwargs_dict, :x0, nlp.meta.x0)
166167
reg_nlp = RegularizedNLPModel(nlp, h, selected)
168+
sub_kwargs = pop!(kwargs_dict, :sub_kwargs, Dict{Symbol, Any}())
167169
return R2N(
168170
reg_nlp,
169171
x = x0,
@@ -177,7 +179,8 @@ function R2N(
177179
η1 = options.η1,
178180
η2 = options.η2,
179181
ν = options.ν,
180-
γ = options.γ;
182+
γ = options.γ,
183+
sub_kwargs = sub_kwargs;
181184
kwargs_dict...,
182185
)
183186
end
@@ -212,7 +215,7 @@ function SolverCore.solve!(
212215
γ::T = T(3),
213216
β::T = 1 / eps(T),
214217
θ::T = 1/(1 + eps(T)^(1 / 5)),
215-
kwargs...,
218+
sub_kwargs::Dict{Symbol} = Dict()
216219
) where {T, V, G}
217220
reset!(stats)
218221

@@ -351,15 +354,15 @@ function SolverCore.solve!(
351354

352355
solver.subpb.model.σ = σk
353356
isa(solver.subsolver, R2DHSolver) && (solver.subsolver.D.d[1] = 1/ν₁)
354-
ν_sub = isa(solver.subsolver, R2DHSolver) ? 1/σk : ν₁
357+
sub_ν = isa(solver.subsolver, R2DHSolver) ? 1/σk : ν₁
355358
solve!(
356359
solver.subsolver,
357360
solver.subpb,
358361
solver.substats;
359362
x = s1,
360363
atol = sub_atol,
361-
ν = ν_sub,
362-
kwargs...,
364+
ν = sub_ν,
365+
sub_kwargs...,
363366
)
364367

365368
s .= solver.substats.solution

0 commit comments

Comments
 (0)