Skip to content

Commit 87d7649

Browse files
R2: remove nu keyword argument and replace with sigma
1 parent 4a755c5 commit 87d7649

File tree

8 files changed

+30
-46
lines changed

8 files changed

+30
-46
lines changed

src/LMTR_alg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function LMTR(
197197
set_bounds!(ψ, max.(-∆_effective, l_bound - xk), min.(∆_effective, u_bound - xk)) :
198198
set_radius!(ψ, ∆_effective)
199199
subsolver_options.Δk = ∆_effective / 10
200-
subsolver_options.ν = ν
200+
subsolver_options.σk = 1/ν
201201
subsolver_args = subsolver == TRDH ? (SpectralGradient(1 / ν, nls.meta.nvar),) : ()
202202
s, iter, _ = with_logger(subsolver_logger) do
203203
subsolver(φ, ∇φ!, ψ, subsolver_args..., subsolver_options, s)

src/LM_alg.jl

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -318,18 +318,15 @@ function SolverCore.solve!(
318318
sub_atol = stats.iter == 0 ? 1.0e-3 : min(sqrt_ξ1_νInv ^ (1.5), sqrt_ξ1_νInv * 1e-3)
319319
solver.subpb.model.σ = σk
320320
isa(solver.subsolver, R2DHSolver) && (solver.subsolver.D.d[1] = 1/ν)
321-
if isa(solver.subsolver, R2Solver) #FIXME
322-
solve!(solver.subsolver, solver.subpb, solver.substats, x = s, atol = sub_atol, ν = ν)
323-
else
324-
solve!(
325-
solver.subsolver,
326-
solver.subpb,
327-
solver.substats,
328-
x = s,
329-
atol = sub_atol,
330-
σk = σk, #FIXME
331-
)
332-
end
321+
322+
solve!(
323+
solver.subsolver,
324+
solver.subpb,
325+
solver.substats,
326+
x = s,
327+
atol = sub_atol,
328+
σk = 1/ν, #FIXME
329+
)
333330

334331
prox_evals += solver.substats.iter
335332
s .= solver.substats.solution

src/R2DH.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ function SolverCore.solve!(
312312
∇fk⁻ .= ∇fk
313313
spectral_test = isa(D, SpectralGradient)
314314

315+
σk = max(σk, σmin)
315316
@. dkσk = D.d .+ σk
316317
DNorm = norm(D.d, Inf)
317318

src/R2N.jl

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ function SolverCore.solve!(
304304
λmax, found_λ = opnorm(solver.subpb.model.B)
305305
found_λ || error("operator norm computation failed")
306306

307+
σk = max(σk, σmin)
307308
ν₁ = θ / (λmax + σk)
308309

309310
sqrt_ξ1_νInv = one(T)
@@ -366,27 +367,15 @@ function SolverCore.solve!(
366367

367368
solver.subpb.model.σ = σk
368369
isa(solver.subsolver, R2DHSolver) && (solver.subsolver.D.d[1] = 1/ν₁)
369-
if isa(solver.subsolver, R2Solver) #FIXME
370-
solve!(
371-
solver.subsolver,
372-
solver.subpb,
373-
solver.substats;
374-
x = s1,
375-
ν = ν₁,
376-
atol = sub_atol,
377-
sub_kwargs...,
378-
)
379-
else
380-
solve!(
381-
solver.subsolver,
382-
solver.subpb,
383-
solver.substats;
384-
x = s1,
385-
σk = σk,
386-
atol = sub_atol,
387-
sub_kwargs...,
388-
)
389-
end
370+
solve!(
371+
solver.subsolver,
372+
solver.subpb,
373+
solver.substats;
374+
x = s1,
375+
σk = σk,
376+
atol = sub_atol,
377+
sub_kwargs...,
378+
)
390379

391380
prox_evals += solver.substats.iter
392381
s .= solver.substats.solution

src/R2_alg.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ For advanced usage, first define a solver "R2Solver" to preallocate the memory u
151151
- `σmin::T = eps(T)`: minimum value of the regularization parameter;
152152
- `η1::T = √√eps(T)`: very successful iteration threshold;
153153
- `η2::T = T(0.9)`: successful iteration threshold;
154-
- `ν::T = eps(T)^(1 / 5)`: multiplicative inverse of the regularization parameter: ν = 1/σ;
154+
- `σk::T = eps(T)^(1 / 5)`: initial value of the regularization parameter;
155155
- `γ::T = T(3)`: regularization parameter multiplier, σ := σ/γ when the iteration is very successful and σ := σγ when the iteration is unsuccessful.
156156
157157
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.
@@ -198,7 +198,7 @@ function R2(
198198
σmin = options.σmin,
199199
η1 = options.η1,
200200
η2 = options.η2,
201-
ν = options.ν,
201+
σk = options.σk,
202202
γ = options.γ;
203203
kwargs_dict...,
204204
)
@@ -237,7 +237,7 @@ function R2(
237237
σmin = options.σmin,
238238
η1 = options.η1,
239239
η2 = options.η2,
240-
ν = options.ν,
240+
σk = options.σk,
241241
γ = options.γ;
242242
kwargs...,
243243
)
@@ -280,7 +280,7 @@ function R2(
280280
σmin = options.σmin,
281281
η1 = options.η1,
282282
η2 = options.η2,
283-
ν = options.ν,
283+
σk = options.σk,
284284
γ = options.γ;
285285
kwargs...,
286286
)
@@ -335,7 +335,7 @@ function SolverCore.solve!(
335335
σmin::T = eps(T),
336336
η1::T = √√eps(T),
337337
η2::T = T(0.9),
338-
ν::T = eps(T)^(1 / 5),
338+
σk::T = eps(T)^(1 / 5),
339339
γ::T = T(3),
340340
) where {T, V}
341341
reset!(stats)
@@ -396,7 +396,7 @@ function SolverCore.solve!(
396396

397397
local ξ::T
398398
local ρk::T
399-
σk = max(1 / ν, σmin)
399+
σk = max(σk, σmin)
400400
ν = 1 / σk
401401
sqrt_ξ_νInv = one(T)
402402

src/TR_alg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ function SolverCore.solve!(
366366
solver.substats;
367367
x = s,
368368
atol = stats.iter == 0 ? 1e-5 : max(sub_atol, min(1e-2, sqrt_ξ1_νInv)),
369-
ν = ν₁,
369+
σk = 1/ν₁,
370370
sub_kwargs...,
371371
)
372372
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using ADNLPModels,
1212

1313
const global compound = 1
1414
const global nz = 10 * compound
15-
const global options = ROSolverOptions(ν = 1.0, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = 10)
15+
const global options = ROSolverOptions(σk = 1.0, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = 10)
1616
const global bpdn, bpdn_nls, sol = bpdn_model(compound)
1717
const global bpdn2, bpdn_nls2, sol2 = bpdn_model(compound, bounds = true)
1818
const global λ = norm(grad(bpdn, zeros(bpdn.meta.nvar)), Inf) / 10

test/test_allocs.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ end
5454
reg_nlp = RegularizedNLPModel(LBFGSModel(bpdn), h)
5555
solver = eval(solver)(reg_nlp)
5656
stats = RegularizedExecutionStats(reg_nlp)
57-
solver_name == "R2" &&
58-
@test @wrappedallocs(solve!(solver, reg_nlp, stats, ν = 1.0, atol = 1e-6, rtol = 1e-6)) ==
59-
0
60-
solver_name == "R2DH" && @test @wrappedallocs(
57+
(solver_name == "R2DH" || solver_name == "R2") && @test @wrappedallocs(
6158
solve!(solver, reg_nlp, stats, σk = 1.0, atol = 1e-6, rtol = 1e-6)
6259
) == 0
6360
solver_name == "TRDH" &&

0 commit comments

Comments
 (0)