From 050d75ea942fa01cea4cc8f5bc2dc37669509778 Mon Sep 17 00:00:00 2001 From: Dominique Date: Thu, 12 Dec 2024 12:02:47 -0800 Subject: [PATCH 1/2] R2: pass kwargs through Without this change, a callback (for example), is not passed through to R2. --- src/R2_alg.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/R2_alg.jl b/src/R2_alg.jl index 83556090..792d47b6 100644 --- a/src/R2_alg.jl +++ b/src/R2_alg.jl @@ -269,7 +269,8 @@ function R2( η1 = options.η1, η2 = options.η2, ν = options.ν, - γ = options.γ, + γ = options.γ; + kwargs... ) outdict = Dict( :Fhist => stats.solver_specific[:Fhist], From 0af0bae30abf665b6f6db3a97f465ce37c4a7d94 Mon Sep 17 00:00:00 2001 From: Dominique Date: Thu, 12 Dec 2024 12:11:24 -0800 Subject: [PATCH 2/2] R2: pass kwargs through --- src/R2_alg.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/R2_alg.jl b/src/R2_alg.jl index 792d47b6..427e11e7 100644 --- a/src/R2_alg.jl +++ b/src/R2_alg.jl @@ -199,7 +199,8 @@ function R2( η1 = options.η1, η2 = options.η2, ν = options.ν, - γ = options.γ, + γ = options.γ; + kwargs_dict... ) end @@ -227,7 +228,8 @@ function R2( η1 = options.η1, η2 = options.η2, ν = options.ν, - γ = options.γ, + γ = options.γ; + kwargs... ) outdict = Dict( :Fhist => stats.solver_specific[:Fhist], @@ -291,12 +293,13 @@ function R2(reg_nlp::AbstractRegularizedNLPModel; kwargs...) max_iter = pop!(kwargs_dict, :max_iter, 10000) solver = R2Solver(reg_nlp, max_iter = max_iter) stats = GenericExecutionStats(reg_nlp.model) - cb = + cb = pop!(kwargs_dict, :callback, (nlp, solver, stats) -> begin solver.Fobj_hist[stats.iter + 1] = stats.solver_specific[:smooth_obj] solver.Hobj_hist[stats.iter + 1] = stats.solver_specific[:nonsmooth_obj] solver.Complex_hist[stats.iter + 1] += 1 end + ) solve!(solver, reg_nlp, stats; callback = cb, max_iter = max_iter, kwargs...) set_solver_specific!(stats, :Fhist, solver.Fobj_hist[1:(stats.iter + 1)]) set_solver_specific!(stats, :Hhist, solver.Hobj_hist[1:(stats.iter + 1)])