Skip to content

Commit 29e72d3

Browse files
Add keywords argument for the subsolver of AL algorithm #327 (#328)
Update documentation and test file for AL algorithm.
1 parent 53e6e22 commit 29e72d3

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

src/AL_alg.jl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ If adopted, the Hessian is accessed as an abstract operator and need not be the
116116
- `init_subtol::T = T(0.1)`: initial subproblem tolerance;
117117
- `factor_decrease_subtol::T = T(1/4)`: multiplicative factor to decrease the subproblem tolerance;
118118
- `dual_safeguard = (nlp::AugLagModel) -> nothing`: in-place function to modify, as needed, the dual estimate.
119+
- `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,)
119120
120121
# Output
121122
@@ -213,16 +214,14 @@ function SolverCore.solve!(
213214
max_iter::Int = 10000,
214215
max_time::Float64 = 30.0,
215216
max_eval::Int = -1,
216-
subsolver_verbose::Int = 0,
217-
subsolver_max_iter::Int = 100000,
218-
subsolver_max_eval::Int = -1,
219217
init_penalty::T = T(10),
220218
factor_penalty_up::T = T(2),
221219
ctol::T = atol,
222220
init_subtol::T = T(0.1),
223221
factor_primal_linear_improvement::T = T(3 // 4),
224222
factor_decrease_subtol::T = T(1 // 4),
225223
dual_safeguard = project_y!,
224+
sub_kwargs::NamedTuple = NamedTuple(),
226225
) where {T, V}
227226
reset!(stats)
228227

@@ -302,14 +301,12 @@ function SolverCore.solve!(
302301
solve!(
303302
solver.sub_solver,
304303
solver.sub_problem,
305-
subout,
304+
subout;
306305
x = solver.x,
307306
atol = subtol,
308307
rtol = zero(T),
309308
max_time = max_time - stats.elapsed_time,
310-
max_eval = subsolver_max_eval < 0 ? rem_eval : min(subsolver_max_eval, rem_eval),
311-
max_iter = subsolver_max_iter,
312-
verbose = subsolver_verbose,
309+
sub_kwargs...,
313310
)
314311
solver.x .= subout.solution
315312
solver.cx .= solver.sub_problem.model.cx

test/test_AL.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ problem_list = [:hs8]
55
for problem in problem_list
66
nlp = eval(problem)(backend = :optimized)
77
for h in (NormL1(1.0),)
8-
stats = AL(nlp, h, subsolver = R2Solver, atol = 1e-3, verbose = 1, subsolver_max_iter = 1000)
8+
stats = AL(nlp, h, subsolver = R2Solver, atol = 1e-3, verbose = 1, sub_kwargs = (max_iter = 1000,))
99
@test stats.status == :first_order
1010
@test stats.primal_feas <= 1e-2
1111
@test stats.dual_feas <= 1e-2
@@ -18,7 +18,7 @@ problem_list = [:hs8]
1818
subsolver = R2NSolver,
1919
atol = 1e-3,
2020
verbose = 1,
21-
subsolver_max_iter = 1000,
21+
sub_kwargs = (max_iter = 1000,),
2222
)
2323
@test stats.status == :first_order
2424
@test stats.primal_feas <= 1e-2

0 commit comments

Comments
 (0)