Applies forward-backward splitting (FBS) to a lasso problem.
Applies forward-backward splitting (FBS) to a lasso problem. Demonstrates the use of the alpaqa::prox_step function.
   10using std::cout, std::ranges::generate;
 
   16    auto rng = std::mt19937(12345);
 
   17    auto uni = std::uniform_real_distribution<real_t>(-1, 1);
 
   20    generate(A.reshaped(), [&] { return uni(rng); });
 
   21    generate(x.reshaped(), [&] { return uni(rng); });
 
   22    generate(b.reshaped(), [&] { return 1e-2 * uni(rng); });
 
   26    return std::make_tuple(std::move(A), std::move(x), std::move(b), λ);
 
   31    auto [A, x_exact, b, λ] = build_problem();
 
   38    vec x = vec::Zero(n), x_next(n), grad(n), err(n), step(n);
 
   41    cout << 
"iteration\t      least squares loss\t    fixed-point residual\n";
 
   42    for (index_t i = 0; i < 1'000; ++i) {
 
   44        err.noalias()  = A * x - b;
 
   45        grad.noalias() = A.transpose() * err;
 
   46        real_t f       = 0.5 * err.squaredNorm();
 
   55        real_t residual = step.norm() / γ;
 
int main(int argc, const char *argv[])
 
#define USING_ALPAQA_CONFIG(Conf)
 
struct alpaqa::prox_step_fn prox_step
Compute a generalized forward-backward step.
 
std::ostream & print_python(std::ostream &os, const Eigen::DenseBase< Derived > &M, Args &&...args)
 
std::string float_to_str(F value, int precision)
 
Double-precision double configuration.