11template <
class InnerSolver>
15 typename ALMSolver::Params alm_param;
16 alm_param.max_iter = 200;
17 alm_param.tolerance = 1e-8;
18 alm_param.dual_tolerance = 1e-8;
19 alm_param.print_interval = 1;
20 alm_param.print_precision = 1;
22 return ALMSolver{alm_param, std::forward<InnerSolver>(inner_solver)};
27template <
class InnerSolver>
30 typename InnerSolver::Params solver_param;
31 solver_param.max_iter = 50'000;
32 solver_param.print_interval = 0;
36 if constexpr (
requires {
typename InnerSolver::Direction; }) {
38 using Direction =
typename InnerSolver::Direction;
39 typename Direction::DirectionParams dir_param;
40 typename Direction::AcceleratorParams accel_param;
46 .accelerator = accel_param,
47 .direction = dir_param,
51 return InnerSolver{solver_param};
55template <
class Solver>
57 std::ostream &os,
unsigned N_exp) {
64 auto stats = solver(problem.
problem, x, y);
70 auto avg_duration = stats.elapsed_time;
71 os.setstate(std::ios_base::badbit);
72 for (
unsigned i = 0; i < N_exp; ++i) {
75 auto s = solver(problem.
problem, x, y);
78 os <<
"\rInterrupted after " << i <<
" runs" << std::endl;
82 avg_duration += s.elapsed_time;
85 avg_duration /= (N_exp + 1);
87 solver.os = &std::cout;
90 real_t final_γ = 0, final_h = 0;
91 if constexpr (
requires { stats.inner.final_γ; })
92 final_γ = stats.inner.final_γ;
93 if constexpr (
requires { stats.inner.final_h; })
94 final_h = stats.inner.final_h;
96 if constexpr (
requires { stats.inner.linesearch_failures; })
98 "linesearch_failures",
99 static_cast<index_t
>(stats.inner.linesearch_failures));
100 if constexpr (
requires { stats.inner.linesearch_backtracks; })
102 "linesearch_backtracks",
103 static_cast<index_t
>(stats.inner.linesearch_backtracks));
104 if constexpr (
requires { stats.inner.stepsize_backtracks; })
106 "stepsize_backtracks",
107 static_cast<index_t
>(stats.inner.stepsize_backtracks));
108 if constexpr (
requires { stats.inner.lbfgs_failures; })
109 extra.emplace_back(
"lbfgs_failures",
110 static_cast<index_t
>(stats.inner.lbfgs_failures));
111 if constexpr (
requires { stats.inner.lbfgs_rejected; })
112 extra.emplace_back(
"lbfgs_rejected",
113 static_cast<index_t
>(stats.inner.lbfgs_rejected));
118 .duration = avg_duration,
119 .solver = solver.get_name(),
124 .Σ = stats.norm_penalty,
127 .multipliers_bounds = vec(0),
128 .outer_iter =
static_cast<index_t
>(stats.outer_iterations),
129 .inner_iter =
static_cast<index_t
>(stats.inner.iterations),
130 .extra = std::move(extra),
auto make_inner_solver(Options &opts)
SolverResults run_alm_solver(LoadedProblem &problem, Solver &solver, std::ostream &os, unsigned N_exp)
auto make_alm_solver(InnerSolver &&inner_solver, Options &opts)
Augmented Lagrangian Method solver.
#define USING_ALPAQA_CONFIG(Conf)
std::string_view enum_name(Ipopt::ApplicationReturnStatus s)
@ ProjGradUnitNorm
∞-norm of the projected gradient with unit step size:
@ Interrupted
Solver was interrupted by the user.
@ Converged
Converged and reached given tolerance.
decltype(auto) set_params(T &t, std::string_view prefix, Options &opts)
vec initial_guess_y
Unknowns.
alpaqa::TypeErasedProblem< config_t > problem
std::shared_ptr< alpaqa::EvalCounter > evaluations
std::vector< std::pair< std::string, any_stat_t > > extra