18template <
class InnerSolverT>
19typename ALMSolver<InnerSolverT>::Stats
21 std::optional<rvec> Σ) {
22 using std::chrono::duration_cast;
23 using std::chrono::nanoseconds;
24 auto start_time = std::chrono::steady_clock::now();
29 if (params.max_iter == 0)
38 .max_time = params.max_time,
39 .tolerance = params.tolerance,
59 vec error = vec::Constant(m,
NaN);
70 if (Σ && Σ->allFinite() && Σ->norm() > 0) {
74 else if (params.initial_penalty > 0) {
75 Σ_curr.setConstant(params.initial_penalty);
79 Helpers::initialize_penalty(p, params, x,
Σ_curr);
83 real_t ε = params.initial_tolerance;
85 for (
unsigned i = 0; i < params.max_iter; ++i) {
86 p.eval_proj_multipliers(y, params.max_multiplier);
117 if (params.print_interval != 0 && i % params.print_interval == 0) {
120 *os <<
"[\x1b[0;34mALM\x1b[0m] " << std::setw(5) << i
126 <<
", iter = " << std::setw(13) <<
ps.iterations
145 norm_e <= params.dual_tolerance;
162 Helpers::update_penalty_weights(params, params.penalty_update_factor,
166 ε = std::fmax(params.tolerance_update_factor * ε, params.tolerance);
171 throw std::logic_error(
"[ALM] loop error");
real_t δ
Final dual tolerance or constraint violation that was reached:
real_t norm_penalty
2-norm of the final penalty factors .
typename InnerSolver::Problem Problem
std::chrono::nanoseconds elapsed_time
Total elapsed time.
InnerStatsAccumulator< typename InnerSolver::Stats > inner
The statistics of the inner solver invocations, accumulated over all ALM iterations.
unsigned inner_convergence_failures
The total number of times that the inner solver failed to converge.
real_t ε
Final primal tolerance that was reached, depends on the stopping criterion used by the inner solver,...
unsigned outer_iterations
Total number of outer ALM iterations (i.e.
Stats operator()(const Problem &problem, rvec x, rvec y, std::optional< rvec > Σ=std::nullopt)
SolverStatus status
Whether the solver converged or not.
auto norm_inf(const Eigen::MatrixBase< Derived > &v)
Get the maximum or infinity-norm of the given vector.
@ Interrupted
Solver was interrupted by the user.
@ MaxTime
Maximum allowed execution time exceeded.
@ MaxIter
Maximum number of iterations exceeded.
@ Converged
Converged and reached given tolerance.
typename Conf::real_t real_t
bool always_overwrite_results
Return the final iterate and multipliers, even if the solver did not converge.
std::string_view float_to_str_vw(auto &buf, double value, int precision=std::numeric_limits< double >::max_digits10)