-
Notifications
You must be signed in to change notification settings - Fork 10
add option to change subsolver in AL #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,7 +81,7 @@ where y is an estimate of the Lagrange multiplier vector for the constraints lco | |
|
|
||
| For advanced usage, first define a solver "ALSolver" to preallocate the memory used in the algorithm, and then call `solve!`: | ||
|
|
||
| solver = ALSolver(reg_nlp) | ||
| solver = ALSolver(reg_nlp; subsolver = R2Solver) | ||
| solve!(solver, reg_nlp) | ||
|
|
||
| stats = GenericExecutionStats(reg_nlp.model) | ||
|
|
@@ -108,7 +108,7 @@ If adopted, the Hessian is accessed as an abstract operator and need not be the | |
| - `max_iter::Int = 10000`: maximum number of iterations; | ||
| - `max_time::Float64 = 30.0`: maximum time limit in seconds; | ||
| - `max_eval::Int = -1`: maximum number of evaluation of the objective function (negative number means unlimited); | ||
| - `subsolver::AbstractOptimizationSolver = has_bounds(nlp) ? TR : R2`: the procedure used to compute a step (e.g. `PG`, `R2`, `TR` or `TRDH`); | ||
| - `subsolver::AbstractOptimizationSolver = R2Solver`: the procedure used to compute a step (e.g. `R2Solver`, `R2NSolver`, `R2DHSolver`, `TRSolver` or `TRDHSolver`); | ||
| - `subsolver_logger::AbstractLogger`: a logger to pass to the subproblem solver; | ||
| - `init_penalty::T = T(10)`: initial penalty parameter; | ||
| - `factor_penalty_up::T = T(2)`: multiplicative factor to increase the penalty parameter; | ||
|
|
@@ -148,7 +148,7 @@ mutable struct ALSolver{T, V, M, Pb, ST} <: AbstractOptimizationSolver | |
| sub_stats::GenericExecutionStats{T, V, V, T} | ||
| end | ||
|
|
||
| function ALSolver(reg_nlp::AbstractRegularizedNLPModel{T, V}; kwargs...) where {T, V} | ||
| function ALSolver(reg_nlp::AbstractRegularizedNLPModel{T, V}; subsolver = R2Solver, kwargs...) where {T, V} | ||
| nlp = reg_nlp.model | ||
| nvar, ncon = nlp.meta.nvar, nlp.meta.ncon | ||
| x = V(undef, nvar) | ||
|
|
@@ -157,7 +157,7 @@ function ALSolver(reg_nlp::AbstractRegularizedNLPModel{T, V}; kwargs...) where { | |
| has_bnds = has_bounds(nlp) | ||
| sub_model = AugLagModel(nlp, V(undef, ncon), T(0), x, T(0), cx) | ||
| sub_problem = RegularizedNLPModel(sub_model, reg_nlp.h, reg_nlp.selected) | ||
| sub_solver = R2Solver(reg_nlp; kwargs...) | ||
| sub_solver = subsolver(reg_nlp; kwargs...) | ||
| sub_stats = RegularizedExecutionStats(sub_problem) | ||
|
Comment on lines
157
to
161
|
||
| M = typeof(nlp) | ||
| ST = typeof(sub_solver) | ||
|
|
@@ -182,8 +182,10 @@ end | |
| "AL(::Val{:equ}, ...) should only be called for equality-constrained problems with bounded variables. Use AL(...)", | ||
| ) | ||
| end | ||
| solver = ALSolver(reg_nlp) | ||
| solve!(solver, reg_nlp; kwargs...) | ||
| kwargs_dict = Dict(kwargs...) | ||
| subsolver = pop!(kwargs_dict, :subsolver, R2Solver) | ||
| solver = ALSolver(reg_nlp, subsolver = subsolver) | ||
| solve!(solver, reg_nlp; kwargs_dict...) | ||
| end | ||
|
|
||
| function SolverCore.solve!( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring lists
subsolver::AbstractOptimizationSolver = R2Solver, butsubsolveris used as a constructor/callable (e.g.subsolver(reg_nlp; ...)) rather than anAbstractOptimizationSolverinstance. To avoid confusing users (and to match how other solvers documentsubsolver), update the doc to reflect that this expects a solver type/constructor (e.g.Type{<:AbstractOptimizationSolver}or a callable that returns a solver) and clarify the default accordingly.