C++ API Reference

Note

The Doxygen documentation of the C++ API is often more readable.

Index

namespace alpaqa

Typedefs

using DefaultConfig = EigenConfigd
template<Config Conf = DefaultConfig>
using real_t = typename Conf::real_t
template<Config Conf = DefaultConfig>
using cplx_t = typename Conf::cplx_t
template<Config Conf = DefaultConfig>
using vec = typename Conf::vec
template<Config Conf = DefaultConfig>
using mvec = typename Conf::mvec
template<Config Conf = DefaultConfig>
using cmvec = typename Conf::cmvec
template<Config Conf = DefaultConfig>
using rvec = typename Conf::rvec
template<Config Conf = DefaultConfig>
using crvec = typename Conf::crvec
template<Config Conf = DefaultConfig>
using mat = typename Conf::mat
template<Config Conf = DefaultConfig>
using mmat = typename Conf::mmat
template<Config Conf = DefaultConfig>
using cmmat = typename Conf::cmmat
template<Config Conf = DefaultConfig>
using rmat = typename Conf::rmat
template<Config Conf = DefaultConfig>
using crmat = typename Conf::crmat
template<Config Conf = DefaultConfig>
using cmat = typename Conf::cmat
template<Config Conf = DefaultConfig>
using mcmat = typename Conf::mcmat
template<Config Conf = DefaultConfig>
using cmcmat = typename Conf::cmcmat
template<Config Conf = DefaultConfig>
using rcmat = typename Conf::rcmat
template<Config Conf = DefaultConfig>
using crcmat = typename Conf::crcmat
template<Config Conf = DefaultConfig>
using length_t = typename Conf::length_t
template<Config Conf = DefaultConfig>
using index_t = typename Conf::index_t
template<Config Conf = DefaultConfig>
using indexvec = typename Conf::indexvec
template<Config Conf = DefaultConfig>
using rindexvec = typename Conf::rindexvec
template<Config Conf = DefaultConfig>
using crindexvec = typename Conf::crindexvec
template<Config Conf = DefaultConfig>
using mindexvec = typename Conf::mindexvec
template<Config Conf = DefaultConfig>
using cmindexvec = typename Conf::cmindexvec
using casadi_int = long long int
using casadi_real = double
using function_dict_t = alpaqa_function_dict_t
using problem_register_t = alpaqa_problem_register_t
using control_problem_register_t = alpaqa_control_problem_register_t
using problem_functions_t = alpaqa_problem_functions_t
using control_problem_functions_t = alpaqa_control_problem_functions_t

Enums

enum class LBFGSStepSize

Which method to use to select the L-BFGS step size.

Values:

enumerator BasedOnExternalStepSize

Initial inverse Hessian approximation is set to \( H_0 = \gamma I \), where \( \gamma \) is the forward-backward splitting step size.

enumerator BasedOnCurvature

Initial inverse Hessian approximation is set to \( H_0 = \frac{s^\top y}{y^\top y} I \).

enumerator BasedOnGradientStepSize
enum class PANOCStopCrit

Values:

enumerator ApproxKKT

Find an ε-approximate KKT point in the ∞-norm:

\[ \varepsilon = \left\| \gamma_k^{-1} (x^k - \hat x^k) + \nabla \psi(\hat x^k) - \nabla \psi(x^k) \right\|_\infty \]

enumerator ApproxKKT2

Find an ε-approximate KKT point in the 2-norm:

\[ \varepsilon = \left\| \gamma_k^{-1} (x^k - \hat x^k) + \nabla \psi(\hat x^k) - \nabla \psi(x^k) \right\|_2 \]

enumerator ProjGradNorm

∞-norm of the projected gradient with step size γ:

\[ \varepsilon = \left\| x^k - \Pi_C\left(x^k - \gamma_k \nabla \psi(x^k)\right) \right\|_\infty \]

enumerator ProjGradNorm2

2-norm of the projected gradient with step size γ:

\[ \varepsilon = \left\| x^k - \Pi_C\left(x^k - \gamma_k \nabla \psi(x^k)\right) \right\|_2 \]
This is the same criterion as used by OpEn.

enumerator ProjGradUnitNorm

∞-norm of the projected gradient with unit step size:

\[ \varepsilon = \left\| x^k - \Pi_C\left(x^k - \nabla \psi(x^k)\right) \right\|_\infty \]

enumerator ProjGradUnitNorm2

2-norm of the projected gradient with unit step size:

\[ \varepsilon = \left\| x^k - \Pi_C\left(x^k - \nabla \psi(x^k)\right) \right\|_2 \]

enumerator FPRNorm

∞-norm of fixed point residual:

\[ \varepsilon = \gamma_k^{-1} \left\| x^k - \Pi_C\left(x^k - \gamma_k \nabla \psi(x^k)\right) \right\|_\infty \]

enumerator FPRNorm2

2-norm of fixed point residual:

\[ \varepsilon = \gamma_k^{-1} \left\| x^k - \Pi_C\left(x^k - \gamma_k \nabla \psi(x^k)\right) \right\|_2 \]

enumerator Ipopt

The stopping criterion used by Ipopt, see https://link.springer.com/article/10.1007/s10107-004-0559-y equation (5).

Given a candidate iterate \( \hat x^k \) and the corresponding candidate Lagrange multipliers \( \hat y^k \) for the general constraints \( g(x)\in D \), the multipliers \( w \) for the box constraints \( x\in C \) (that are otherwise not computed explicitly) are given by

\[w^k = v^k - \Pi_C(v^k), \]
where
\[\begin{split} \begin{aligned} v^k &\triangleq \hat x^k - \nabla f(\hat x^k) - \nabla g(\hat x^k)\, \hat y^k \\ &= \hat x^k - \nabla \psi(\hat x^k) \end{aligned} \end{split}\]
The quantity that is compared to the (scaled) tolerance is then given by
\[\begin{split} \begin{aligned} \varepsilon' &= \left\| \nabla f(\hat x^k) + \nabla g(\hat x^k)\, \hat y^k + w^k \right\|_\infty \\ &= \left\| \hat x^k - \Pi_C\left(v^k\right) \right\|_\infty \end{aligned} \end{split}\]
Finally, the quantity is scaled by the factor
\[s_d \triangleq \max\left\{ s_\text{max},\;\frac{\|\hat y^k\|_1 + \|w^k\|_1}{2m + 2n} \right\} / s_\text{max}, \]
i.e. \( \varepsilon = \varepsilon' / s_d \).

enumerator LBFGSBpp

The stopping criterion used by LBFGS++, see https://lbfgspp.statr.me/doc/classLBFGSpp_1_1LBFGSBParam.html#afb20e8fd6c6808c1f736218841ba6947.

\[ \varepsilon = \frac{\left\| x^k - \Pi_C\left(x^k - \nabla \psi(x^k)\right) \right\|_\infty} {\max\left\{1, \|x\|_2 \right\}} \]

enum class SolverStatus

Exit status of a numerical solver such as ALM or PANOC.

Values:

enumerator Busy

In progress.

enumerator Converged

Converged and reached given tolerance.

enumerator MaxTime

Maximum allowed execution time exceeded.

enumerator MaxIter

Maximum number of iterations exceeded.

enumerator NotFinite

Intermediate results were infinite or not-a-number.

enumerator NoProgress

No progress was made in the last iteration.

enumerator Interrupted

Solver was interrupted by the user.

enumerator Exception

An unexpected exception was thrown.

Functions

template<Config Conf = DefaultConfig>
inline void minimize_update_anderson(LimitedMemoryQR<Conf> &qr, rmat<Conf> G_tilde, crvec<Conf> rₖ, crvec<Conf> rₗₐₛₜ, crvec<Conf> gₖ, real_t<Conf> min_div_fac, rvec<Conf> γ_LS, rvec<Conf> xₖ_aa)

Solve one step of Anderson acceleration to find a fixed point of a function g(x):

\( g(x^\star) - x^\star = 0 \)

Updates the QR factorization of \( \mathcal{R}_k = QR \), solves the least squares problem to find \( \gamma_\text{LS} \), computes the next iterate \( x_{k+1} \), and stores the current function value \( g_k \) in the matrix \( G \), which is used as a circular buffer.

\[\begin{split} \begin{aligned} \def\gammaLS{\gamma_\text{LS}} m_k &= \min \{k, m\} \\ g_i &= g(x_i) \\ r_i &= r(x_i) g_i - x_i \\ \Delta r_i &= r_i - r_{i-1} \\ \mathcal{R}_k &= \begin{pmatrix} \Delta r_{k-m_k+1} & \dots & \Delta r_k \end{pmatrix} \in \R^{n\times m_k} \\ \gammaLS &= \argmin_{\gamma \in \R^{m_k}}\; \norm{\mathcal{R}_k \gamma - r_k}_2 \\ \alpha_i &= \begin{cases} \gammaLS[0] & i = 0 \\ \gammaLS[i] - \gammaLS[i-1] & 0 \lt i \lt m_k \\ 1 - \gammaLS[m_k - 1] & i = m_k \end{cases} \\ \tilde G_k &= \begin{pmatrix} g_{k - m_k} & \dots & g_{k-1} \end{pmatrix} \\ G_k &= \begin{pmatrix} g_{k - m_k} & \dots & g_{k} \end{pmatrix} \\ &= \begin{pmatrix} \tilde G_k & g_{k} \end{pmatrix} \\ x_{k+1} &= \sum_{i=0}^{m_k} \alpha_i\,g_{k - m_k + i} \\ &= G_k \alpha \\ \end{aligned} \end{split}\]

Parameters:
  • qr – [inout] QR factorization of \( \mathcal{R}_k \)

  • G_tilde – [inout] Matrix of previous function values \( \tilde G_k \) (stored as ring buffer with the same indices as qr)

  • rₖ – [in] Current residual \( r_k \)

  • rₗₐₛₜ – [in] Previous residual \( r_{k-1} \)

  • gₖ – [in] Current function value \( g_k \)

  • min_div_fac – [in] Minimum divisor when solving close to singular systems, scaled by the maximum eigenvalue of R

  • γ_LS – [out] Solution to the least squares system

  • xₖ_aa – [out] Next Anderson iterate

inline const char *enum_name(LBFGSStepSize s)
template<Config Conf, VectorRefLike<Conf> V>
auto const_or_mut_rvec(V &&v)
template<Config Conf>
InnerStatsAccumulator<FISTAStats<Conf>> &operator+=(InnerStatsAccumulator<FISTAStats<Conf>> &acc, const FISTAStats<Conf> &s)
inline const char *enum_name(PANOCStopCrit s)
std::ostream &operator<<(std::ostream &os, PANOCStopCrit s)
template<Config Conf>
InnerStatsAccumulator<PANOCOCPStats<Conf>> &operator+=(InnerStatsAccumulator<PANOCOCPStats<Conf>> &acc, const PANOCOCPStats<Conf> &s)
template<Config Conf>
InnerStatsAccumulator<PANOCStats<Conf>> &operator+=(InnerStatsAccumulator<PANOCStats<Conf>> &acc, const PANOCStats<Conf> &s)
template<Config Conf>
InnerStatsAccumulator<PANTRStats<Conf>> &operator+=(InnerStatsAccumulator<PANTRStats<Conf>> &acc, const PANTRStats<Conf> &s)
template<Config Conf>
InnerStatsAccumulator<WolfeStats<Conf>> &operator+=(InnerStatsAccumulator<WolfeStats<Conf>> &acc, const WolfeStats<Conf> &s)
template<Config Conf>
InnerStatsAccumulator<ZeroFPRStats<Conf>> &operator+=(InnerStatsAccumulator<ZeroFPRStats<Conf>> &acc, const ZeroFPRStats<Conf> &s)
template<Config Conf>
KKTError<Conf> compute_kkt_error(const TypeErasedProblem<Conf> &problem, crvec<Conf> x, crvec<Conf> y)
std::ostream &operator<<(std::ostream&, const OCPEvalCounter&)
inline OCPEvalCounter::OCPEvalTimer &operator+=(OCPEvalCounter::OCPEvalTimer &a, const OCPEvalCounter::OCPEvalTimer &b)
inline OCPEvalCounter &operator+=(OCPEvalCounter &a, const OCPEvalCounter &b)
inline OCPEvalCounter operator+(OCPEvalCounter a, const OCPEvalCounter &b)
inline void check_finiteness(const auto &v, std::string_view msg)

If the given vector v is not finite, break or throw an exception with the given message msg.

inline void check_finiteness(const std::floating_point auto &v, std::string_view msg)
template<class Problem>
auto ocproblem_with_counters(Problem &&p)
template<class Problem>
auto ocproblem_with_counters_ref(Problem &p)
std::ostream &operator<<(std::ostream&, const EvalCounter&)
inline EvalCounter::EvalTimer &operator+=(EvalCounter::EvalTimer &a, const EvalCounter::EvalTimer &b)
inline EvalCounter &operator+=(EvalCounter &a, const EvalCounter &b)
inline EvalCounter operator+(EvalCounter a, const EvalCounter &b)
template<class Derived>
std::ostream &print_python(std::ostream &os, const Eigen::DenseBase<Derived> &M)
template<class Derived>
auto as_span(Eigen::DenseBase<Derived> &v)

Convert an Eigen vector view to a std::span.

template<class Derived>
auto as_span(Eigen::DenseBase<Derived> &&v)

Convert an Eigen vector view to a std::span.

template<class Derived>
auto as_span(const Eigen::DenseBase<Derived> &v)

Convert an Eigen vector view to a std::span.

template<class T, size_t E>
auto as_vec(std::span<T, E> s)

Convert a std::span to an Eigen::Vector view.

template<class Solver>
auto attach_cancellation(Solver &solver)

Attach SIGINT and SIGTERM handlers to stop the given solver.

Parameters:

solver – The solver that should be stopped by the handler.

Returns:

A RAII object that detaches the handler when destroyed.

std::ostream &operator<<(std::ostream &os, SolverStatus s)
template<class Func>
void register_function(function_dict_t *&extra_functions, std::string name, Func &&func)

Make the given function available to alpaqa.

See also

call_extra_func

See also

call_extra_func

template<class Func>
void register_function(problem_register_t &result, std::string name, Func &&func)
template<class Func>
void register_function(control_problem_register_t &result, std::string name, Func &&func)
template<class Result, class T, class Ret, class ...Args>
void register_member_function(Result &result, std::string name, Ret (T::* member)(Args...))
template<auto Member>
static auto member_caller()

Wrap the given member function or variable into a (possibly generic) lambda function that accepts the instance as a type-erased void pointer.

The signature of the resulting function depends on the signature of the member function:

  • Ret Class::member(args...)Ret(void *self, args...)

  • Ret Class::member(args...) constRet(void *self, args...)

  • Ret Class::member(args...) constRet(const void *self, args...)

If the given member is a variable:

  • Type Class::memberType &(void *self)

  • Type Class::memberconst Type &(const void *self)

inline void unregister_functions(function_dict_t *&extra_functions)

Cleans up the extra functions registered by register_function.

Note

This does not need to be called for the functions returned by the registration function, those functions will be cleaned up by alpaqa.

Note

The alpaqa_problem_register_t and alpaqa_control_problem_register_t structs are part of the C API and do not automatically clean up their resources when destroyed, you have to do it manually by calling this function.

inline InnerStatsAccumulator<lbfgsb::LBFGSBStats> &operator+=(InnerStatsAccumulator<lbfgsb::LBFGSBStats> &acc, const lbfgsb::LBFGSBStats &s)
template<Config Conf>
InnerStatsAccumulator<lbfgspp::LBFGSBStats<Conf>> &operator+=(InnerStatsAccumulator<lbfgspp::LBFGSBStats<Conf>> &acc, const lbfgspp::LBFGSBStats<Conf> &s)
OwningQPALMData build_qpalm_problem(const TypeErasedProblem<EigenConfigd> &problem)

Variables

template<class T>
bool is_config_v = is_config<T>::value
template<class T>
bool is_eigen_config_v = is_eigen_config<T>::value
template<Config Conf>
const auto inf = std::numeric_limits<real_t<Conf>>::infinity()
template<Config Conf>
const auto NaN = std::numeric_limits<real_t<Conf>>::quiet_NaN()
template<Config Conf>
const rvec<Conf> null_vec = mvec<Conf>{nullptr, 0}

Global empty vector for convenience.

template<Config Conf>
const rindexvec<Conf> null_indexvec = mindexvec<Conf>{nullptr, 0}

Global empty index vector for convenience.

template<Config Conf = DefaultConfig>
struct ALMParams
#include <alpaqa/outer/alm.hpp>

Parameters for the Augmented Lagrangian solver.

Public Members

real_t tolerance = real_t(1e-5)

Primal tolerance (used for stopping criterion of inner solver).

real_t dual_tolerance = real_t(1e-5)

Dual tolerance (constraint violation and complementarity).

real_t penalty_update_factor = 10

Factor used in updating the penalty parameters.

real_t initial_penalty = 1

Initial penalty parameter.

When set to zero (which is the default), it is computed automatically, based on the constraint violation in the starting point and the parameter initial_penalty_factor.

real_t initial_penalty_factor = 20

Initial penalty parameter factor.

Active if initial_penalty is set to zero.

real_t initial_tolerance = 1

Initial primal tolerance.

real_t tolerance_update_factor = real_t(1e-1)

Update factor for primal tolerance.

real_t rel_penalty_increase_threshold = real_t(0.1)

Error tolerance for penalty increase.

real_t max_multiplier = real_t(1e9)

Lagrange multiplier bound.

real_t max_penalty = real_t(1e9)

Maximum penalty factor.

real_t min_penalty = real_t(1e-9)

Minimum penalty factor (used during initialization).

unsigned int max_iter = 100

Maximum number of outer ALM iterations.

std::chrono::nanoseconds max_time = std::chrono::minutes(5)

Maximum duration.

unsigned print_interval = 0

When to print progress.

If set to zero, nothing will be printed. If set to N != 0, progress is printed every N iterations.

int print_precision = std::numeric_limits<real_t>::max_digits10 / 2

The precision of the floating point values printed by the solver.

bool single_penalty_factor = false

Use one penalty factor for all m constraints.

template<class InnerSolverT>
class ALMSolver
#include <alpaqa/outer/alm.hpp>

Augmented Lagrangian Method solver.

Public Types

using Params = ALMParams<config_t>
using InnerSolver = InnerSolverT
using Problem = typename InnerSolver::Problem

Public Functions

inline ALMSolver(Params params, InnerSolver &&inner_solver)
inline ALMSolver(Params params, const InnerSolver &inner_solver)
Stats operator()(const Problem &problem, rvec x, rvec y, std::optional<rvec> Σ = std::nullopt)
template<class P>
inline Stats operator()(const P &problem, rvec x, rvec y, std::optional<rvec> Σ = std::nullopt)
inline std::string get_name() const
inline void stop()

Abort the computation and return the result so far.

Can be called from other threads or signal handlers.

inline const Params &get_params() const

Public Members

InnerSolver inner_solver
std::ostream *os = &std::cout
struct Stats
#include <alpaqa/outer/alm.hpp>

Public Members

unsigned outer_iterations = 0

Total number of outer ALM iterations (i.e.

the number of times that the inner solver was invoked).

std::chrono::nanoseconds elapsed_time = {}

Total elapsed time.

unsigned inner_convergence_failures = 0

The total number of times that the inner solver failed to converge.

real_t ε = inf<config_t>

Final primal tolerance that was reached, depends on the stopping criterion used by the inner solver, see for example PANOCStopCrit.

real_t δ = inf<config_t>

Final dual tolerance or constraint violation that was reached:

\[\delta = \| \Pi_D\left(g(x^k) + \Sigma^{-1}y\right) \|_\infty \]

real_t norm_penalty = 0

2-norm of the final penalty factors \( \| \Sigma \|_2 \).

SolverStatus status = SolverStatus::Busy

Whether the solver converged or not.

See also

SolverStatus

InnerStatsAccumulator<typename InnerSolver::Stats> inner = {}

The statistics of the inner solver invocations, accumulated over all ALM iterations.

template<Config Conf = DefaultConfig>
class AndersonAccel
#include <alpaqa/accelerators/anderson.hpp>

Anderson Acceleration.

Algorithm for accelerating fixed-point iterations for finding fixed points of a function \( g \), i.e. \( g(x^\star) = x^\star \), or equivalently, roots of the residual \( r(x) \triangleq g(x) - x \).

Public Types

using Params = AndersonAccelParams<config_t>

Public Functions

AndersonAccel() = default
inline AndersonAccel(Params params)
Parameters:

params – Parameters.

inline AndersonAccel(Params params, length_t n)
Parameters:
  • params – Parameters.

  • n – Problem dimension (size of the vectors).

inline void resize(length_t n)

Change the problem dimension.

Flushes the history.

Parameters:

n – Problem dimension (size of the vectors).

inline void initialize(crvec g_0, crvec r_0)

Call this function on the first iteration to initialize the accelerator.

inline void compute(crvec gₖ, crvec rₖ, rvec xₖ_aa)

Compute the accelerated iterate \( x^k_\text{AA} \), given the function value at the current iterate \( g^k = g(x^k) \) and the corresponding residual \( r^k = g^k - x^k \).

inline void compute(crvec gₖ, vec &&rₖ, rvec xₖ_aa)

Compute the accelerated iterate \( x^k_\text{AA} \), given the function value at the current iterate \( g^k = g(x^k) \) and the corresponding residual \( r^k = g^k - x^k \).

inline void reset()

Reset the accelerator (but keep the last function value and residual, so calling initialize is not necessary).

inline length_t n() const

Get the problem dimension.

inline length_t history() const

Get the maximum number of stored columns.

inline length_t current_history() const

Get the number of columns currently stored in the buffer.

inline const Params &get_params() const

Get the parameters.

inline std::string get_name() const
inline void scale_R(real_t scal)

Scale the factorization.

inline const LimitedMemoryQR<config_t> &get_QR() const

For testing purposes.

template<Config Conf = DefaultConfig>
struct AndersonAccelParams
#include <alpaqa/accelerators/anderson.hpp>

Parameters for the AndersonAccel class.

Public Members

length_t memory = 10

Length of the history to keep (the number of columns in the QR factorization).

If this number is greater than the problem dimension, the memory is set to the problem dimension (otherwise the system is underdetermined).

real_t min_div_fac = real_t(1e2) * std::numeric_limits<real_t>::epsilon()

Minimum divisor when solving close to singular systems, scaled by the maximum eigenvalue of R.

template<Config Conf>
struct AndersonDirection
#include <alpaqa/inner/directions/panoc/anderson.hpp>

Public Types

using Problem = TypeErasedProblem<config_t>
using AndersonAccel = alpaqa::AndersonAccel<config_t>
using AcceleratorParams = typename AndersonAccel::Params
using DirectionParams = AndersonDirectionParams<config_t>

Public Functions

AndersonDirection() = default
inline AndersonDirection(const Params &params)
inline AndersonDirection(const typename AndersonAccel::Params &params, const DirectionParams &directionparams = {})
inline AndersonDirection(const AndersonAccel &anderson, const DirectionParams &directionparams = {})
inline AndersonDirection(AndersonAccel &&anderson, const DirectionParams &directionparams = {})
inline void initialize(const Problem &problem, crvec y, crvec Σ, real_t γ_0, crvec x_0, crvec x̂_0, crvec p_0, crvec grad_ψx_0)

See also

initialize

inline bool has_initial_direction() const

inline bool update(real_t γₖ, real_t γₙₑₓₜ, crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, crvec grad_ψxₖ, crvec grad_ψxₙₑₓₜ)

See also

update

inline bool apply(real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const

See also

apply

inline void changed_γ(real_t γₖ, real_t old_γₖ)

See also

changed_γ

inline void reset()

See also

reset

inline std::string get_name() const

See also

get_name

inline auto get_params() const

Public Members

mutable AndersonAccel anderson
DirectionParams direction_params
struct Params
#include <alpaqa/inner/directions/panoc/anderson.hpp>

Public Members

AcceleratorParams accelerator = {}
DirectionParams direction = {}
template<Config Conf>
struct AndersonDirectionParams
#include <alpaqa/inner/directions/panoc/anderson.hpp>

Parameters for the AndersonDirection class.

Public Members

bool rescale_on_step_size_changes = false

Instead of flushing the buffer when the step size changes, rescale the buffer by a factor \( \gamma_k / \gamma_{k-1} \).

template<Config Conf = DefaultConfig>
struct Box
#include <alpaqa/problem/box.hpp>

Public Functions

inline Box()
inline Box(length_t n)

Public Members

vec lower
vec upper

Public Static Functions

static inline Box NaN(length_t n)
static inline Box from_lower_upper(vec lower, vec upper)
template<Config Conf>
class BoxConstrProblem
#include <alpaqa/problem/box-constr-problem.hpp>

Implements common problem functions for minimization problems with box constraints.

Meant to be used as a base class for custom problem implementations. Supports optional \( \ell_1 \)-regularization.

Public Types

using Box = alpaqa::Box<config_t>

Public Functions

inline BoxConstrProblem(length_t num_variables, length_t num_constraints)

Create a problem with inactive boxes \( (-\infty, +\infty) \), with no \( \ell_1 \)-regularization, and all general constraints handled using ALM.

Parameters:
  • num_variables – Number of decision variables

  • num_constraints – Number of constraints

inline BoxConstrProblem(std::tuple<length_t, length_t> dims)

Create a problem with inactive boxes \( (-\infty, +\infty) \), with no \( \ell_1 \)-regularization, and all general constraints handled using ALM.

Parameters:

dims – Number of variables and number of constraints.

inline BoxConstrProblem(Box variable_bounds, Box general_bounds, vec l1_reg = vec(0), index_t penalty_alm_split = 0)
inline void resize(length_t num_variables, length_t num_constraints)

Change the dimensions of the problem (number of decision variables and number of constraints).

Destructive: resizes and/or resets the members variable_bounds, general_bounds, l1_reg and penalty_alm_split.

Parameters:
  • num_variables – Number of decision variables

  • num_constraints – Number of constraints

BoxConstrProblem(const BoxConstrProblem&) = default
BoxConstrProblem &operator=(const BoxConstrProblem&) = default
BoxConstrProblem(BoxConstrProblem&&) noexcept = default
BoxConstrProblem &operator=(BoxConstrProblem&&) noexcept = default
inline length_t get_num_variables() const

Number of decision variables \( n \), num_variables.

inline length_t get_num_constraints() const

Number of constraints \( m \), num_constraints.

inline real_t eval_proximal_gradient_step(real_t γ, crvec x, crvec grad_ψ, rvec x_hat, rvec p) const

inline void eval_projecting_difference_constraints(crvec z, rvec p) const

inline void eval_projection_multipliers(rvec y, real_t M) const

inline const Box &get_variable_bounds() const

inline const Box &get_general_bounds() const

inline bool provides_get_variable_bounds() const

Only supported if the ℓ₁-regularization term is zero.

inline index_t eval_inactive_indices_res_lna(real_t γ, crvec x, crvec grad_ψ, rindexvec J) const

inline void check() const

See also

check

inline std::string get_name() const

See also

get_name

Public Members

length_t num_variables

Number of decision variables, dimension of x.

length_t num_constraints

Number of constraints, dimension of g(x) and z.

Box variable_bounds = {this->num_variables}

Constraints of the decision variables, \( x \in C \).

Box general_bounds = {this->num_constraints}

Other constraints, \( g(x) \in D \).

vec l1_reg = {}

\( \ell_1 \) (1-norm) regularization parameter.

Possible dimensions are: \( 0 \) (no regularization), \( 1 \) (a single scalar factor), or \( n \) (a different factor for each variable).

index_t penalty_alm_split = 0

Components of the constraint function with indices below this number are handled using a quadratic penalty method rather than using an augmented Lagrangian method.

Specifically, the Lagrange multipliers for these components (which determine the shifts in ALM) are kept at zero.

Public Static Functions

static inline real_t eval_proj_grad_step_box(const Box &C, real_t γ, crvec x, crvec grad_ψ, rvec x_hat, rvec p)

Projected gradient step for rectangular box C.

\[\begin{split} \begin{aligned} \hat x &= \Pi_C(x - \gamma\nabla\psi(x)) \\ p &= \hat x - x \\ &= \max(\underline x - x, \;\min(-\gamma\nabla\psi(x), \overline x - x) \end{aligned} \end{split}\]

static inline void eval_prox_grad_step_box_l1_impl(const Box &C, const auto &λ, real_t γ, crvec x, crvec grad_ψ, rvec x_hat, rvec p)

Proximal gradient step for rectangular box C with ℓ₁-regularization.

\[\begin{split} \begin{aligned} h(x) &= \|x\|_1 + \delta_C(x) \\ \hat x &= \prox_{\gamma h}(x - \gamma\nabla\psi(x)) \\ &= -\max\big( x - \overline x, \;\min\big( x - \underline x, \;\min\big( \gamma(\nabla\psi(x) + \lambda), \;\max\big( \gamma(\nabla\psi(x) - \lambda), x \big) \big) \big) \big) \end{aligned} \end{split}\]

static inline real_t eval_prox_grad_step_box_l1(const Box &C, const auto &λ, real_t γ, crvec x, crvec grad_ψ, rvec x_hat, rvec p)

Proximal gradient step for rectangular box C with ℓ₁-regularization.

\[\begin{split} \begin{aligned} h(x) &= \|x\|_1 + \delta_C(x) \\ \hat x &= \prox_{\gamma h}(x - \gamma\nabla\psi(x)) \\ &= -\max\big( x - \overline x, \;\min\big( x - \underline x, \;\min\big( \gamma(\nabla\psi(x) + \lambda), \;\max\big( \gamma(\nabla\psi(x) - \lambda), x \big) \big) \big) \big) \end{aligned} \end{split}\]

static inline real_t eval_prox_grad_step_box_l1_scal(const Box &C, real_t λ, real_t γ, crvec x, crvec grad_ψ, rvec x_hat, rvec p)

Proximal gradient step for rectangular box C with ℓ₁-regularization.

\[\begin{split} \begin{aligned} h(x) &= \|x\|_1 + \delta_C(x) \\ \hat x &= \prox_{\gamma h}(x - \gamma\nabla\psi(x)) \\ &= -\max\big( x - \overline x, \;\min\big( x - \underline x, \;\min\big( \gamma(\nabla\psi(x) + \lambda), \;\max\big( \gamma(\nabla\psi(x) - \lambda), x \big) \big) \big) \big) \end{aligned} \end{split}\]

static inline void eval_proj_multipliers_box(const Box &D, rvec y, real_t M, index_t penalty_alm_split)
template<Config Conf>
class CasADiControlProblem
#include <alpaqa/casadi/CasADiControlProblem.hpp>

Public Types

using Box = alpaqa::Box<config_t>

Public Functions

CasADiControlProblem(const std::string &filename, length_t N, DynamicLoadFlags dl_flags = {})
~CasADiControlProblem()
CasADiControlProblem(const CasADiControlProblem&)
CasADiControlProblem &operator=(const CasADiControlProblem&)
CasADiControlProblem(CasADiControlProblem&&) noexcept
CasADiControlProblem &operator=(CasADiControlProblem&&) noexcept
void load_numerical_data(const std::filesystem::path &filepath, char sep = ',')

Load the numerical problem data (bounds and parameters) from a CSV file.

The file should contain 8 rows, with the following contents:

  1. U lower bound [nu]

  2. U upper bound [nu]

  3. D lower bound [nc]

  4. D upper bound [nc]

  5. D_N lower bound [nc_N]

  6. D_N upper bound [nc_N]

  7. x_init [nx]

  8. param [p]

Line endings are encoded using a single line feed (\n), and the column separator can be specified using the sep argument.

inline void get_U(Box &U) const
inline void get_D(Box &D) const
inline void get_D_N(Box &D_N) const
inline void get_x_init(rvec x_init) const
void eval_f(index_t timestep, crvec x, crvec u, rvec fxu) const
void eval_jac_f(index_t timestep, crvec x, crvec u, rmat J_fxu) const
void eval_grad_f_prod(index_t timestep, crvec x, crvec u, crvec p, rvec grad_fxu_p) const
void eval_h(index_t timestep, crvec x, crvec u, rvec h) const
void eval_h_N(crvec x, rvec h) const
real_t eval_l(index_t timestep, crvec h) const
real_t eval_l_N(crvec h) const
void eval_qr(index_t timestep, crvec xu, crvec h, rvec qr) const
void eval_q_N(crvec x, crvec h, rvec q) const
void eval_add_Q(index_t timestep, crvec xu, crvec h, rmat Q) const
void eval_add_Q_N(crvec x, crvec h, rmat Q) const
void eval_add_R_masked(index_t timestep, crvec xu, crvec h, crindexvec mask, rmat R, rvec work) const
void eval_add_S_masked(index_t timestep, crvec xu, crvec h, crindexvec mask, rmat S, rvec work) const
void eval_add_R_prod_masked(index_t timestep, crvec xu, crvec h, crindexvec mask_J, crindexvec mask_K, crvec v, rvec out, rvec work) const
void eval_add_S_prod_masked(index_t timestep, crvec xu, crvec h, crindexvec mask_K, crvec v, rvec out, rvec work) const
length_t get_R_work_size() const
length_t get_S_work_size() const
void eval_constr(index_t timestep, crvec x, rvec c) const
void eval_grad_constr_prod(index_t timestep, crvec x, crvec p, rvec grad_cx_p) const
void eval_add_gn_hess_constr(index_t timestep, crvec x, crvec M, rmat out) const
void eval_constr_N(crvec x, rvec c) const
void eval_grad_constr_prod_N(crvec x, crvec p, rvec grad_cx_p) const
void eval_add_gn_hess_constr_N(crvec x, crvec M, rmat out) const
inline void check() const
inline length_t get_N() const
inline length_t get_nx() const
inline length_t get_nu() const
inline length_t get_nh() const
inline length_t get_nh_N() const
inline length_t get_nc() const
inline length_t get_nc_N() const
inline void eval_projecting_difference_constraints(crvec z, rvec e) const

inline void eval_projection_multipliers(rvec y, real_t M) const

Public Members

length_t N
length_t nx
length_t nu
length_t nh
length_t nh_N
length_t nc
length_t nc_N
vec x_init
vec param
Box U
Box D
Box D_N
mutable vec work
index_t penalty_alm_split = 0

Components of the constraint function with indices below this number are handled using a quadratic penalty method rather than using an augmented Lagrangian method.

Specifically, the Lagrange multipliers for these components (which determine the shifts in ALM) are kept at zero.

index_t penalty_alm_split_N = 0

Same as penalty_alm_split, but for the terminal constraint.

struct CasADiFunctions
#include <alpaqa/casadi/CasADiProblem.hpp>

Public Functions

~CasADiFunctions()

Public Members

std::map<std::string, casadi::Function> functions
template<Config Conf = EigenConfigd>
class CasADiProblem : public BoxConstrProblem<EigenConfigd>
#include <alpaqa/casadi/CasADiProblem.hpp>

Problem definition for a CasADi problem, loaded from a DLL.

Public Functions

CasADiProblem(const std::string &filename, DynamicLoadFlags dl_flags = {})

Load a problem generated by CasADi (with parameters).

The file should contain functions with the names f, grad_f, g and grad_g. These functions evaluate the objective function, its gradient, the constraints, and the constraint gradient times a vector respectively. For second order solvers, additional functions hess_L, hess_ψ, hess_L_prod and hess_ψ_prod can be provided to evaluate the Hessian of the (augmented) Lagrangian and Hessian-vector products.

Parameters:
  • filename – Filename of the shared library to load the functions from.

  • dl_flags – Flags passed to dlopen when loading the problem.

Throws:

std::invalid_argument – The dimensions of the loaded functions do not match.

CasADiProblem(const SerializedCasADiFunctions &functions)

Create a problem from a collection of serialized CasADi functions.

CasADiProblem(const CasADiFunctions &functions)

Create a problem from a collection of CasADi functions.

~CasADiProblem()
CasADiProblem(const CasADiProblem&)
CasADiProblem &operator=(const CasADiProblem&)
CasADiProblem(CasADiProblem&&) noexcept
CasADiProblem &operator=(CasADiProblem&&) noexcept
void load_numerical_data(const std::filesystem::path &filepath, char sep = ',')

Load the numerical problem data (bounds and parameters) from a CSV file.

The file should contain 7 rows, with the following contents:

  1. variable_bounds lower bound [n]

  2. variable_bounds upper bound [n]

  3. general_bounds lower bound [m]

  4. general_bounds upper bound [m]

  5. param [p]

  6. l1_reg [0, 1 or n]

  7. penalty_alm_split [1]

Line endings are encoded using a single line feed (\n), and the column separator can be specified using the sep argument.

real_t eval_objective(crvec x) const
void eval_objective_gradient(crvec x, rvec grad_fx) const
real_t eval_objective_and_gradient(crvec x, rvec grad_fx) const
void eval_constraints(crvec x, rvec g) const
void eval_constraints_gradient_product(crvec x, crvec y, rvec grad_gxy) const
void eval_augmented_lagrangian_gradient(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
real_t eval_augmented_lagrangian_and_gradient(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
void eval_lagrangian_gradient(crvec x, crvec y, rvec grad_L, rvec work_n) const
real_t eval_augmented_lagrangian(crvec x, crvec y, crvec Σ, rvec ŷ) const
void eval_grad_gi(crvec x, index_t i, rvec grad_i) const
Sparsity get_constraints_jacobian_sparsity() const
void eval_constraints_jacobian(crvec x, rvec J_values) const
void eval_lagrangian_hessian_product(crvec x, crvec y, real_t scale, crvec v, rvec Hv) const
Sparsity get_lagrangian_hessian_sparsity() const
void eval_lagrangian_hessian(crvec x, crvec y, real_t scale, rvec H_values) const
void eval_augmented_lagrangian_hessian_product(crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
Sparsity get_augmented_lagrangian_hessian_sparsity() const
void eval_augmented_lagrangian_hessian(crvec x, crvec y, crvec Σ, real_t scale, rvec H_values) const
bool provides_eval_lagrangian_gradient() const

bool provides_eval_augmented_lagrangian() const

bool provides_eval_augmented_lagrangian_gradient() const

bool provides_eval_augmented_lagrangian_and_gradient() const

bool provides_eval_grad_gi() const

bool provides_eval_constraints_jacobian() const

bool provides_eval_lagrangian_hessian_product() const

bool provides_eval_lagrangian_hessian() const

bool provides_eval_augmented_lagrangian_hessian_product() const

bool provides_eval_augmented_lagrangian_hessian() const

std::string get_name() const

See also

get_name

Public Members

vec param
std::string name = "CasADiProblem"
template<Config Conf = DefaultConfig>
struct CBFGSParams
#include <alpaqa/accelerators/lbfgs.hpp>

Cautious BFGS update.

See also

cbfgs

Public Functions

inline explicit operator bool() const

Public Members

real_t α = 1
real_t ϵ = 0

Set to zero to disable CBFGS check.

template<Config Conf>
struct ControlProblemVTable : public BasicVTable
#include <alpaqa/problem/ocproblem.hpp>

Public Types

using Box = alpaqa::Box<config_t>
template<class F>
using optional_function_t = guanaqo::optional_function_t<F, ControlProblemVTable>
template<class F>
using required_function_t = guanaqo::required_function_t<F>

Public Functions

template<class P>
inline ControlProblemVTable(std::in_place_t, P &p)
ControlProblemVTable() = default

Public Members

required_function_t<void(crvec z, rvec e) const> eval_projecting_difference_constraints
required_function_t<void(rvec y, real_t M) const> eval_projection_multipliers
required_function_t<void(Box &U) const> get_U
optional_function_t<void(Box &D) const> get_D = nullptr
optional_function_t<void(Box &D) const> get_D_N = &default_get_D_N
required_function_t<void(rvec x_init) const> get_x_init
required_function_t<void(index_t timestep, crvec x, crvec u, rvec fxu) const> eval_f
required_function_t<void(index_t timestep, crvec x, crvec u, rmat J_fxu) const> eval_jac_f
required_function_t<void(index_t timestep, crvec x, crvec u, crvec p, rvec grad_fxu_p) const> eval_grad_f_prod
optional_function_t<void(index_t timestep, crvec x, crvec u, rvec h) const> eval_h = nullptr
optional_function_t<void(crvec x, rvec h) const> eval_h_N = nullptr
required_function_t<real_t(index_t timestep, crvec h) const> eval_l
required_function_t<real_t(crvec h) const> eval_l_N
required_function_t<void(index_t timestep, crvec xu, crvec h, rvec qr) const> eval_qr
required_function_t<void(crvec x, crvec h, rvec q) const> eval_q_N
required_function_t<void(index_t timestep, crvec xu, crvec h, rmat Q) const> eval_add_Q
optional_function_t<void(crvec x, crvec h, rmat Q) const> eval_add_Q_N = &default_eval_add_Q_N
required_function_t<void(index_t timestep, crvec xu, crvec h, crindexvec mask, rmat R, rvec work) const> eval_add_R_masked
required_function_t<void(index_t timestep, crvec xu, crvec h, crindexvec mask, rmat S, rvec work) const> eval_add_S_masked
optional_function_t<void(index_t timestep, crvec xu, crvec h, crindexvec mask_J, crindexvec mask_K, crvec v, rvec out, rvec work) const> eval_add_R_prod_masked = &default_eval_add_R_prod_masked
optional_function_t<void(index_t timestep, crvec xu, crvec h, crindexvec mask_K, crvec v, rvec out, rvec work) const> eval_add_S_prod_masked = &default_eval_add_S_prod_masked
optional_function_t<length_t() const> get_R_work_size = &default_get_R_work_size
optional_function_t<length_t() const> get_S_work_size = &default_get_S_work_size
optional_function_t<void(index_t timestep, crvec x, rvec c) const> eval_constr = nullptr
optional_function_t<void(crvec x, rvec c) const> eval_constr_N = &default_eval_constr_N
optional_function_t<void(index_t timestep, crvec x, crvec p, rvec grad_cx_p) const> eval_grad_constr_prod = nullptr
optional_function_t<void(crvec x, crvec p, rvec grad_cx_p) const> eval_grad_constr_prod_N = &default_eval_grad_constr_prod_N
optional_function_t<void(index_t timestep, crvec x, crvec M, rmat out) const> eval_add_gn_hess_constr = nullptr
optional_function_t<void(crvec x, crvec M, rmat out) const> eval_add_gn_hess_constr_N = &default_eval_add_gn_hess_constr_N
required_function_t<void() const> check
length_t N
length_t nu
length_t nx
length_t nh
length_t nh_N
length_t nc
length_t nc_N

Public Static Functions

static void default_get_D_N(const void *self, Box &D, const ControlProblemVTable &vtable)
static void default_eval_add_Q_N(const void *self, crvec x, crvec h, rmat Q, const ControlProblemVTable &vtable)
static void default_eval_add_R_prod_masked(const void*, index_t, crvec, crvec, crindexvec, crindexvec, crvec, rvec, rvec, const ControlProblemVTable&)
static void default_eval_add_S_prod_masked(const void*, index_t, crvec, crvec, crindexvec, crvec, rvec, rvec, const ControlProblemVTable&)
static length_t default_get_R_work_size(const void*, const ControlProblemVTable&)
static length_t default_get_S_work_size(const void*, const ControlProblemVTable&)
static void default_eval_constr_N(const void *self, crvec x, rvec c, const ControlProblemVTable &vtable)
static void default_eval_grad_constr_prod_N(const void *self, crvec x, crvec p, rvec grad_cx_p, const ControlProblemVTable &vtable)
static void default_eval_add_gn_hess_constr_N(const void *self, crvec x, crvec M, rmat out, const ControlProblemVTable &vtable)
template<class Problem>
struct ControlProblemWithCounters
#include <alpaqa/problem/ocproblem.hpp>

Public Types

using Box = typename TypeErasedControlProblem<config_t>::Box

Public Functions

inline length_t get_N() const
inline length_t get_nu() const
inline length_t get_nx() const
inline length_t get_nh() const
inline length_t get_nh_N() const
inline length_t get_nc() const
inline length_t get_nc_N() const
inline void eval_projecting_difference_constraints(crvec z, rvec e) const
inline void eval_projection_multipliers(rvec y, real_t M) const
inline void get_x_init(rvec x_init) const
inline length_t get_R_work_size() const
inline length_t get_S_work_size() const
inline void get_U(Box &U) const
inline void get_D(Box &D) const
inline void get_D_N(Box &D) const
inline void eval_f(index_t timestep, crvec x, crvec u, rvec fxu) const
inline void eval_jac_f(index_t timestep, crvec x, crvec u, rmat J_fxu) const
inline void eval_grad_f_prod(index_t timestep, crvec x, crvec u, crvec p, rvec grad_fxu_p) const
inline void eval_h(index_t timestep, crvec x, crvec u, rvec h) const
inline void eval_h_N(crvec x, rvec h) const
inline real_t eval_l(index_t timestep, crvec h) const
inline real_t eval_l_N(crvec h) const
inline void eval_qr(index_t timestep, crvec xu, crvec h, rvec qr) const
inline void eval_q_N(crvec x, crvec h, rvec q) const
inline void eval_add_Q(index_t timestep, crvec xu, crvec h, rmat Q) const
inline void eval_add_Q_N(crvec x, crvec h, rmat Q) const
inline void eval_add_R_masked(index_t timestep, crvec xu, crvec h, crindexvec mask, rmat R, rvec work) const
inline void eval_add_S_masked(index_t timestep, crvec xu, crvec h, crindexvec mask, rmat S, rvec work) const
inline void eval_add_R_prod_masked(index_t timestep, crvec xu, crvec h, crindexvec mask_J, crindexvec mask_K, crvec v, rvec out, rvec work) const
inline void eval_add_S_prod_masked(index_t timestep, crvec xu, crvec h, crindexvec mask_K, crvec v, rvec out, rvec work) const
inline void eval_constr(index_t timestep, crvec x, rvec c) const
inline void eval_constr_N(crvec x, rvec c) const
inline void eval_grad_constr_prod(index_t timestep, crvec x, crvec p, rvec grad_cx_p) const
inline void eval_grad_constr_prod_N(crvec x, crvec p, rvec grad_cx_p) const
inline void eval_add_gn_hess_constr(index_t timestep, crvec x, crvec M, rmat out) const
inline void eval_add_gn_hess_constr_N(crvec x, crvec M, rmat out) const
inline void check() const
inline bool provides_get_D() const
inline bool provides_get_D_N() const
inline bool provides_eval_add_Q_N() const
inline bool provides_eval_add_R_prod_masked() const
inline bool provides_eval_add_S_prod_masked() const
inline bool provides_get_R_work_size() const
inline bool provides_get_S_work_size() const
inline bool provides_eval_constr() const
inline bool provides_eval_constr_N() const
inline bool provides_eval_grad_constr_prod() const
inline bool provides_eval_grad_constr_prod_N() const
inline bool provides_eval_add_gn_hess_constr() const
inline bool provides_eval_add_gn_hess_constr_N() const
ControlProblemWithCounters() = default
template<class P>
inline explicit ControlProblemWithCounters(P &&problem)
template<class ...Args>
inline explicit ControlProblemWithCounters(std::in_place_t, Args&&... args)
inline void reset_evaluations()

Reset all evaluation counters and timers to zero.

Affects all instances that share the same evaluations. If you only want to reset the counters of this instance, use decouple_evaluations first.

inline void decouple_evaluations()

Give this instance its own evaluation counters and timers, decoupling it from any other instances they might have previously been shared with.

The evaluation counters and timers are preserved (a copy is made).

Public Members

std::shared_ptr<OCPEvalCounter> evaluations = std::make_shared<OCPEvalCounter>()
Problem problem
template<Config Conf = DefaultConfig>
struct ConvexNewtonDirection
#include <alpaqa/inner/directions/panoc/convex-newton.hpp>

Public Types

using Problem = TypeErasedProblem<config_t>
using DirectionParams = ConvexNewtonDirectionParams<config_t>
using AcceleratorParams = ConvexNewtonRegularizationParams<config_t>

Public Functions

ConvexNewtonDirection() = default
inline ConvexNewtonDirection(const Params &params)
inline ConvexNewtonDirection(const AcceleratorParams &params, const DirectionParams &directionparams = {})
inline void initialize(const Problem &problem, crvec y, crvec Σ, real_t γ_0, crvec x_0, crvec x̂_0, crvec p_0, crvec grad_ψx_0)

See also

initialize

inline bool has_initial_direction() const

inline bool update(real_t γₖ, real_t γₙₑₓₜ, crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, crvec grad_ψxₖ, crvec grad_ψxₙₑₓₜ)

See also

update

template<class Solver>
inline void solve(rmat H, rvec q) const
inline bool apply(real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const

See also

apply

inline void changed_γ(real_t γₖ, real_t old_γₖ)

See also

changed_γ

inline void reset()

See also

reset

inline std::string get_name() const

See also

get_name

inline const auto &get_params() const

Public Members

AcceleratorParams reg_params
DirectionParams direction_params
struct Params
#include <alpaqa/inner/directions/panoc/convex-newton.hpp>

Public Members

AcceleratorParams accelerator = {}
DirectionParams direction = {}
template<Config Conf>
struct ConvexNewtonDirectionParams
#include <alpaqa/inner/directions/panoc/convex-newton.hpp>

Parameters for the ConvexNewtonDirection class.

Public Members

real_t hessian_vec_factor = 0

Set this option to a nonzero value to include the Hessian-vector product \( \nabla^2_{x_\mathcal{J}x_\mathcal{K}}\psi(x) q_\mathcal{K} \) from equation 12b in [4], scaled by this parameter.

Set it to zero to leave out that term.

bool quadratic = false
template<Config Conf>
struct ConvexNewtonRegularizationParams
#include <alpaqa/inner/directions/panoc/convex-newton.hpp>

Parameters for the ConvexNewtonDirection class.

Public Members

real_t ζ = real_t(1e-8)
real_t ν = 1
bool ldlt = false
class CUTEstLoader

Public Types

using Box = alpaqa::Box<config_t>
using logical_vec = Eigen::VectorX<logical>

Pointers to loaded problem functions.

Public Functions

inline CUTEstLoader(const char *so_fname, const char *outsdif_fname, DynamicLoadFlags dl_flags)
inline void setup_problem(rvec x0, rvec y0, Box &C, Box &D)
inline std::string get_name()
inline void get_report(double *calls, double *time)

Public Members

std::shared_ptr<void> so_handle

dlopen handle to shared library

cleanup_t cleanup_outsdif

Responsible for closing the OUTSDIF.d file.

cleanup_t cutest_terminate

Responsible for calling CUTEST_xterminate.

integer funit = 42

Fortran Unit Number for OUTSDIF.d file.

integer iout = 6

Fortran Unit Number for standard output.

integer io_buffer = 11

Fortran Unit Number for internal IO.

integer nvar

Number of decision variabls.

integer ncon

Number of constraints.

ConstrFuncs funcs
logical_vec equatn

whether the constraint is an equality

logical_vec linear

whether the constraint is linear

mutable vec work
vec work2

work vectors

struct ConstrFuncs

Public Members

cutest::cfn::signature_t *cfn
cutest::cofg::signature_t *cofg
cutest::ccfg::signature_t *ccfg
cutest::clfg::signature_t *clfg
cutest::cjprod::signature_t *cjprod
cutest::ccifg::signature_t *ccifg
cutest::cigr::signature_t *cigr
cutest::cdimsj::signature_t *cdimsj
cutest::csjp::signature_t *csjp
cutest::ccfsg::signature_t *ccfsg
cutest::cdh::signature_t *cdh
cutest::cdimsh::signature_t *cdimsh
cutest::cshp::signature_t *cshp
cutest::csh::signature_t *csh
cutest::chprod::signature_t *chprod
class CUTEstProblem : public BoxConstrProblem<alpaqa::EigenConfigd>
#include <alpaqa/cutest/cutest-loader.hpp>

Wrapper for CUTEst problems loaded from an external shared library.

Public Functions

CUTEstProblem(const char *so_fname, const char *outsdif_fname = nullptr, bool sparse = false, DynamicLoadFlags dl_flags = {})

Load a CUTEst problem from the given shared library and OUTSDIF.d file.

If so_fname points to a directory, "PROBLEM.so" is appended automatically. If outsdif_fname is nullptr, the same directory as so_fname is used.

CUTEstProblem(const CUTEstProblem&)
CUTEstProblem &operator=(const CUTEstProblem&)
CUTEstProblem(CUTEstProblem&&) noexcept
CUTEstProblem &operator=(CUTEstProblem&&) noexcept
~CUTEstProblem()
Report get_report() const
std::ostream &format_report(std::ostream &os, const Report &r) const
inline std::ostream &format_report(std::ostream &os) const
real_t eval_objective(crvec x) const
void eval_objective_gradient(crvec x, rvec grad_fx) const
void eval_constraints(crvec x, rvec gx) const
void eval_constraints_gradient_product(crvec x, crvec y, rvec grad_gxy) const
void eval_constraints_jacobian(crvec x, rvec J_values) const
Sparsity get_constraints_jacobian_sparsity() const
void eval_grad_gi(crvec x, index_t i, rvec grad_gi) const
void eval_lagrangian_hessian_product(crvec x, crvec y, real_t scale, crvec v, rvec Hv) const
void eval_lagrangian_hessian(crvec x, crvec y, real_t scale, rvec H_values) const
Sparsity get_lagrangian_hessian_sparsity() const
void eval_augmented_lagrangian_hessian_product(crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
real_t eval_objective_and_gradient(crvec x, rvec grad_fx) const
real_t eval_objective_and_constraints(crvec x, rvec g) const
void eval_lagrangian_gradient(crvec x, crvec y, rvec grad_L, rvec work_n) const
inline std::string get_name() const

Public Members

std::string name = "<UNKNOWN>"

Problem name.

vec x0

Initial value of decision variables.

vec y0

Initial value of Lagrange multipliers.

struct Report
#include <alpaqa/cutest/cutest-loader.hpp>

The report generated by CUTEst.

See also

man CUTEST_creport and man CUTEST_ureport

Public Members

Calls calls

Function call counters.

double time_setup = 0

CPU time (in seconds) for CUTEST_csetup.

double time = 0

CPU time (in seconds) since the end of CUTEST_csetup.

struct Calls
#include <alpaqa/cutest/cutest-loader.hpp>

Function call counters.

Note

Note that hessian_times_vector, constraints and constraints_grad may account for codes which allow the evaluation of a selection of constraints only and may thus be much smaller than the number of constraints times the number of iterations.

Public Members

unsigned objective = 0

Number of calls to the objective function.

unsigned objective_grad = 0

Number of calls to the objective gradient.

unsigned objective_hess = 0

Number of calls to the objective Hessian.

unsigned hessian_times_vector = 0

Number of Hessian times vector products.

unsigned constraints = 0

Number of calls to the constraint functions.

unsigned constraints_grad = 0

Number of calls to the constraint gradients.

unsigned constraints_hess = 0

Number of calls to the constraint Hessians.

template<Config Conf>
struct Dim
#include <alpaqa/inner/directions/panoc-ocp/lqr.hpp>

Public Functions

inline Horizon horizon() const

Public Members

length_t N
length_t nx
length_t nu
struct Horizon
#include <alpaqa/inner/directions/panoc-ocp/lqr.hpp>

Public Functions

inline Iter end() const

Public Members

length_t N

Public Static Functions

static inline Iter begin()
struct Iter
#include <alpaqa/inner/directions/panoc-ocp/lqr.hpp>

Public Functions

inline Iter &operator++()
inline Iter operator++(int) const
inline index_t &operator*()
inline const index_t &operator*() const

Public Members

index_t i

Friends

friend auto operator<=>(const Iter&, const Iter&) = default
template<class RealT>
struct EigenConfig
#include <alpaqa/config/config.hpp>

Public Types

using real_t = RealT

Real scalar element type.

using cplx_t = std::complex<real_t>

Complex scalar element type.

using vec = Eigen::VectorX<real_t>

Dynamic vector type.

using mvec = Eigen::Map<vec>

Map of vector type.

using cmvec = Eigen::Map<const vec>

Immutable map of vector type.

using rvec = Eigen::Ref<vec>

Reference to mutable vector.

using crvec = Eigen::Ref<const vec>

Reference to immutable vector.

using mat = Eigen::MatrixX<real_t>

Dynamic matrix type.

using mmat = Eigen::Map<mat>

Map of matrix type.

using cmmat = Eigen::Map<const mat>

Immutable map of matrix type.

using rmat = Eigen::Ref<mat>

Reference to mutable matrix.

using crmat = Eigen::Ref<const mat>

Reference to immutable matrix.

using cmat = Eigen::MatrixX<cplx_t>

Dynamic complex matrix type.

using mcmat = Eigen::Map<cmat>

Map of complex matrix type.

using cmcmat = Eigen::Map<const cmat>

Immutable map of complex matrix type.

using rcmat = Eigen::Ref<cmat>

Reference to mutable complex matrix.

using crcmat = Eigen::Ref<const cmat>

Reference to immutable complex matrix.

using length_t = Eigen::Index

Type for lengths and sizes.

using index_t = Eigen::Index

Type for vector and matrix indices.

using indexvec = Eigen::VectorX<index_t>

Dynamic vector of indices.

using rindexvec = Eigen::Ref<indexvec>

Reference to mutable index vector.

using crindexvec = Eigen::Ref<const indexvec>

Reference to immutable index vector.

using mindexvec = Eigen::Map<indexvec>

Map of index vector type.

using cmindexvec = Eigen::Map<const indexvec>

Immutable map of index vector type.

Public Static Attributes

static bool supports_indexvec = true

Whether indexing by vectors of indices is supported.

struct EigenConfigd : public EigenConfig<double>
#include <alpaqa/config/config.hpp>

Double-precision double configuration.

Public Static Functions

static inline const char *get_name()
struct EigenConfigf : public EigenConfig<float>
#include <alpaqa/config/config.hpp>

Single-precision float configuration.

Public Static Functions

static inline const char *get_name()
struct EigenConfigl : public EigenConfig<long double>
#include <alpaqa/config/config.hpp>

long double configuration.

(Quad precision on ARM64, 80-bit x87 floats on Intel/AMD x86)

Public Static Functions

static inline const char *get_name()
struct EvalCounter
#include <alpaqa/problem/problem-counters.hpp>

Public Functions

inline void reset()

Public Members

unsigned projecting_difference_constraints = {}
unsigned projection_multipliers = {}
unsigned proximal_gradient_step = {}
unsigned inactive_indices_res_lna = {}
unsigned objective = {}
unsigned objective_gradient = {}
unsigned objective_and_gradient = {}
unsigned objective_and_constraints = {}
unsigned objective_gradient_and_constraints_gradient_product = {}
unsigned constraints = {}
unsigned constraints_gradient_product = {}
unsigned grad_gi = {}
unsigned constraints_jacobian = {}
unsigned lagrangian_gradient = {}
unsigned lagrangian_hessian_product = {}
unsigned lagrangian_hessian = {}
unsigned augmented_lagrangian_hessian_product = {}
unsigned augmented_lagrangian_hessian = {}
unsigned augmented_lagrangian = {}
unsigned augmented_lagrangian_gradient = {}
unsigned augmented_lagrangian_and_gradient = {}
struct alpaqa::EvalCounter::EvalTimer time
struct EvalTimer
#include <alpaqa/problem/problem-counters.hpp>

Public Members

std::chrono::nanoseconds projecting_difference_constraints = {}
std::chrono::nanoseconds projection_multipliers = {}
std::chrono::nanoseconds proximal_gradient_step = {}
std::chrono::nanoseconds inactive_indices_res_lna = {}
std::chrono::nanoseconds objective = {}
std::chrono::nanoseconds objective_gradient = {}
std::chrono::nanoseconds objective_and_gradient = {}
std::chrono::nanoseconds objective_and_constraints = {}
std::chrono::nanoseconds objective_gradient_and_constraints_gradient_product = {}
std::chrono::nanoseconds constraints = {}
std::chrono::nanoseconds constraints_gradient_product = {}
std::chrono::nanoseconds grad_gi = {}
std::chrono::nanoseconds constraints_jacobian = {}
std::chrono::nanoseconds lagrangian_gradient = {}
std::chrono::nanoseconds lagrangian_hessian_product = {}
std::chrono::nanoseconds lagrangian_hessian = {}
std::chrono::nanoseconds augmented_lagrangian_hessian_product = {}
std::chrono::nanoseconds augmented_lagrangian_hessian = {}
std::chrono::nanoseconds augmented_lagrangian = {}
std::chrono::nanoseconds augmented_lagrangian_gradient = {}
std::chrono::nanoseconds augmented_lagrangian_and_gradient = {}
template<Config Conf = DefaultConfig>
struct FISTAParams
#include <alpaqa/inner/fista.hpp>

Tuning parameters for the FISTA algorithm.

Public Members

LipschitzEstimateParams<config_t> Lipschitz = {}

Parameters related to the Lipschitz constant estimate and step size.

unsigned max_iter = 1000

Maximum number of inner FISTA iterations.

std::chrono::nanoseconds max_time = std::chrono::minutes(5)

Maximum duration.

real_t L_min = real_t(1e-5)

Minimum Lipschitz constant estimate.

real_t L_max = real_t(1e20)

Maximum Lipschitz constant estimate.

PANOCStopCrit stop_crit = PANOCStopCrit::ApproxKKT

What stopping criterion to use.

unsigned max_no_progress = 10

Maximum number of iterations without any progress before giving up.

unsigned print_interval = 0

When to print progress.

If set to zero, nothing will be printed. If set to N != 0, progress is printed every N iterations.

int print_precision = std::numeric_limits<real_t>::max_digits10 / 2

The precision of the floating point values printed by the solver.

real_t quadratic_upperbound_tolerance_factor = 10 * std::numeric_limits<real_t>::epsilon()

Tolerance factor used in the quadratic upper bound condition that determines the step size.

Its goal is to account for numerical errors in the function and gradient evaluations. If you notice that the step size γ becomes very small, you may want to increase this factor.

bool disable_acceleration = false

Don’t compute accelerated steps, fall back to forward-backward splitting.

For testing purposes.

template<Config Conf = DefaultConfig>
struct FISTAProgressInfo
#include <alpaqa/inner/fista.hpp>

Public Members

unsigned k
SolverStatus status
crvec x
crvec p
real_t norm_sq_p
crvec x_hat
crvec ŷ
real_t φγ
real_t ψ
crvec grad_ψ
real_t ψ_hat
crvec grad_ψ_hat
real_t L
real_t γ
real_t t
real_t ε
crvec Σ
crvec y
unsigned outer_iter
const TypeErasedProblem<config_t> *problem
const FISTAParams<config_t> *params
template<Config Conf>
class FISTASolver
#include <alpaqa/inner/fista.hpp>

FISTA solver for ALM.

Public Types

using Problem = TypeErasedProblem<config_t>
using Params = FISTAParams<config_t>
using Stats = FISTAStats<config_t>
using ProgressInfo = FISTAProgressInfo<config_t>
using SolveOptions = InnerSolveOptions<config_t>

Public Functions

inline FISTASolver(const Params &params)
Stats operator()(const Problem &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec err_z)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec e)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec x)
inline FISTASolver &set_progress_callback(std::function<void(const ProgressInfo&)> cb)

Specify a callable that is invoked with some intermediate results on each iteration of the algorithm.

See also

ProgressInfo

std::string get_name() const
inline void stop()
inline const Params &get_params() const

Public Members

std::ostream *os = &std::cout
template<Config Conf = DefaultConfig>
struct FISTAStats
#include <alpaqa/inner/fista.hpp>

Public Members

SolverStatus status = SolverStatus::Busy
real_t ε = inf<config_t>
std::chrono::nanoseconds elapsed_time = {}
std::chrono::nanoseconds time_progress_callback = {}
unsigned iterations = 0
unsigned stepsize_backtracks = 0
real_t final_γ = 0
real_t final_ψ = 0
real_t final_h = 0
template<Config Conf = DefaultConfig>
class FunctionalProblem : public BoxConstrProblem<DefaultConfig>
#include <alpaqa/problem/functional-problem.hpp>

Problem class that allows specifying the basic functions as C++ std::functions.

Public Functions

inline real_t eval_objective(crvec x) const
inline void eval_objective_gradient(crvec x, rvec grad_fx) const
inline void eval_constraints(crvec x, rvec gx) const
inline void eval_constraints_gradient_product(crvec x, crvec y, rvec grad_gxy) const
inline void eval_grad_gi(crvec x, index_t i, rvec grad_gix) const
inline void eval_lagrangian_hessian_product(crvec x, crvec y, real_t scale, crvec v, rvec Hv) const
inline void eval_augmented_lagrangian_hessian_product(crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
inline void eval_constraints_jacobian(crvec x, rvec J_values) const
inline void eval_lagrangian_hessian(crvec x, crvec y, real_t scale, rvec H_values) const
inline void eval_augmented_lagrangian_hessian(crvec x, crvec y, crvec Σ, real_t scale, rvec H_values) const
inline bool provides_eval_grad_gi() const

inline bool provides_eval_constraints_jacobian() const

inline bool provides_eval_lagrangian_hessian_product() const

inline bool provides_eval_lagrangian_hessian() const

inline bool provides_eval_augmented_lagrangian_hessian_product() const

inline bool provides_eval_augmented_lagrangian_hessian() const

inline std::string get_name() const

See also

get_name

FunctionalProblem(const FunctionalProblem&) = default
FunctionalProblem &operator=(const FunctionalProblem&) = default
FunctionalProblem(FunctionalProblem&&) noexcept = default
FunctionalProblem &operator=(FunctionalProblem&&) noexcept = default

Public Members

std::function<real_t(crvec)> f
std::function<void(crvec, rvec)> grad_f
std::function<void(crvec, rvec)> g
std::function<void(crvec, crvec, rvec)> grad_g_prod
std::function<void(crvec, index_t, rvec)> grad_gi
std::function<void(crvec, rmat)> jac_g
std::function<void(crvec, crvec, real_t, crvec, rvec)> hess_L_prod
std::function<void(crvec, crvec, real_t, rmat)> hess_L
std::function<void(crvec, crvec, crvec, real_t, crvec, rvec)> hess_ψ_prod
std::function<void(crvec, crvec, crvec, real_t, rmat)> hess_ψ
template<Config Conf>
struct InnerSolveOptions
#include <alpaqa/inner/inner-solve-options.hpp>

Public Members

bool always_overwrite_results = true

Return the final iterate and multipliers, even if the solver did not converge.

std::optional<std::chrono::nanoseconds> max_time = std::nullopt

Maximum run time (in addition to the inner solver’s own timeout).

Zero means no timeout.

real_t tolerance = 0

Desired tolerance (overrides the solver’s own tolerance).

Zero means no tolerance (use solver’s own tolerance).

std::ostream *os = nullptr

Output stream to print to.

unsigned outer_iter = 0

The current iteration of the outer solver.

bool check = true

Call check() before starting to solve.

template<class InnerSolverStats>
struct InnerStatsAccumulator
template<Config Conf>
struct InnerStatsAccumulator<FISTAStats<Conf>>
#include <alpaqa/inner/fista.hpp>

Public Members

std::chrono::nanoseconds elapsed_time = {}

Total elapsed time in the inner solver.

std::chrono::nanoseconds time_progress_callback = {}

Total time spent in the user-provided progress callback.

unsigned iterations = 0

Total number of inner FISTA iterations.

unsigned stepsize_backtracks = 0

Total number of FISTA step size reductions.

real_t final_γ = 0

The final FISTA step size γ.

real_t final_ψ = 0

Final value of the smooth cost \( \psi(\hat x) \).

real_t final_h = 0

Final value of the nonsmooth cost \( h(\hat x) \).

template<>
struct InnerStatsAccumulator<lbfgsb::LBFGSBStats>
#include <alpaqa/lbfgsb/lbfgsb-adapter.hpp>

Public Members

std::chrono::nanoseconds elapsed_time = {}

Total elapsed time in the inner solver.

std::chrono::nanoseconds time_progress_callback = {}

Total time spent in the user-provided progress callback.

unsigned iterations = 0

Total number of inner PANOC iterations.

real_t final_ψ = 0

Final value of the smooth cost \( \psi(\hat x) \).

unsigned direction_update_rejected = 0

Total number of times that the L-BFGS update was rejected (i.e.

it could have resulted in a non-positive definite Hessian estimate).

template<Config Conf>
struct InnerStatsAccumulator<lbfgspp::LBFGSBStats<Conf>>
#include <alpaqa/lbfgsb-adapter.hpp>

Public Members

std::chrono::nanoseconds elapsed_time = {}

Total elapsed time in the inner solver.

unsigned iterations = 0

Total number of inner PANOC iterations.

real_t final_ψ = 0

Final value of the smooth cost \( \psi(\hat x) \).

template<Config Conf>
struct InnerStatsAccumulator<PANOCOCPStats<Conf>>
#include <alpaqa/inner/panoc-ocp.hpp>

Public Members

std::chrono::nanoseconds elapsed_time = {}

Total elapsed time in the inner solver.

std::chrono::nanoseconds time_prox = {}

Total time spent computing proximal mappings.

std::chrono::nanoseconds time_forward = {}

Total time spent doing forward simulations.

std::chrono::nanoseconds time_backward = {}

Total time spent doing backward gradient evaluations.

std::chrono::nanoseconds time_jacobians = {}

Total time spent computing dynamics Jacobians.

std::chrono::nanoseconds time_hessians = {}

Total time spent computing cost Hessians and Hessian-vector products.

std::chrono::nanoseconds time_indices = {}

Total time spent determining active indices.

std::chrono::nanoseconds time_lqr_factor = {}

Total time spent performing LQR factorizations.

std::chrono::nanoseconds time_lqr_solve = {}

Total time spent solving the (factorized) LQR problem.

std::chrono::nanoseconds time_lbfgs_indices = {}

Total time spent determining active indices for L-BFGS applications.

std::chrono::nanoseconds time_lbfgs_apply = {}

Total time spent applying L-BFGS estimates.

std::chrono::nanoseconds time_lbfgs_update = {}

Total time spent updating the L-BFGS estimate.

std::chrono::nanoseconds time_progress_callback = {}

Total time spent in the user-provided progress callback.

unsigned iterations = 0

Total number of inner PANOC iterations.

unsigned linesearch_failures = 0

Total number of PANOC line search failures.

unsigned linesearch_backtracks = 0

Total number of PANOC line search backtracking steps.

unsigned stepsize_backtracks = 0

Total number of PANOC step size reductions.

unsigned direction_failures = 0

Total number of times that the L-BFGS direction was not finite.

unsigned direction_update_rejected = 0

Total number of times that the L-BFGS update was rejected (i.e.

it could have resulted in a non-positive definite Hessian estimate).

unsigned τ_1_accepted = 0

Total number of times that a line search parameter of \( \tau = 1 \) was accepted (i.e.

no backtracking necessary).

unsigned count_τ = 0

The total number of line searches performed (used for computing the average value of \( \tau \)).

real_t sum_τ = 0

The sum of the line search parameter \( \tau \) in all iterations (used for computing the average value of \( \tau \)).

real_t final_γ = 0

The final PANOC step size γ.

real_t final_ψ = 0

Final value of the smooth cost \( \psi(\hat x) \).

real_t final_h = 0

Final value of the nonsmooth cost \( h(\hat x) \).

real_t final_φγ = 0

Final value of the forward-backward envelope, \( \varphi_\gamma(x) \) (note that this is in the point \( x \), not \( \hat x \)).

template<Config Conf>
struct InnerStatsAccumulator<PANOCStats<Conf>>
#include <alpaqa/inner/panoc.hpp>

Public Members

std::chrono::nanoseconds elapsed_time = {}

Total elapsed time in the inner solver.

std::chrono::nanoseconds time_progress_callback = {}

Total time spent in the user-provided progress callback.

unsigned iterations = 0

Total number of inner PANOC iterations.

unsigned linesearch_failures = 0

Total number of PANOC line search failures.

unsigned linesearch_backtracks = 0

Total number of PANOC line search backtracking steps.

unsigned stepsize_backtracks = 0

Total number of PANOC step size reductions.

unsigned direction_failures = 0

Total number of times that the L-BFGS direction was not finite.

unsigned direction_update_rejected = 0

Total number of times that the L-BFGS update was rejected (i.e.

it could have resulted in a non-positive definite Hessian estimate).

unsigned τ_1_accepted = 0

Total number of times that a line search parameter of \( \tau = 1 \) was accepted (i.e.

no backtracking necessary).

unsigned count_τ = 0

The total number of line searches performed (used for computing the average value of \( \tau \)).

real_t sum_τ = 0

The sum of the line search parameter \( \tau \) in all iterations (used for computing the average value of \( \tau \)).

real_t final_γ = 0

The final PANOC step size γ.

real_t final_ψ = 0

Final value of the smooth cost \( \psi(\hat x) \).

real_t final_h = 0

Final value of the nonsmooth cost \( h(\hat x) \).

real_t final_φγ = 0

Final value of the forward-backward envelope, \( \varphi_\gamma(x) \) (note that this is in the point \( x \), not \( \hat x \)).

template<Config Conf>
struct InnerStatsAccumulator<PANTRStats<Conf>>
#include <alpaqa/inner/pantr.hpp>

Public Members

std::chrono::nanoseconds elapsed_time = {}

Total elapsed time in the inner solver.

std::chrono::nanoseconds time_progress_callback = {}

Total time spent in the user-provided progress callback.

unsigned iterations = 0

Total number of inner PANTR iterations.

unsigned accelerated_step_rejected = 0

Total number of PANTR rejected accelerated steps.

unsigned stepsize_backtracks = 0

Total number of FB step size reductions.

unsigned direction_failures = 0

Total number of times that the accelerated direction was not finite.

unsigned direction_update_rejected = 0

Total number of times that the direction update was rejected (e.g.

it could have resulted in a non-positive definite Hessian estimate).

real_t final_γ = 0

The final FB step size γ.

real_t final_ψ = 0

Final value of the smooth cost \( \psi(\hat x) \).

real_t final_h = 0

Final value of the nonsmooth cost \( h(\hat x) \).

real_t final_φγ = 0

Final value of the forward-backward envelope, \( \varphi_\gamma(x) \) (note that this is in the point \( x \), not \( \hat x \)).

template<Config Conf>
struct InnerStatsAccumulator<WolfeStats<Conf>>
#include <alpaqa/inner/wolfe.hpp>

Public Members

std::chrono::nanoseconds elapsed_time = {}

Total elapsed time in the inner solver.

std::chrono::nanoseconds time_progress_callback = {}

Total time spent in the user-provided progress callback.

unsigned iterations = 0

Total number of inner Wolfe iterations.

unsigned linesearch_failures = 0

Total number of Wolfe line search failures.

unsigned linesearch_backtracks = 0

Total number of Wolfe line search backtracking steps.

unsigned direction_failures = 0

Total number of times that the L-BFGS direction was not finite.

unsigned direction_update_rejected = 0

Total number of times that the L-BFGS update was rejected (i.e.

it could have resulted in a non-positive definite Hessian estimate).

unsigned τ_1_accepted = 0

Total number of times that a line search parameter of \( \tau = 1 \) was accepted (i.e.

no backtracking necessary).

unsigned count_τ = 0

The total number of line searches performed (used for computing the average value of \( \tau \)).

real_t sum_τ = 0

The sum of the line search parameter \( \tau \) in all iterations (used for computing the average value of \( \tau \)).

real_t final_ψ = 0

Final value of the smooth cost \( \psi(\hat x) \).

template<Config Conf>
struct InnerStatsAccumulator<ZeroFPRStats<Conf>>
#include <alpaqa/inner/zerofpr.hpp>

Public Members

std::chrono::nanoseconds elapsed_time = {}

Total elapsed time in the inner solver.

std::chrono::nanoseconds time_progress_callback = {}

Total time spent in the user-provided progress callback.

unsigned iterations = 0

Total number of inner ZeroFPR iterations.

unsigned linesearch_failures = 0

Total number of ZeroFPR line search failures.

unsigned linesearch_backtracks = 0

Total number of ZeroFPR line search backtracking steps.

unsigned stepsize_backtracks = 0

Total number of ZeroFPR step size reductions.

unsigned direction_failures = 0

Total number of times that the L-BFGS direction was not finite.

unsigned direction_update_rejected = 0

Total number of times that the L-BFGS update was rejected (i.e.

it could have resulted in a non-positive definite Hessian estimate).

unsigned τ_1_accepted = 0

Total number of times that a line search parameter of \( \tau = 1 \) was accepted (i.e.

no backtracking necessary).

unsigned count_τ = 0

The total number of line searches performed (used for computing the average value of \( \tau \)).

real_t sum_τ = 0

The sum of the line search parameter \( \tau \) in all iterations (used for computing the average value of \( \tau \)).

real_t final_γ = 0

The final ZeroFPR step size γ.

real_t final_ψ = 0

Final value of the smooth cost \( \psi(\hat x) \).

real_t final_h = 0

Final value of the nonsmooth cost \( h(\hat x) \).

real_t final_φγ = 0

Final value of the forward-backward envelope, \( \varphi_\gamma(x) \) (note that this is in the point \( x \), not \( \hat x \)).

class IpoptAdapter : public TNLP
#include <alpaqa/ipopt/ipopt-adapter.hpp>

Based on https://coin-or.github.io/Ipopt/INTERFACES.html.

Functions required by Ipopt

bool get_nlp_info(Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style) override
bool get_bounds_info(Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u) override
bool get_starting_point(Index n, bool init_x, Number *x, bool init_z, Number *z_L, Number *z_U, Index m, bool init_lambda, Number *lambda) override
bool eval_f(Index n, const Number *x, bool new_x, Number &obj_value) override
bool eval_grad_f(Index n, const Number *x, bool new_x, Number *grad_f) override
bool eval_g(Index n, const Number *x, bool new_x, Index m, Number *g) override
bool eval_jac_g(Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values) override
bool eval_h(Index n, const Number *x, bool new_x, Number obj_factor, Index m, const Number *lambda, bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values) override
void finalize_solution(Ipopt::SolverReturn status, Index n, const Number *x, const Number *z_L, const Number *z_U, Index m, const Number *g, const Number *lambda, Number obj_value, const Ipopt::IpoptData *ip_data, Ipopt::IpoptCalculatedQuantities *ip_cq) override

Public Types

using Problem = TypeErasedProblem<config_t>
using Index = Ipopt::Index
using Number = Ipopt::Number

Public Functions

IpoptAdapter(const Problem &problem)
IpoptAdapter(Problem&&) = delete

Public Members

vec initial_guess
vec initial_guess_bounds_multipliers
vec initial_guess_multipliers
struct alpaqa::IpoptAdapter::Results results
struct Results
#include <alpaqa/ipopt/ipopt-adapter.hpp>

Public Functions

inline vec combine_bounds_multipliers() const

Public Members

Ipopt::SolverReturn status = Ipopt::SolverReturn::UNASSIGNED
vec solution_x
vec solution_z_L
vec solution_z_U
vec solution_y
vec solution_g
real_t solution_f = NaN<config_t>
real_t infeasibility = NaN<config_t>
real_t nlp_error = NaN<config_t>
length_t iter_count = 0
template<class T>
struct is_config : public false_type
#include <alpaqa/config/config.hpp>
template<>
struct is_config<EigenConfigd> : public false_type, public true_type
#include <alpaqa/config/config.hpp>
template<>
struct is_config<EigenConfigf> : public false_type, public true_type
#include <alpaqa/config/config.hpp>
template<>
struct is_config<EigenConfigl> : public false_type, public true_type
#include <alpaqa/config/config.hpp>
template<>
struct is_config<EigenConfigq> : public false_type, public true_type
#include <alpaqa/config/config.hpp>
template<class T>
struct is_eigen_config : public false_type
#include <alpaqa/config/config.hpp>
template<>
struct is_eigen_config<EigenConfigd> : public false_type, public true_type
#include <alpaqa/config/config.hpp>
template<>
struct is_eigen_config<EigenConfigf> : public false_type, public true_type
#include <alpaqa/config/config.hpp>
template<>
struct is_eigen_config<EigenConfigl> : public false_type, public true_type
#include <alpaqa/config/config.hpp>
template<>
struct is_eigen_config<EigenConfigq> : public false_type, public true_type
#include <alpaqa/config/config.hpp>
template<Config Conf>
struct KKTError
#include <alpaqa/problem/kkt-error.hpp>

Public Members

real_t stationarity = NaN
real_t constr_violation = NaN
real_t complementarity = NaN
real_t bounds_violation = NaN

Public Static Attributes

static auto NaN = alpaqa::NaN<config_t>
template<Config Conf = DefaultConfig, class Storage = LBFGSStorage<Conf>>
class LBFGS
#include <alpaqa/accelerators/lbfgs.hpp>

Limited memory Broyden–Fletcher–Goldfarb–Shanno (L-BFGS) algorithm.

Public Types

enum class Sign

The sign of the vectors \( p \) passed to the update method.

Values:

enumerator Positive

\( p \sim \nabla \psi(x) \)

enumerator Negative

\( p \sim -\nabla \psi(x) \)

using Params = LBFGSParams<config_t>

Public Functions

LBFGS() = default
inline LBFGS(Params params)
inline LBFGS(Params params, length_t n)
bool update_sy(crvec s, crvec y, real_t pₙₑₓₜᵀpₙₑₓₜ, bool forced = false)

Update the inverse Hessian approximation using the new vectors sₖ = xₙₑₓₜ - xₖ and yₖ = pₙₑₓₜ - pₖ.

bool update_sy_impl(const auto &s, const auto &y, real_t pₙₑₓₜᵀpₙₑₓₜ, bool forced = false)

See also

update_sy

bool update(crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, Sign sign = Sign::Positive, bool forced = false)

Update the inverse Hessian approximation using the new vectors xₙₑₓₜ and pₙₑₓₜ.

bool apply(rvec q, real_t γ = -1) const

Apply the inverse Hessian approximation to the given vector q.

Initial inverse Hessian approximation is set to \( H_0 = \gamma I \). If γ is negative, \( H_0 = \frac{s^\top y}{y^\top y} I \).

bool apply_masked(rvec q, real_t γ, crindexvec J) const

Apply the inverse Hessian approximation to the given vector q, applying only the columns and rows of the Hessian in the index set J.

bool apply_masked(rvec q, real_t γ, const std::vector<index_t> &J) const

Apply the inverse Hessian approximation to the given vector q, applying only the columns and rows of the Hessian in the index set J.

bool apply_masked_impl(rvec q, real_t γ, const auto &J) const

Apply the inverse Hessian approximation to the given vector q, applying only the columns and rows of the Hessian in the index set J.

void reset()

Throw away the approximation and all previous vectors s and y.

void resize(length_t n)

Re-allocate storage for a problem with a different size.

Causes a reset.

void scale_y(real_t factor)

Scale the stored y vectors by the given factor.

inline std::string get_name() const

Get a string identifier for this accelerator.

inline const Params &get_params() const

Get the parameters.

inline length_t n() const

Get the size of the s and y vectors in the buffer.

inline length_t history() const

Get the number of previous vectors s and y stored in the buffer.

inline index_t succ(index_t i) const

Get the next index in the circular buffer of previous s and y vectors.

inline index_t pred(index_t i) const

Get the previous index in the circular buffer of s and y vectors.

inline length_t current_history() const

Get the number of previous s and y vectors currently stored in the buffer.

inline auto s(index_t i)
inline auto s(index_t i) const
inline auto y(index_t i)
inline auto y(index_t i) const
inline real_t &ρ(index_t i)
inline real_t &ρ(index_t i) const
inline real_t &α(index_t i)
inline real_t &α(index_t i) const
template<class F>
inline void foreach_fwd(const F &fun) const

Iterate over the indices in the history buffer, oldest first.

template<class F>
inline void foreach_rev(const F &fun) const

Iterate over the indices in the history buffer, newest first.

Public Static Functions

static bool update_valid(const Params &params, real_t yᵀs, real_t sᵀs, real_t pᵀp)

Check if the new vectors s and y allow for a valid BFGS update that preserves the positive definiteness of the Hessian approximation.

template<Config Conf>
struct LBFGSDirection
#include <alpaqa/inner/directions/panoc/lbfgs.hpp>

Public Types

using Problem = TypeErasedProblem<config_t>
using LBFGS = alpaqa::LBFGS<config_t>
using AcceleratorParams = typename LBFGS::Params
using DirectionParams = LBFGSDirectionParams<config_t>

Public Functions

LBFGSDirection() = default
inline LBFGSDirection(const Params &params)
inline LBFGSDirection(const typename LBFGS::Params &params, const DirectionParams &directionparams = {})
inline LBFGSDirection(const LBFGS &lbfgs, const DirectionParams &directionparams = {})
inline LBFGSDirection(LBFGS &&lbfgs, const DirectionParams &directionparams = {})
inline void initialize(const Problem &problem, crvec y, crvec Σ, real_t γ_0, crvec x_0, crvec x̂_0, crvec p_0, crvec grad_ψx_0)

See also

initialize

inline bool has_initial_direction() const

inline bool update(real_t γₖ, real_t γₙₑₓₜ, crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, crvec grad_ψxₖ, crvec grad_ψxₙₑₓₜ)

See also

update

inline bool apply(real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const

See also

apply

inline void changed_γ(real_t γₖ, real_t old_γₖ)

See also

changed_γ

inline void reset()

See also

reset

inline std::string get_name() const

See also

get_name

inline auto get_params() const

Public Members

LBFGS lbfgs
DirectionParams direction_params
struct Params
#include <alpaqa/inner/directions/panoc/lbfgs.hpp>

Public Members

AcceleratorParams accelerator = {}
DirectionParams direction = {}
template<Config Conf>
struct LBFGSDirectionParams
#include <alpaqa/inner/directions/panoc/lbfgs.hpp>

Parameters for the LBFGSDirection class.

Public Members

bool rescale_on_step_size_changes = false

Instead of flushing the buffer when the step size changes, rescale the buffer by a factor \( \gamma_k / \gamma_{k-1} \).

template<Config Conf = DefaultConfig>
struct LBFGSParams
#include <alpaqa/accelerators/lbfgs.hpp>

Parameters for the LBFGS class.

Public Members

length_t memory = 10

Length of the history to keep.

real_t min_div_fac = std::numeric_limits<real_t>::epsilon()

Reject update if \( y^\top s \le \text{min_div_fac} \cdot s^\top s \).

Keeps the inverse Hessian approximation positive definite.

real_t min_abs_s = std::pow(std::numeric_limits<real_t>::epsilon(), real_t(2))

Reject update if \( s^\top s \le \text{min_abs_s} \).

Keeps the Hessian approximation nonsingular.

CBFGSParams<config_t> cbfgs = {}

Parameters in the cautious BFGS update condition.

\[ \frac{y^\top s}{s^\top s} \ge \epsilon \| g \|^\alpha. \]
Disabled by default.

bool force_pos_def = true

If set to true, the inverse Hessian estimate should remain definite, i.e.

a check is performed that rejects the update if \( y^\top s \le \text{min_div_fac} \cdot s^\top s \). If set to false, just try to prevent a singular Hessian by rejecting the update if \( \left| y^\top s \right| \le \text{min_div_fac} \cdot s^\top s \).

LBFGSStepSize stepsize = LBFGSStepSize::BasedOnCurvature

Scale of the initial inverse Hessian approximation that the rank-one L-BFGS updates are applied to, \( H_0 \).

You probably want to keep this as the default.

See also

LBFGSStepSize

template<Config Conf = DefaultConfig>
struct LBFGSStorage
#include <alpaqa/accelerators/lbfgs.hpp>

Layout:

      ┌───── 2 m ─────┐
    ┌ ┌───┬───┬───┬───┐
    │ │   │   │   │   │
    │ │ s │ y │ s │ y │
n+1 │ │   │   │   │   │
    │ ├───┼───┼───┼───┤
    │ │ ρ │ α │ ρ │ α │
    └ └───┴───┴───┴───┘

Public Types

using storage_t = mat

Public Functions

void resize(length_t n, length_t history)

Re-allocate storage for a problem with a different size.

inline length_t n() const

Get the size of the s and y vectors in the buffer.

inline length_t history() const

Get the number of previous vectors s and y stored in the buffer.

inline auto s(index_t i)
inline auto s(index_t i) const
inline auto y(index_t i)
inline auto y(index_t i) const
inline real_t &ρ(index_t i)
inline real_t &ρ(index_t i) const
inline real_t &α(index_t i)
inline real_t &α(index_t i) const

Public Members

mutable storage_t sto
template<Config Conf = DefaultConfig>
class LimitedMemoryQR
#include <alpaqa/accelerators/internal/limited-memory-qr.hpp>

Incremental QR factorization using modified Gram-Schmidt with reorthogonalization.

Computes A = QR while allowing efficient removal of the first column of A or adding new columns at the end of A.

Public Types

template<class Derived>
using solve_ret_t = std::conditional_t<Eigen::internal::traits<Derived>::ColsAtCompileTime == 1, vec, mat>

Public Functions

LimitedMemoryQR() = default
inline LimitedMemoryQR(length_t n, length_t m)

The maximum dimensions of Q are n×m and the maximum dimensions of R are m×m.

Parameters:
  • n – The size of the vectors, the number of rows of A.

  • m – The maximum number of columns of A.

inline length_t n() const
inline length_t m() const
inline length_t size() const
inline length_t history() const
template<class VecV>
inline void add_column(const VecV &v)

Add the given column to the right.

inline void remove_column()

Remove the leftmost column.

template<class VecB, class VecX>
inline void solve_col(const VecB &b, VecX &x, real_t tol = 0) const

Solve the least squares problem Ax = b.

Do not divide by elements that are smaller in absolute value than tol.

template<class MatB, class MatX>
inline void solve(const MatB &B, MatX &X, real_t tol = 0) const

Solve the least squares problem AX = B.

Do not divide by elements that are smaller in absolute value than tol.

template<class Derived>
inline solve_ret_t<Derived> solve(const Eigen::DenseBase<Derived> &B)

Solve the least squares problem AX = B.

inline const mat &get_raw_Q() const

Get the full, raw storage for the orthogonal matrix Q.

inline const mat &get_raw_R() const

Get the full, raw storage for the upper triangular matrix R.

The columns of this matrix are permuted because it’s stored as a circular buffer for efficiently appending columns to the end and popping columns from the front.

inline mat get_full_R() const

Get the full storage for the upper triangular matrix R but with the columns in the correct order.

Note

Meant for tests only, creates a permuted copy.

inline mat get_R() const

Get the matrix R such that Q times R is the original matrix.

Note

Meant for tests only, creates a permuted copy.

inline mat get_Q() const

Get the matrix Q such that Q times R is the original matrix.

Note

Meant for tests only, creates a copy.

inline void scale_R(real_t scal)

Multiply the matrix R by a scalar.

inline unsigned long get_reorth_count() const

Get the number of MGS reorthogonalizations.

inline void clear_reorth_count()

Reset the number of MGS reorthogonalizations.

inline real_t get_min_eig() const

Get the minimum eigenvalue of R.

inline real_t get_max_eig() const

Get the maximum eigenvalue of R.

inline void reset()

Reset all indices, clearing the Q and R matrices.

inline void resize(length_t n, length_t m)

Re-allocate storage for a problem with a different size.

Causes a reset.

inline length_t num_columns() const

Get the number of columns that are currently stored.

inline index_t ring_head() const

Get the head index of the circular buffer (points to the oldest element).

inline index_t ring_tail() const

Get the tail index of the circular buffer (points to one past the most recent element).

inline index_t ring_next(index_t i) const

Get the next index in the circular buffer.

inline index_t ring_prev(index_t i) const

Get the previous index in the circular buffer.

inline length_t current_history() const

Get the number of columns currently stored in the buffer.

inline guanaqo::CircularRange<index_t> ring_iter() const

Get iterators in the circular buffer.

inline guanaqo::ReverseCircularRange<index_t> ring_reverse_iter() const

Get reverse iterators in the circular buffer.

template<Config Conf, class IndexT, class StorageIndexT>
struct LinConstrConverter
#include <alpaqa/util/lin-constr-converter.hpp>

Public Types

using config_t = Conf
using real_t = typename config_t::real_t
using index_t = IndexT
using storage_index_t = StorageIndexT

Public Static Functions

static inline bool is_bound(std::span<const real_t> lbx, std::span<const real_t> ubx, size_t i)

Check if the variable with the given index has bound constraints, i.e.

if not lower == -inf and upper == +inf.

static inline bool is_bound(const sets::Box<config_t> &C, typename config_t::index_t i)
static inline index_t count_bounds(std::span<const real_t> lbx, std::span<const real_t> ubx)
static inline index_t count_bounds(const sets::Box<config_t> &C)
static inline void add_box_constr_to_constr_matrix(mat<config_t> &A, std::span<const real_t> lbx, std::span<const real_t> ubx)
static inline void add_box_constr_to_constr_matrix(mat<config_t> &A, const sets::Box<config_t> &C)
static inline void add_box_constr_to_constr_matrix_inplace(index_t n_row, rmat<config_t> A, std::span<const real_t> lbx, std::span<const real_t> ubx)
static inline void add_box_constr_to_constr_matrix_inplace(index_t n_row, rmat<config_t> A, const sets::Box<config_t> &C)
static inline void add_box_constr_to_constr_matrix_inplace_vec(index_t n_row, index_t n_col, rvec<config_t> A, std::span<const real_t> lbx, std::span<const real_t> ubx)
static inline void add_box_constr_to_constr_matrix_inplace_vec(index_t n_row, index_t n_col, rvec<config_t> A, const sets::Box<config_t> &C)
static void add_box_constr_to_constr_matrix(SparseView &A, std::span<const real_t> lbx, std::span<const real_t> ubx)

Update the constraint matrix A, such that for each constraint C(i) with finite bounds, a row is inserted into A with a one in the i-th column.

The newly added rows are added above the original rows of A. For example, if all constraints have finite bounds, the resulting matrix is \( \begin{pmatrix} I \\\hline A \end{pmatrix} \).

Pre:

Assumes that the user preallocated enough space for inserting these nonzero elements into A, and that A is compressed.

static inline void add_box_constr_to_constr_matrix(SparseView &A, const sets::Box<config_t> &C)
static void combine_bound_constr(std::span<const real_t> lbx, std::span<const real_t> ubx, std::span<const real_t> lbg, std::span<const real_t> ubg, std::span<real_t> new_lbg, std::span<real_t> new_ubg, std::span<const real_t> g0)

For each constraint lbx(i)/ubx(i) with finite bounds, insert these bounds into new_lbg(i)/new_ubg(i), followed by all bounds lbg(i)/ubg(i), shifted by the constant vector -g₀.

static inline void combine_bound_constr(const sets::Box<config_t> &C, const sets::Box<config_t> &D, sets::Box<config_t> &new_D, typename config_t::crvec g0)
static inline void combine_bound_constr(const sets::Box<config_t> &C, const sets::Box<config_t> &D, std::span<real_t> new_lbg, std::span<real_t> new_ubg, typename config_t::crvec g0)
struct SparseView
#include <alpaqa/util/lin-constr-converter.hpp>

Public Members

index_t nrow
index_t ncol
std::span<index_t> inner_idx
std::span<storage_index_t> outer_ptr
std::span<real_t> values
template<Config Conf = DefaultConfig>
struct LipschitzEstimateParams
#include <alpaqa/inner/internal/lipschitz.hpp>

Parameters for the estimation of the Lipschitz constant of the gradient of the smooth term of the cost.

This is needed to select a suitable step size for the forward-backward iterations used by solvers like PANOC and PANTR.

Public Members

real_t L_0 = 0

Initial estimate of the Lipschitz constant of ∇ψ(x).

If set to zero, it will be approximated using finite differences.

real_t ε = real_t(1e-6)

Relative step size for initial finite difference Lipschitz estimate.

real_t δ = real_t(1e-12)

Minimum step size for initial finite difference Lipschitz estimate.

real_t Lγ_factor = real_t(0.95)

Factor that relates step size γ and Lipschitz constant.

Parameter α in Algorithm 2 of [2]. \( 0 < \alpha < 1 \)

template<Config Conf>
struct NewtonTRDirection
#include <alpaqa/inner/directions/pantr/newton-tr.hpp>

Public Types

using Problem = TypeErasedProblem<config_t>
using AcceleratorParams = SteihaugCGParams<config_t>
using DirectionParams = NewtonTRDirectionParams<config_t>

Public Functions

NewtonTRDirection() = default
inline NewtonTRDirection(const Params &params)
inline NewtonTRDirection(const AcceleratorParams &params, const DirectionParams &directionparams = {})
inline void initialize(const Problem &problem, crvec y, crvec Σ, real_t γ_0, crvec x_0, crvec x̂_0, crvec p_0, crvec grad_ψx_0)

See also

initialize

inline bool has_initial_direction() const

inline bool update(real_t γₖ, real_t γₙₑₓₜ, crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, crvec grad_ψxₖ, crvec grad_ψxₙₑₓₜ)

See also

update

inline real_t apply(real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, real_t radius, rvec qₖ) const

See also

apply

inline void changed_γ(real_t γₖ, real_t old_γₖ)

See also

changed_γ

inline void reset()

See also

reset

inline std::string get_name() const

See also

get_name

inline auto get_params() const

Public Members

SteihaugCG<config_t> steihaug
DirectionParams direction_params
const Problem *problem = nullptr
std::optional<crvec> y = std::nullopt
std::optional<crvec> Σ = std::nullopt
mutable indexvec JK_sto
mutable vec rJ_sto
mutable vec qJ_sto
mutable vec work
vec work_2
vec work_n_fd
vec work_m_fd
struct Params
#include <alpaqa/inner/directions/pantr/newton-tr.hpp>

Public Members

AcceleratorParams accelerator = {}
DirectionParams direction = {}
template<Config Conf>
struct NewtonTRDirectionParams
#include <alpaqa/inner/directions/pantr/newton-tr.hpp>

Parameters for the NewtonTRDirection class.

Public Members

real_t hessian_vec_factor = real_t(1)

The factor in front of the term \( \langle H_{\mathcal{JK}} d_{\mathcal {K}}, d_{\mathcal{J}} \rangle \) in equation (9) in [1].

Set it to zero to leave out that term (this usually only slightly increases the number of iterations, and eliminates one Hessian-vector product per iteration, improving the overall runtime).

bool finite_diff = false

Use finite differences to compute Hessian-vector products.

real_t finite_diff_stepsize = std::sqrt(std::numeric_limits<real_t>::epsilon())

Size of the perturbation for the finite differences computation.

Multiplied by \( 1+\|x\| \).

template<Config Conf>
struct NoopDirection
#include <alpaqa/inner/directions/panoc/noop.hpp>

Direction provider that provides no directions (apply always returns false).

Public Types

using Problem = TypeErasedProblem<config_t>
using AcceleratorParams = std::monostate
using DirectionParams = std::monostate

Public Functions

NoopDirection() = default
inline NoopDirection(Params)
inline NoopDirection(AcceleratorParams, DirectionParams)
inline void initialize(const Problem &problem, crvec y, crvec Σ, real_t γ_0, crvec x_0, crvec x̂_0, crvec p_0, crvec grad_ψx_0)

See also

initialize

inline bool has_initial_direction() const

inline bool update(real_t γₖ, real_t γₙₑₓₜ, crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, crvec grad_ψxₖ, crvec grad_ψxₙₑₓₜ)

See also

update

inline bool apply(real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const

See also

apply

inline void changed_γ(real_t γₖ, real_t old_γₖ)

See also

changed_γ

inline void reset()

See also

reset

inline std::string get_name() const

See also

get_name

inline void get_params() const
struct Params
#include <alpaqa/inner/directions/panoc/noop.hpp>

Public Members

AcceleratorParams accelerator = {}
DirectionParams direction = {}
template<Config Conf>
struct OCPDim
#include <alpaqa/problem/ocproblem.hpp>

Public Members

length_t N
length_t nx
length_t nu
length_t nh
length_t nc
struct OCPEvalCounter
#include <alpaqa/problem/ocproblem-counters.hpp>

Public Functions

inline void reset()

Public Members

unsigned f = {}
unsigned jac_f = {}
unsigned grad_f_prod = {}
unsigned h = {}
unsigned h_N = {}
unsigned l = {}
unsigned l_N = {}
unsigned qr = {}
unsigned q_N = {}
unsigned add_Q = {}
unsigned add_Q_N = {}
unsigned add_R_masked = {}
unsigned add_S_masked = {}
unsigned add_R_prod_masked = {}
unsigned add_S_prod_masked = {}
unsigned constr = {}
unsigned constr_N = {}
unsigned grad_constr_prod = {}
unsigned grad_constr_prod_N = {}
unsigned add_gn_hess_constr = {}
unsigned add_gn_hess_constr_N = {}
struct alpaqa::OCPEvalCounter::OCPEvalTimer time
struct OCPEvalTimer
#include <alpaqa/problem/ocproblem-counters.hpp>

Public Members

std::chrono::nanoseconds f = {}
std::chrono::nanoseconds jac_f = {}
std::chrono::nanoseconds grad_f_prod = {}
std::chrono::nanoseconds h = {}
std::chrono::nanoseconds h_N = {}
std::chrono::nanoseconds l = {}
std::chrono::nanoseconds l_N = {}
std::chrono::nanoseconds qr = {}
std::chrono::nanoseconds q_N = {}
std::chrono::nanoseconds add_Q = {}
std::chrono::nanoseconds add_Q_N = {}
std::chrono::nanoseconds add_R_masked = {}
std::chrono::nanoseconds add_S_masked = {}
std::chrono::nanoseconds add_R_prod_masked = {}
std::chrono::nanoseconds add_S_prod_masked = {}
std::chrono::nanoseconds constr = {}
std::chrono::nanoseconds constr_N = {}
std::chrono::nanoseconds grad_constr_prod = {}
std::chrono::nanoseconds grad_constr_prod_N = {}
std::chrono::nanoseconds add_gn_hess_constr = {}
std::chrono::nanoseconds add_gn_hess_constr_N = {}
template<Config Conf>
struct OCPEvaluator
#include <alpaqa/inner/directions/panoc-ocp/ocp-vars.hpp>

Public Types

using OCPVars = OCPVariables<config_t>
using Problem = TypeErasedControlProblem<config_t>
using Box = alpaqa::Box<config_t>

Public Functions

inline OCPEvaluator(const Problem &problem)
inline length_t N() const
inline real_t forward(rvec storage, const Box &D, const Box &D_N, crvec μ, crvec y) const
Pre:

x0 and u initialized

Post:

x, h and c updated

Returns:

\( V(u) = \sum_{k=0}^{N-1} \ell(h_k(x_k, u_k)) + V_f(h_N(x_N)) \)

inline void forward_simulate(rvec storage) const
Pre:

x0 and u initialized

Post:

x updated

inline void forward_simulate(crvec u, rvec x) const
Pre:

x0 and u initialized

inline void backward(rvec storage, rvec g, const auto &qr, const auto &q_N, const Box &D, const Box &D_N, crvec μ, crvec y) const
Pre:

x, u, h and c initialized (i.e. forward was called)

inline void Qk(crvec storage, crvec y, crvec μ, const Box &D, const Box &D_N, index_t k, rmat out) const
inline auto Q(crvec storage, crvec y, crvec μ, const Box &D, const Box &D_N) const
inline void Rk(crvec storage, index_t k, crindexvec mask, rmat out)
Post:

initialize work_R

inline auto R(crvec storage)
inline void Sk(crvec storage, index_t k, crindexvec mask, rmat out)
Post:

initialize work_S

inline auto S(crvec storage)
inline void Rk_prod(crvec storage, index_t k, crindexvec mask_J, crindexvec mask_K, crvec v, rvec out) const
Pre:

initialized work_R

inline auto R_prod(crvec storage) const
inline void Sk_prod(crvec storage, index_t k, crindexvec mask_K, crvec v, rvec out) const
Pre:

initialized work_S

inline auto S_prod(crvec storage) const

Public Members

const Problem *problem
OCPVars vars
mutable vec work_x = {vars.nc() > 0 || vars.nc_N() ? vars.nx() : 0}
mutable vec work_λ = {vars.nx()}
mutable vec work_c = {std::max(vars.nc(), vars.nc_N())}
mutable vec work_R = {problem->get_R_work_size()}
mutable vec work_S = {problem->get_S_work_size()}
template<Config Conf>
struct OCPVariables
#include <alpaqa/inner/directions/panoc-ocp/ocp-vars.hpp>

Public Types

enum Indices

Values:

enumerator i_u
enumerator i_h
enumerator i_c
enumerator i_h_N
enumerator i_c_N

Public Functions

inline OCPVariables(const std::array<index_t, 4> &sizes, const std::array<index_t, 3> &sizes_N, length_t N)
Parameters:
  • sizes – nx, nu, nh, nc

  • sizes_N – nx, nh, nc

  • N – Horizon length

inline OCPVariables(const TypeErasedControlProblem<config_t> &prob)
inline length_t size(size_t i) const
inline length_t size_N(size_t i) const
inline length_t nx() const
inline length_t nu() const
inline length_t nxu() const
inline length_t nh() const
inline length_t nc() const
inline length_t nx_N() const
inline length_t nh_N() const
inline length_t nc_N() const
inline vec create() const
inline auto xk(VectorRefLike<config_t> auto &&v, index_t t) const
inline auto x(crvec v) const
inline auto xuk(VectorRefLike<config_t> auto &&v, index_t t) const
inline auto uk(VectorRefLike<config_t> auto &&v, index_t t) const
inline auto u(crvec v) const
inline auto hk(VectorRefLike<config_t> auto &&v, index_t t) const
inline auto ck(VectorRefLike<config_t> auto &&v, index_t t) const
inline vec create_qr() const
inline auto qk(VectorRefLike<config_t> auto &&v, index_t t) const
inline auto q(crvec v) const
inline auto qN_mut(vec &v) const
inline auto rk(VectorRefLike<config_t> auto &&v, index_t t) const
inline auto r(crvec v) const
inline auto qrk(VectorRefLike<config_t> auto &&v, index_t t) const
inline auto qr(crvec v) const
inline auto qr_mut(vec &v) const
inline mat create_AB() const
inline rmat ABk(rmat AB, index_t t) const
inline auto ABk(mat &AB, index_t t) const
inline crmat ABk(crmat AB, index_t t) const
inline auto AB(crmat AB) const
inline rmat Ak(rmat AB, index_t t) const
inline crmat Ak(crmat AB, index_t t) const
inline auto Ak(mat &AB, index_t t) const
inline auto A(crmat AB) const
inline rmat Bk(rmat AB, index_t t) const
inline crmat Bk(crmat AB, index_t t) const
inline auto Bk(mat &AB, index_t t) const
inline auto B(crmat AB) const

Public Members

length_t N
std::array<index_t, 4> indices
std::array<index_t, 3> indices_N
struct OwningQPALMData : public QPALMData
#include <alpaqa/qpalm/qpalm-adapter.hpp>

Public Members

std::unique_ptr<Storage> sto = std::make_unique<Storage>()
struct Storage
#include <alpaqa/qpalm/qpalm-adapter.hpp>

Public Members

qpalm::ladel_sparse_matrix_ptr Q
qpalm::ladel_sparse_matrix_ptr A
vec q
Box<config_t> b
template<Config Conf>
struct PANOCDirection
#include <alpaqa/inner/directions/panoc-direction-update.hpp>

This class outlines the interface for direction providers used by PANOC-like algorithms.

Public Types

using Problem = TypeErasedProblem<config_t>

Public Functions

void initialize(const Problem &problem, crvec y, crvec Σ, real_t γ_0, crvec x_0, crvec x̂_0, crvec p_0, crvec grad_ψx_0) = delete

Initialize the direction provider.

The references problem, y and Σ are guaranteed to remain valid for subsequent calls to update, apply, changed_γ and reset.

Parameters:
  • problem[in] Problem description.

  • y[in] Lagrange multipliers.

  • Σ[in] Penalty factors.

  • γ_0[in] Initial step size.

  • x_0[in] Initial iterate.

  • x̂_0[in] Result of proximal gradient step in x_0.

  • p_0[in] Proximal gradient step in x_0.

  • grad_ψx_0[in] Gradient of the objective in x_0.

bool has_initial_direction() const = delete

Return whether a direction is available on the very first iteration, before the first call to update.

bool update(real_t γₖ, real_t γₙₑₓₜ, crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, crvec grad_ψxₖ, crvec grad_ψxₙₑₓₜ) = delete

Update the direction provider when accepting the next iterate.

Parameters:
  • γₖ[in] Current step size.

  • γₙₑₓₜ[in] Step size for the next iterate.

  • xₖ[in] Current iterate.

  • xₙₑₓₜ[in] Next iterate.

  • pₖ[in] Proximal gradient step in the current iterate.

  • pₙₑₓₜ[in] Proximal gradient step in the next iterate.

  • grad_ψxₖ[in] Gradient of the objective in the current iterate.

  • grad_ψxₙₑₓₜ[in] Gradient of the objective in the next iterate.

bool apply(real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const = delete

Apply the direction estimation in the current point.

Parameters:
  • γₖ[in] Current step size.

  • xₖ[in] Current iterate.

  • x̂ₖ[in] Result of proximal gradient step in xₖ.

  • pₖ[in] Proximal gradient step in xₖ.

  • grad_ψxₖ[in] Gradient of the objective at xₖ.

  • qₖ[out] Resulting step.

void changed_γ(real_t γₖ, real_t old_γₖ) = delete

Called when the PANOC step size changes.

void reset() = delete

Called when using the direction failed.

A possible behavior could be to flush the buffers, hopefully yielding a better direction on the next iteration.

std::string get_name() const = delete

Get a human-readable name for this direction provider.

template<Config Conf = DefaultConfig>
struct PANOCOCPParams
#include <alpaqa/inner/panoc-ocp.hpp>

Tuning parameters for the PANOC algorithm.

Public Members

LipschitzEstimateParams<config_t> Lipschitz = {}

Parameters related to the Lipschitz constant estimate and step size.

unsigned max_iter = 100

Maximum number of inner PANOC iterations.

std::chrono::nanoseconds max_time = std::chrono::minutes(5)

Maximum duration.

real_t min_linesearch_coefficient = real_t(1. / 256)

Minimum weight factor between Newton step and projected gradient step, line search parameter.

real_t linesearch_strictness_factor = real_t(0.95)

Parameter β used in the line search (see Algorithm 2 in [2]).

\( 0 < \beta < 1 \)

real_t L_min = real_t(1e-5)

Minimum Lipschitz constant estimate.

real_t L_max = real_t(1e20)

Maximum Lipschitz constant estimate.

unsigned L_max_inc = 16

Maximum number of times to double the Lipschitz constant estimate per iteration.

PANOCStopCrit stop_crit = PANOCStopCrit::ApproxKKT

What stopping criterion to use.

unsigned max_no_progress = 10

Maximum number of iterations without any progress before giving up.

unsigned gn_interval = 1

How often to use a Gauss-Newton step. Zero to disable GN entirely.

bool gn_sticky = true

Keep trying to apply a Gauss-Newton step as long as they keep getting accepted with step size one.

bool reset_lbfgs_on_gn_step = false

Flush the L-BFGS buffer when a Gauss-Newton step is accepted.

bool lqr_factor_cholesky = true

Use a Cholesky factorization for the Riccati recursion.

Use LU if set to false.

LBFGSParams<config_t> lbfgs_params

L-BFGS parameters (e.g. memory).

unsigned print_interval = 0

When to print progress.

If set to zero, nothing will be printed. If set to N != 0, progress is printed every N iterations.

int print_precision = std::numeric_limits<real_t>::max_digits10 / 2

The precision of the floating point values printed by the solver.

real_t quadratic_upperbound_tolerance_factor = real_t(1e2) * std::numeric_limits<real_t>::epsilon()

Tolerance factor used in the quadratic upper bound condition that determines the step size.

Its goal is to account for numerical errors in the function and gradient evaluations. If you notice that the step size γ becomes very small, you may want to increase this factor.

real_t linesearch_tolerance_factor = real_t(1e2) * std::numeric_limits<real_t>::epsilon()

Tolerance factor used in the line search.

Its goal is to account for numerical errors in the function and gradient evaluations. If you notice that accelerated steps are rejected (τ = 0) when getting closer to the solution, you may want to increase this factor.

bool disable_acceleration = false

Don’t compute accelerated steps, fall back to forward-backward splitting.

For testing purposes.

template<Config Conf = DefaultConfig>
struct PANOCOCPProgressInfo
#include <alpaqa/inner/panoc-ocp.hpp>

Public Functions

vec u() const
vec û() const
vec x() const
vec x_hat() const

Public Members

unsigned k
SolverStatus status
crvec xu
crvec p
real_t norm_sq_p
crvec x̂u
real_t φγ
real_t ψ
crvec grad_ψ
real_t ψ_hat
crvec q
bool gn
length_t nJ
real_t lqr_min_rcond
real_t L
real_t γ
real_t τ
real_t ε
unsigned outer_iter
const TypeErasedControlProblem<config_t> *problem
const PANOCOCPParams<config_t> *params
template<Config Conf>
class PANOCOCPSolver
#include <alpaqa/inner/panoc-ocp.hpp>

Public Types

using Problem = alpaqa::TypeErasedControlProblem<config_t>
using Params = PANOCOCPParams<config_t>
using Stats = PANOCOCPStats<config_t>
using ProgressInfo = PANOCOCPProgressInfo<config_t>
using SolveOptions = InnerSolveOptions<config_t>

Public Functions

inline PANOCOCPSolver(const Params &params)
Stats operator()(const Problem &problem, const SolveOptions &opts, rvec u, rvec y, crvec μ, rvec err_z)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec u, rvec y, crvec μ, rvec e)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec u)
inline PANOCOCPSolver &set_progress_callback(std::function<void(const ProgressInfo&)> cb)

Specify a callable that is invoked with some intermediate results on each iteration of the algorithm.

See also

ProgressInfo

std::string get_name() const
inline void stop()
inline const Params &get_params() const

Public Members

std::ostream *os = &std::cout
template<Config Conf = DefaultConfig>
struct PANOCOCPStats
#include <alpaqa/inner/panoc-ocp.hpp>

Public Members

SolverStatus status = SolverStatus::Busy
real_t ε = inf<config_t>
std::chrono::nanoseconds elapsed_time = {}
std::chrono::nanoseconds time_prox = {}
std::chrono::nanoseconds time_forward = {}
std::chrono::nanoseconds time_backward = {}
std::chrono::nanoseconds time_jacobians = {}
std::chrono::nanoseconds time_hessians = {}
std::chrono::nanoseconds time_indices = {}
std::chrono::nanoseconds time_lqr_factor = {}
std::chrono::nanoseconds time_lqr_solve = {}
std::chrono::nanoseconds time_lbfgs_indices = {}
std::chrono::nanoseconds time_lbfgs_apply = {}
std::chrono::nanoseconds time_lbfgs_update = {}
std::chrono::nanoseconds time_progress_callback = {}
unsigned iterations = 0
unsigned linesearch_failures = 0
unsigned linesearch_backtracks = 0
unsigned stepsize_backtracks = 0
unsigned direction_failures = 0
unsigned direction_update_rejected = 0
unsigned τ_1_accepted = 0
unsigned count_τ = 0
real_t sum_τ = 0
real_t final_γ = 0
real_t final_ψ = 0
real_t final_h = 0
real_t final_φγ = 0
template<Config Conf = DefaultConfig>
struct PANOCParams
#include <alpaqa/inner/panoc.hpp>

Tuning parameters for the PANOC algorithm.

Public Members

LipschitzEstimateParams<config_t> Lipschitz = {}

Parameters related to the Lipschitz constant estimate and step size.

unsigned max_iter = 100

Maximum number of inner PANOC iterations.

std::chrono::nanoseconds max_time = std::chrono::minutes(5)

Maximum duration.

real_t min_linesearch_coefficient = real_t(1. / 256)

Minimum weight factor between Newton step and projected gradient step.

real_t linesearch_coefficient_update_factor = real_t(0.5)

Factor to decrease the line search factor by after a line search failure.

bool force_linesearch = false

Ignore the line search condition and always accept the accelerated step.

(For testing purposes only).

real_t linesearch_strictness_factor = real_t(0.95)

Parameter β used in the line search (see Algorithm 2 in [2]).

\( 0 < \beta < 1 \)

real_t L_min = real_t(1e-5)

Minimum Lipschitz constant estimate.

real_t L_max = real_t(1e20)

Maximum Lipschitz constant estimate.

PANOCStopCrit stop_crit = PANOCStopCrit::ApproxKKT

What stopping criterion to use.

unsigned max_no_progress = 10

Maximum number of iterations without any progress before giving up.

unsigned print_interval = 0

When to print progress.

If set to zero, nothing will be printed. If set to N != 0, progress is printed every N iterations.

int print_precision = std::numeric_limits<real_t>::max_digits10 / 2

The precision of the floating point values printed by the solver.

real_t quadratic_upperbound_tolerance_factor = 10 * std::numeric_limits<real_t>::epsilon()

Tolerance factor used in the quadratic upper bound condition that determines the step size.

Its goal is to account for numerical errors in the function and gradient evaluations. If you notice that the step size γ becomes very small, you may want to increase this factor.

real_t linesearch_tolerance_factor = 10 * std::numeric_limits<real_t>::epsilon()

Tolerance factor used in the line search.

Its goal is to account for numerical errors in the function and gradient evaluations. If you notice that accelerated steps are rejected (τ = 0) when getting closer to the solution, you may want to increase this factor.

bool update_direction_in_candidate = false

Use the candidate point rather than the accepted point to update the quasi-Newton direction.

bool recompute_last_prox_step_after_stepsize_change = false

If the step size changes, the direction buffer is flushed.

The current step will still be used to update the direction, but may still use the old step size. If set to true, the current step will be recomputed with the new step size as well, to match the step in the candidate iterate.

bool eager_gradient_eval = false

When evaluating ψ(x̂) in a candidate point, always evaluate ∇ψ(x̂) as well.

Can be beneficial if computing ∇ψ(x̂) is not much more expensive than computing just ψ(x), and if ∇ψ(x̂) is required in the next iteration (e.g. for the stopping criterion, or when using the NoopDirection).

template<Config Conf = DefaultConfig>
struct PANOCProgressInfo
#include <alpaqa/inner/panoc.hpp>

Public Members

unsigned k
SolverStatus status
crvec x
crvec p
real_t norm_sq_p
crvec x_hat
crvec ŷ
real_t φγ
real_t ψ
crvec grad_ψ
real_t ψ_hat
crvec grad_ψ_hat
crvec q
real_t L
real_t γ
real_t τ
real_t ε
crvec Σ
crvec y
unsigned outer_iter
const TypeErasedProblem<config_t> *problem
const PANOCParams<config_t> *params
template<class DirectionT>
class PANOCSolver
#include <alpaqa/inner/panoc.hpp>

PANOC solver for ALM.

Public Types

using Problem = TypeErasedProblem<config_t>
using Params = PANOCParams<config_t>
using Direction = DirectionT
using Stats = PANOCStats<config_t>
using ProgressInfo = PANOCProgressInfo<config_t>
using SolveOptions = InnerSolveOptions<config_t>

Public Functions

inline PANOCSolver(const Params &params)
inline PANOCSolver(const Params &params, Direction &&direction)
inline PANOCSolver(const Params &params, const Direction &direction)
Stats operator()(const Problem &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec err_z)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec e)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec x)
inline PANOCSolver &set_progress_callback(std::function<void(const ProgressInfo&)> cb)

Specify a callable that is invoked with some intermediate results on each iteration of the algorithm.

See also

ProgressInfo

std::string get_name() const
inline void stop()
inline const Params &get_params() const

Public Members

Direction direction
std::ostream *os = &std::cout
template<Config Conf = DefaultConfig>
struct PANOCStats
#include <alpaqa/inner/panoc.hpp>

Public Members

SolverStatus status = SolverStatus::Busy
real_t ε = inf<config_t>
std::chrono::nanoseconds elapsed_time = {}
std::chrono::nanoseconds time_progress_callback = {}
unsigned iterations = 0
unsigned linesearch_failures = 0
unsigned linesearch_backtracks = 0
unsigned stepsize_backtracks = 0
unsigned direction_failures = 0
unsigned direction_update_rejected = 0
unsigned τ_1_accepted = 0
unsigned count_τ = 0
real_t sum_τ = 0
real_t final_γ = 0
real_t final_ψ = 0
real_t final_h = 0
real_t final_φγ = 0
template<Config Conf>
struct PANTRDirection
#include <alpaqa/inner/directions/pantr/pantr-direction.hpp>

This class outlines the interface for direction providers used by PANTR-like algorithms.

Public Types

using Problem = TypeErasedProblem<config_t>

Public Functions

void initialize(const Problem &problem, crvec y, crvec Σ, real_t γ_0, crvec x_0, crvec x̂_0, crvec p_0, crvec grad_ψx_0) = delete

Initialize the direction provider.

The references problem, y and Σ are guaranteed to remain valid for subsequent calls to update, apply, changed_γ and reset.

Parameters:
  • problem[in] Problem description.

  • y[in] Lagrange multipliers.

  • Σ[in] Penalty factors.

  • γ_0[in] Initial step size.

  • x_0[in] Initial iterate.

  • x̂_0[in] Result of proximal gradient step in x_0.

  • p_0[in] Proximal gradient step in x_0.

  • grad_ψx_0[in] Gradient of the objective in x_0.

inline bool has_initial_direction() const

Return whether a direction is available on the very first iteration, before the first call to update.

bool update(real_t γₖ, real_t γₙₑₓₜ, crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, crvec grad_ψxₖ, crvec grad_ψxₙₑₓₜ) = delete

Update the direction provider when accepting the next iterate.

Parameters:
  • γₖ[in] Current step size.

  • γₙₑₓₜ[in] Step size for the next iterate.

  • xₖ[in] Current iterate.

  • xₙₑₓₜ[in] Next iterate.

  • pₖ[in] Proximal gradient step in the current iterate.

  • pₙₑₓₜ[in] Proximal gradient step in the next iterate.

  • grad_ψxₖ[in] Gradient of the objective in the current iterate.

  • grad_ψxₙₑₓₜ[in] Gradient of the objective in the next iterate.

real_t apply(real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, real_t radius, rvec qₖ) const = delete

Compute the direction in the given point.

Parameters:
  • γₖ[in] Current step size.

  • xₖ[in] Current iterate.

  • x̂ₖ[in] Result of proximal gradient step in xₖ.

  • pₖ[in] Proximal gradient step in xₖ.

  • grad_ψxₖ[in] Gradient of the objective at xₖ.

  • radius[in] Trust radius Δ.

  • qₖ[out] Resulting step.

Returns:

Model decrease.

void changed_γ(real_t γₖ, real_t old_γₖ) = delete

Called when the PANTR step size changes.

void reset() = delete

Called when using the direction failed.

A possible behavior could be to flush the buffers, hopefully yielding a better direction on the next iteration.

std::string get_name() const = delete

Get a human-readable name for this direction provider.

template<Config Conf = DefaultConfig>
struct PANTRParams
#include <alpaqa/inner/pantr.hpp>

Tuning parameters for the PANTR algorithm.

Public Members

LipschitzEstimateParams<config_t> Lipschitz = {}

Parameters related to the Lipschitz constant estimate and step size.

unsigned max_iter = 100

Maximum number of inner PANTR iterations.

std::chrono::nanoseconds max_time = std::chrono::minutes(5)

Maximum duration.

real_t L_min = real_t(1e-5)

Minimum Lipschitz constant estimate.

real_t L_max = real_t(1e20)

Maximum Lipschitz constant estimate.

PANOCStopCrit stop_crit = PANOCStopCrit::ApproxKKT

What stopping criterion to use.

unsigned max_no_progress = 10

Maximum number of iterations without any progress before giving up.

unsigned print_interval = 0

When to print progress.

If set to zero, nothing will be printed. If set to N != 0, progress is printed every N iterations.

int print_precision = std::numeric_limits<real_t>::max_digits10 / 2

The precision of the floating point values printed by the solver.

real_t quadratic_upperbound_tolerance_factor = 10 * std::numeric_limits<real_t>::epsilon()

Tolerance factor used in the quadratic upper bound condition that determines the step size.

Its goal is to account for numerical errors in the function and gradient evaluations. If you notice that the step size γ becomes very small, you may want to increase this factor.

real_t TR_tolerance_factor = 10 * std::numeric_limits<real_t>::epsilon()
real_t ratio_threshold_acceptable = real_t(0.2)

Minimal TR ratio to be accepted (successful).

real_t ratio_threshold_good = real_t(0.8)

Minimal TR ratio to increase radius (very successful).

real_t radius_factor_rejected = real_t(0.35)

TR radius decrease coefficient when unsuccessful.

real_t radius_factor_acceptable = real_t(0.999)

TR radius decrease coefficient when successful.

real_t radius_factor_good = real_t(2.5)

TR radius increase coefficient when very successful.

real_t initial_radius = NaN<config_t>

Initial trust radius.

real_t min_radius = 100 * std::numeric_limits<real_t>::epsilon()

Minimum trust radius.

bool compute_ratio_using_new_stepsize = false

Check the quadratic upper bound and update γ before computing the reduction of the TR step.

bool update_direction_on_prox_step = true
bool recompute_last_prox_step_after_direction_reset = false
bool disable_acceleration = false

Don’t compute accelerated steps, fall back to forward-backward splitting.

For testing purposes.

bool ratio_approx_fbe_quadratic_model = true

Compute the trust-region ratio using an approximation of the quadratic model of the FBE, rather than the quadratic model of the subproblem.

Specifically, when set to false, the quadratic model used is

\[ q(d) = \tfrac12 \inprod{\mathcal R_\gamma(\hat x) d}{d} + \inprod{R_\gamma(\hat x)}{d}. \]
When set to true, the quadratic model used is
\[ q_\mathrm{approx}(d) = \inv{(1-\alpha)} q(d), \]
where \( \alpha = \) Lγ_factor. This is an approximation of the quadratic model of the FBE,
\[ q_{\varphi_\gamma}(d) = \tfrac12 \inprod{\mathcal Q_\gamma(\hat x) \mathcal R_\gamma(\hat x) d}{d} + \inprod{\mathcal Q_\gamma(\hat x) R_\gamma(\hat x)}{d}, \]
with \( \mathcal Q_\gamma(x) = \Id - \gamma \nabla^2 \psi(x) \).

template<Config Conf = DefaultConfig>
struct PANTRProgressInfo
#include <alpaqa/inner/pantr.hpp>

Public Members

unsigned k
SolverStatus status
crvec x
crvec p
real_t norm_sq_p
crvec x_hat
crvec ŷ
real_t φγ
real_t ψ
crvec grad_ψ
real_t ψ_hat
crvec grad_ψ_hat
crvec q
real_t L
real_t γ
real_t Δ
real_t ρ
real_t τ

1 if previous step accepted, 0 otherwise (PANOC compatibility)

real_t ε
crvec Σ
crvec y
unsigned outer_iter
const TypeErasedProblem<config_t> *problem
const PANTRParams<config_t> *params
template<class DirectionT>
class PANTRSolver
#include <alpaqa/inner/pantr.hpp>

PANTR solver for ALM.

Public Types

using Problem = TypeErasedProblem<config_t>
using Params = PANTRParams<config_t>
using Direction = DirectionT
using Stats = PANTRStats<config_t>
using ProgressInfo = PANTRProgressInfo<config_t>
using SolveOptions = InnerSolveOptions<config_t>

Public Functions

inline PANTRSolver(const Params &params)
inline PANTRSolver(const Params &params, Direction &&direction)
inline PANTRSolver(const Params &params, const Direction &direction)
Stats operator()(const Problem &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec err_z)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec e)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec x)
inline PANTRSolver &set_progress_callback(std::function<void(const ProgressInfo&)> cb)

Specify a callable that is invoked with some intermediate results on each iteration of the algorithm.

See also

ProgressInfo

std::string get_name() const
inline void stop()
inline const Params &get_params() const

Public Members

Direction direction
std::ostream *os = &std::cout
template<Config Conf = DefaultConfig>
struct PANTRStats
#include <alpaqa/inner/pantr.hpp>

Public Members

SolverStatus status = SolverStatus::Busy
real_t ε = inf<config_t>
std::chrono::nanoseconds elapsed_time = {}
std::chrono::nanoseconds time_progress_callback = {}
unsigned iterations = 0
unsigned accelerated_step_rejected = 0
unsigned stepsize_backtracks = 0
unsigned direction_failures = 0
unsigned direction_update_rejected = 0
real_t final_γ = 0
real_t final_ψ = 0
real_t final_h = 0
real_t final_φγ = 0
template<Config Conf>
struct ProblemVTable : public BasicVTable
#include <alpaqa/problem/type-erased-problem.hpp>

Struct containing function pointers to all problem functions (like the objective and constraint functions, with their derivatives, and more).

Some default implementations are available. Internal struct, it is used by TypeErasedProblem.

Public Types

using Box = alpaqa::Box<config_t>
template<class F>
using optional_function_t = guanaqo::optional_function_t<F, ProblemVTable>
template<class F>
using required_function_t = guanaqo::required_function_t<F>

Public Functions

template<class P>
inline ProblemVTable(std::in_place_t, P &p)
ProblemVTable() = default

Public Members

required_function_t<void(crvec z, rvec e) const> eval_projecting_difference_constraints
required_function_t<void(rvec y, real_t M) const> eval_projection_multipliers
required_function_t<real_t(real_t γ, crvec x, crvec grad_ψ, rvec x_hat, rvec p) const> eval_proximal_gradient_step
required_function_t<real_t(crvec x) const> eval_objective
required_function_t<void(crvec x, rvec grad_fx) const> eval_objective_gradient
required_function_t<void(crvec x, rvec gx) const> eval_constraints
required_function_t<void(crvec x, crvec y, rvec grad_gxy) const> eval_constraints_gradient_product
optional_function_t<index_t(real_t γ, crvec x, crvec grad_ψ, rindexvec J) const> eval_inactive_indices_res_lna = default_eval_inactive_indices_res_lna
optional_function_t<void(crvec x, rvec J_values) const> eval_constraints_jacobian = default_eval_constraints_jacobian
optional_function_t<Sparsity() const> get_constraints_jacobian_sparsity = default_get_constraints_jacobian_sparsity
optional_function_t<void(crvec x, index_t i, rvec grad_gi) const> eval_grad_gi = default_eval_grad_gi
optional_function_t<void(crvec x, crvec y, real_t scale, crvec v, rvec Hv) const> eval_lagrangian_hessian_product = default_eval_lagrangian_hessian_product
optional_function_t<void(crvec x, crvec y, real_t scale, rvec H_values) const> eval_lagrangian_hessian = default_eval_lagrangian_hessian
optional_function_t<Sparsity() const> get_lagrangian_hessian_sparsity = default_get_lagrangian_hessian_sparsity
optional_function_t<void(crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const> eval_augmented_lagrangian_hessian_product = default_eval_augmented_lagrangian_hessian_product
optional_function_t<void(crvec x, crvec y, crvec Σ, real_t scale, rvec H_values) const> eval_augmented_lagrangian_hessian = default_eval_augmented_lagrangian_hessian
optional_function_t<Sparsity() const> get_augmented_lagrangian_hessian_sparsity = default_get_augmented_lagrangian_hessian_sparsity
optional_function_t<real_t(crvec x, rvec grad_fx) const> eval_objective_and_gradient = default_eval_objective_and_gradient
optional_function_t<real_t(crvec x, rvec g) const> eval_objective_and_constraints = default_eval_objective_and_constraints
optional_function_t<void(crvec x, crvec y, rvec grad_f, rvec grad_gxy) const> eval_objective_gradient_and_constraints_gradient_product = default_eval_objective_gradient_and_constraints_gradient_product
optional_function_t<void(crvec x, crvec y, rvec grad_L, rvec work_n) const> eval_lagrangian_gradient = default_eval_lagrangian_gradient
optional_function_t<real_t(crvec x, crvec y, crvec Σ, rvec ŷ) const> eval_augmented_lagrangian = default_eval_augmented_lagrangian
optional_function_t<void(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const> eval_augmented_lagrangian_gradient = default_eval_augmented_lagrangian_gradient
optional_function_t<real_t(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const> eval_augmented_lagrangian_and_gradient = default_eval_augmented_lagrangian_and_gradient
optional_function_t<const Box&() const> get_variable_bounds = default_get_variable_bounds
optional_function_t<const Box&() const> get_general_bounds = default_get_general_bounds
optional_function_t<void() const> check = default_check
optional_function_t<std::string() const> get_name = default_get_name
length_t n
length_t m

Public Static Functions

static ALPAQA_EXPORT_STATIC real_t calc_ŷ_dᵀŷ (const void *self, rvec g_ŷ, crvec y, crvec Σ, const ProblemVTable &vtable)
static ALPAQA_EXPORT_STATIC index_t default_eval_inactive_indices_res_lna (const void *, real_t, crvec, crvec, rindexvec, const ProblemVTable &)
static ALPAQA_EXPORT_STATIC void default_eval_constraints_jacobian (const void *, crvec, rvec, const ProblemVTable &)
static ALPAQA_EXPORT_STATIC Sparsity default_get_constraints_jacobian_sparsity (const void *, const ProblemVTable &)
static ALPAQA_EXPORT_STATIC void default_eval_grad_gi (const void *, crvec, index_t, rvec, const ProblemVTable &)
static ALPAQA_EXPORT_STATIC void default_eval_lagrangian_hessian_product (const void *, crvec, crvec, real_t, crvec, rvec, const ProblemVTable &)
static ALPAQA_EXPORT_STATIC void default_eval_lagrangian_hessian (const void *, crvec, crvec, real_t, rvec, const ProblemVTable &)
static ALPAQA_EXPORT_STATIC Sparsity default_get_lagrangian_hessian_sparsity (const void *, const ProblemVTable &)
static ALPAQA_EXPORT_STATIC void default_eval_augmented_lagrangian_hessian_product (const void *self, crvec x, crvec y, crvec, real_t scale, crvec v, rvec Hv, const ProblemVTable &vtable)
static ALPAQA_EXPORT_STATIC void default_eval_augmented_lagrangian_hessian (const void *self, crvec x, crvec y, crvec, real_t scale, rvec H_values, const ProblemVTable &vtable)
static ALPAQA_EXPORT_STATIC Sparsity default_get_augmented_lagrangian_hessian_sparsity (const void *, const ProblemVTable &)
static ALPAQA_EXPORT_STATIC real_t default_eval_objective_and_gradient (const void *self, crvec x, rvec grad_fx, const ProblemVTable &vtable)
static ALPAQA_EXPORT_STATIC real_t default_eval_objective_and_constraints (const void *self, crvec x, rvec g, const ProblemVTable &vtable)
static ALPAQA_EXPORT_STATIC void default_eval_objective_gradient_and_constraints_gradient_product (const void *self, crvec x, crvec y, rvec grad_f, rvec grad_gxy, const ProblemVTable &vtable)
static ALPAQA_EXPORT_STATIC void default_eval_lagrangian_gradient (const void *self, crvec x, crvec y, rvec grad_L, rvec work_n, const ProblemVTable &vtable)
static ALPAQA_EXPORT_STATIC real_t default_eval_augmented_lagrangian (const void *self, crvec x, crvec y, crvec Σ, rvec ŷ, const ProblemVTable &vtable)
static ALPAQA_EXPORT_STATIC void default_eval_augmented_lagrangian_gradient (const void *self, crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m, const ProblemVTable &vtable)
static ALPAQA_EXPORT_STATIC real_t default_eval_augmented_lagrangian_and_gradient (const void *self, crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m, const ProblemVTable &vtable)
static ALPAQA_EXPORT_STATIC const Box & default_get_variable_bounds (const void *, const ProblemVTable &)
static ALPAQA_EXPORT_STATIC const Box & default_get_general_bounds (const void *, const ProblemVTable &)
static ALPAQA_EXPORT_STATIC void default_check (const void *, const ProblemVTable &)
static ALPAQA_EXPORT_STATIC std::string default_get_name (const void *, const ProblemVTable &)
template<class Problem>
struct ProblemWithCounters
#include <alpaqa/problem/problem-with-counters.hpp>

Problem wrapper that keeps track of the number of evaluations and the run time of each function.

You probably want to use problem_with_counters or problem_with_counters_ref instead of instantiating this class directly.

Note

The evaluation counters are stored using a std::shared_pointers, which means that different copies of a ProblemWithCounters instance all share the same counters. To opt out of this behavior, you can use the decouple_evaluations function.

Public Types

using Box = typename TypeErasedProblem<config_t>::Box

Public Functions

inline void eval_projecting_difference_constraints(crvec z, rvec e) const
inline void eval_projection_multipliers(rvec y, real_t M) const
inline real_t eval_proximal_gradient_step(real_t γ, crvec x, crvec grad_ψ, rvec x_hat, rvec p) const
inline index_t eval_inactive_indices_res_lna(real_t γ, crvec x, crvec grad_ψ, rindexvec J) const
inline real_t eval_objective(crvec x) const
inline void eval_objective_gradient(crvec x, rvec grad_fx) const
inline void eval_constraints(crvec x, rvec gx) const
inline void eval_constraints_gradient_product(crvec x, crvec y, rvec grad_gxy) const
inline void eval_grad_gi(crvec x, index_t i, rvec grad_gi) const
inline void eval_constraints_jacobian(crvec x, rvec J_values) const
inline Sparsity get_constraints_jacobian_sparsity() const
inline void eval_lagrangian_hessian_product(crvec x, crvec y, real_t scale, crvec v, rvec Hv) const
inline void eval_lagrangian_hessian(crvec x, crvec y, real_t scale, rvec H_values) const
inline Sparsity get_lagrangian_hessian_sparsity() const
inline void eval_augmented_lagrangian_hessian_product(crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
inline void eval_augmented_lagrangian_hessian(crvec x, crvec y, crvec Σ, real_t scale, rvec H_values) const
inline Sparsity get_augmented_lagrangian_hessian_sparsity() const
inline real_t eval_objective_and_gradient(crvec x, rvec grad_fx) const
inline real_t eval_objective_and_constraints(crvec x, rvec g) const
inline void eval_objective_gradient_and_constraints_gradient_product(crvec x, crvec y, rvec grad_f, rvec grad_gxy) const
inline void eval_lagrangian_gradient(crvec x, crvec y, rvec grad_L, rvec work_n) const
inline real_t eval_augmented_lagrangian(crvec x, crvec y, crvec Σ, rvec ŷ) const
inline void eval_augmented_lagrangian_gradient(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
inline real_t eval_augmented_lagrangian_and_gradient(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
inline const Box &get_variable_bounds() const
inline const Box &get_general_bounds() const
inline void check() const
inline std::string get_name() const
inline bool provides_eval_grad_gi() const
inline bool provides_eval_inactive_indices_res_lna() const
inline bool provides_eval_constraints_jacobian() const
inline bool provides_get_constraints_jacobian_sparsity() const
inline bool provides_eval_lagrangian_hessian_product() const
inline bool provides_eval_lagrangian_hessian() const
inline bool provides_get_lagrangian_hessian_sparsity() const
inline bool provides_eval_augmented_lagrangian_hessian_product() const
inline bool provides_eval_augmented_lagrangian_hessian() const
inline bool provides_get_augmented_lagrangian_hessian_sparsity() const
inline bool provides_eval_objective_and_gradient() const
inline bool provides_eval_objective_and_constraints() const
inline bool provides_eval_objective_gradient_and_constraints_gradient_product() const
inline bool provides_eval_lagrangian_gradient() const
inline bool provides_eval_augmented_lagrangian() const
inline bool provides_eval_augmented_lagrangian_gradient() const
inline bool provides_eval_augmented_lagrangian_and_gradient() const
inline bool provides_get_variable_bounds() const
inline bool provides_get_general_bounds() const
inline bool provides_check() const
inline bool provides_get_name() const
inline length_t get_num_variables() const
inline length_t get_num_constraints() const
ProblemWithCounters() = default
template<class P>
inline explicit ProblemWithCounters(P &&problem)
template<class ...Args>
inline explicit ProblemWithCounters(std::in_place_t, Args&&... args)
inline void reset_evaluations()

Reset all evaluation counters and timers to zero.

Affects all instances that share the same evaluations. If you only want to reset the counters of this instance, use decouple_evaluations first.

inline void decouple_evaluations()

Give this instance its own evaluation counters and timers, decoupling it from any other instances they might have previously been shared with.

The evaluation counters and timers are preserved (a copy is made).

Public Members

std::shared_ptr<EvalCounter> evaluations = std::make_shared<EvalCounter>()
Problem problem
struct prox_fn
#include <alpaqa/functions/prox.hpp>

Proximal mapping customization point.

Public Functions

template<class T>
inline typename T::config_t::real_t operator()(T &func, typename T::config_t::crmat in, typename T::config_t::rmat out, typename T::config_t::real_t γ = 1) const
struct prox_step_fn
#include <alpaqa/functions/prox.hpp>

Proximal mapping customization point for forward-backward steps.

Public Functions

template<class T>
inline typename T::config_t::real_t operator()(T &func, typename T::config_t::crmat in, typename T::config_t::crmat fwd_step, typename T::config_t::rmat out, typename T::config_t::rmat fb_step, typename T::config_t::real_t γ = 1, typename T::config_t::real_t γ_fwd = -1) const
template<class T>
inline typename T::config_t::real_t operator()(T &func, typename T::config_t::crmat in, typename T::config_t::crmat fwd_step, typename T::config_t::rmat out, typename T::config_t::rmat fb_step, typename T::config_t::real_t γ = 1, typename T::config_t::real_t γ_fwd = -1) const

Default implementation for prox_step if only prox is provided.

struct ScopedMallocAllower : public ScopedMallocChecker<true>
#include <alpaqa/util/alloc-check.hpp>
struct ScopedMallocBlocker : public ScopedMallocChecker<false>
#include <alpaqa/util/alloc-check.hpp>
template<bool>
struct ScopedMallocChecker
#include <alpaqa/util/alloc-check.hpp>

Public Functions

inline ScopedMallocChecker() noexcept
struct SerializedCasADiFunctions
#include <alpaqa/casadi/CasADiProblem.hpp>

Public Members

std::map<std::string, std::string> functions
template<Config Conf>
struct StatefulLQRFactor
#include <alpaqa/inner/directions/panoc-ocp/lqr.hpp>

Public Types

using Dim = alpaqa::Dim<config_t>

Public Functions

inline StatefulLQRFactor(Dim d)
inline void factor_masked(auto &&AB, auto &&Q, auto &&R, auto &&S, auto &&R_prod, auto &&S_prod, auto &&q, auto &&r, auto &&u, auto &&J, auto &&K, bool use_cholesky)
Parameters:
  • AB – System matrix A & input matrix B

  • Q – State cost matrix Q

  • R – Input cost matrix R

  • S – Cross cost matrix S

  • R_prod – Product with input cost matrix R

  • S_prod – Product with cross cost matrix S

  • q – Linear state factor q

  • r – Linear input factor r

  • u – Fixed inputs u

  • J – Index set of inactive constraints

  • K – Index set of active constraints

  • use_cholesky – Use Cholesky instead of LU solver

inline void solve_masked(auto &&AB, auto &&J, rvec Δu_eq, rvec Δx)

Public Members

Dim dim
mat P = {dim.nx, dim.nx}
mat gain_K = {dim.nu * dim.nx, dim.N}
mat e = {dim.nu, dim.N}
vec s = {dim.nx}
vec c = {dim.nx}
vec y = {dim.nx}
vec t = {dim.nu}
vec R̅_sto = {dim.nu * dim.nu}
vec S̅_sto = {dim.nu * dim.nx}
vec BiJ_sto = {dim.nx * dim.nu}
vec PBiJ_sto = {dim.nx * dim.nu}
mat PA = {dim.nx, dim.nx}
real_t min_rcond = 1
template<Config Conf>
struct SteihaugCG
#include <alpaqa/accelerators/steihaugcg.hpp>

Steihaug conjugate gradients procedure based on https://github.com/scipy/scipy/blob/583e70a50573169fc352b5dc6d94588a97c7389a/scipy/optimize/_trustregion_ncg.py#L44.

Public Types

using Params = SteihaugCGParams<config_t>

Public Functions

SteihaugCG() = default
inline SteihaugCG(const Params &params)
inline void resize(length_t n)
template<class HessFun>
inline real_t solve(const auto &grad, const HessFun &hess_prod, real_t trust_radius, rvec step) const

Public Members

Params params
mutable vec z
vec r
vec d
vec Bd
vec work_eval

Public Static Functions

static inline auto get_boundaries_intersections(crvec z, crvec d, real_t trust_radius)

Solve the scalar quadratic equation ||z + t d|| == trust_radius.

This is like a line-sphere intersection. Return the two values of t, sorted from low to high.

template<Config Conf>
struct SteihaugCGParams
#include <alpaqa/accelerators/steihaugcg.hpp>

Parameters for SteihaugCG.

Public Members

real_t tol_scale = 1

Determines the tolerance for termination of the algorithm.

It terminates if the norm of the residual \( r = -g - Hq \) is smaller than the tolerance

\[ \mathrm{tolerance} = \min\left( \mathrm{tol\_max},\; \mathrm{tol\_scale}\cdot \|g\|\cdot \min\left(\mathrm{tol\_scale\_root},\; \sqrt{\|g\|}\right) \right) \]

real_t tol_scale_root = real_t(0.5)

Determines the tolerance for termination of the algorithm.

See tol_scale.

real_t tol_max = inf<config_t>

Determines the tolerance for termination of the algorithm.

Prevents the use of huge tolerances if the gradient norm is still large. See tol_scale.

real_t max_iter_factor = 1

Limit the number of CG iterations to \( \lfloor n \cdot \mathrm{max\_iter\_factor} \rceil \), where \( n \) is the number of free variables of the problem.

template<Config Conf = DefaultConfig>
struct StructuredLBFGSDirection
#include <alpaqa/inner/directions/panoc/structured-lbfgs.hpp>

Public Types

using Problem = TypeErasedProblem<config_t>
using LBFGS = alpaqa::LBFGS<config_t>
using AcceleratorParams = typename LBFGS::Params
using DirectionParams = StructuredLBFGSDirectionParams<config_t>

Public Functions

StructuredLBFGSDirection() = default
inline StructuredLBFGSDirection(const Params &params)
inline StructuredLBFGSDirection(const typename LBFGS::Params &params, const DirectionParams &directionparams = {})
inline StructuredLBFGSDirection(const LBFGS &lbfgs, const DirectionParams &directionparams = {})
inline StructuredLBFGSDirection(LBFGS &&lbfgs, const DirectionParams &directionparams = {})
void initialize(const Problem &problem, crvec y, crvec Σ, real_t γ_0, crvec x_0, crvec x̂_0, crvec p_0, crvec grad_ψx_0)

See also

initialize

inline bool has_initial_direction() const

inline bool update(real_t γₖ, real_t γₙₑₓₜ, crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, crvec grad_ψxₖ, crvec grad_ψxₙₑₓₜ)

See also

update

bool apply(real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const

See also

apply

inline void changed_γ(real_t γₖ, real_t old_γₖ)

See also

changed_γ

inline void reset()

See also

reset

inline std::string get_name() const

See also

get_name

inline auto get_params() const

Public Members

DirectionParams direction_params
struct Params
#include <alpaqa/inner/directions/panoc/structured-lbfgs.hpp>

Public Members

AcceleratorParams accelerator = {}
DirectionParams direction = {}
template<Config Conf>
struct StructuredLBFGSDirectionParams
#include <alpaqa/inner/directions/panoc/structured-lbfgs.hpp>

Parameters for the StructuredLBFGSDirection class.

Public Types

enum FailurePolicy

Values:

enumerator FallbackToProjectedGradient

If L-BFGS fails, propagate the failure and tell PANOC that no accelerated step is available, causing it to accept the projected gradient step instead.

enumerator UseScaledLBFGSInput

If L-BFGS fails, return \( q_\mathcal{J} = -\gamma\nabla_{x_\mathcal{J}}\psi(x^k) -\gamma\nabla^2_{x_\mathcal{J}x_\mathcal{K}}\psi(x) q_\mathcal{K} \) as the accelerated step (effectively approximating \( \nabla_{x_\mathcal{J}x_\mathcal{J}} \approx \gamma I \)).

Public Members

real_t hessian_vec_factor = 0

Set this option to a nonzero value to include the Hessian-vector product \( \nabla^2_{x_\mathcal{J}x_\mathcal{K}}\psi(x) q_\mathcal{K} \) from equation 12b in [4], scaled by this parameter.

Set it to zero to leave out that term (this usually only slightly increases the number of iterations, and eliminates one Hessian-vector product per iteration, improving the overall runtime).

bool hessian_vec_finite_differences = true

If hessian_vec_factor is nonzero, set this option to true to approximate that term using finite differences instead of using AD.

bool full_augmented_hessian = true

If hessian_vec_factor is nonzero and hessian_vec_finite_differences is true, set this option to true to compute the exact Hessian of the augmented Lagrangian, false to approximate it using the Hessian of the Lagrangian.

enum alpaqa::StructuredLBFGSDirectionParams::FailurePolicy failure_policy = FallbackToProjectedGradient

What to do when L-BFGS failed (e.g.

if there were no pairs (s, y) with positive curvature).

template<Config Conf = DefaultConfig>
struct StructuredNewtonDirection
#include <alpaqa/inner/directions/panoc/structured-newton.hpp>

Public Types

using Problem = TypeErasedProblem<config_t>
using DirectionParams = StructuredNewtonDirectionParams<config_t>
using AcceleratorParams = StructuredNewtonRegularizationParams<config_t>

Public Functions

StructuredNewtonDirection() = default
inline StructuredNewtonDirection(const Params &params)
inline StructuredNewtonDirection(const AcceleratorParams &params, const DirectionParams &directionparams = {})
inline void initialize(const Problem &problem, crvec y, crvec Σ, real_t γ_0, crvec x_0, crvec x̂_0, crvec p_0, crvec grad_ψx_0)

See also

initialize

inline bool has_initial_direction() const

inline bool update(real_t γₖ, real_t γₙₑₓₜ, crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, crvec grad_ψxₖ, crvec grad_ψxₙₑₓₜ)

See also

update

inline bool apply(real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const

See also

apply

inline void changed_γ(real_t γₖ, real_t old_γₖ)

See also

changed_γ

inline void reset()

See also

reset

inline std::string get_name() const

See also

get_name

inline const auto &get_params() const

Public Members

AcceleratorParams reg_params
DirectionParams direction_params
struct Params
#include <alpaqa/inner/directions/panoc/structured-newton.hpp>

Public Members

AcceleratorParams accelerator = {}
DirectionParams direction = {}
template<Config Conf>
struct StructuredNewtonDirectionParams
#include <alpaqa/inner/directions/panoc/structured-newton.hpp>

Parameters for the StructuredNewtonDirection class.

Public Members

real_t hessian_vec_factor = 0

Set this option to a nonzero value to include the Hessian-vector product \( \nabla^2_{x_\mathcal{J}x_\mathcal{K}}\psi(x) q_\mathcal{K} \) from equation 12b in [4], scaled by this parameter.

Set it to zero to leave out that term.

template<Config Conf>
struct StructuredNewtonRegularizationParams
#include <alpaqa/inner/directions/panoc/structured-newton.hpp>

Parameters for the StructuredNewtonDirection class.

Public Members

real_t min_eig = std::cbrt(std::numeric_limits<real_t>::epsilon())

Minimum eigenvalue of the Hessian, scaled by \( 1 + |\lambda_\mathrm{max}| \), enforced by regularization using a multiple of identity.

bool print_eig = false

Print the minimum and maximum eigenvalue of the Hessian.

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
class TypeErasedControlProblem : public guanaqo::TypeErased<ControlProblemVTable<DefaultConfig>, std::allocator<std::byte>>
#include <alpaqa/problem/ocproblem.hpp>

Nonlinear optimal control problem with finite horizon \( N \).

\[\begin{split}\newcommand\U{U} \newcommand\D{D} \newcommand\nnu{{n_u}} \newcommand\nnx{{n_x}} \newcommand\nny{{n_y}} \newcommand\xinit{x_\text{init}} \begin{equation}\label{eq:OCP} \tag{OCP}\hspace{-0.8em} \begin{aligned} &\minimize_{u,x} && \sum_{k=0}^{N-1} \ell_k\big(h_k(x^k, u^k)\big) + \ell_N\big(h_N(x^N)\big)\hspace{-0.8em} \\ &\subjto && u^k \in \U \\ &&& c_k(x^k) \in \D \\ &&& c_N(x^N) \in \D_N \\ &&& x^0 = \xinit \\ &&& x^{k+1} = f(x^k, u^k) \quad\quad (0 \le k \lt N) \end{aligned} \end{equation} \end{split}\]

The function \( f : \R^\nnx \times \R^\nnu \to \R^\nnx \) models the discrete-time, nonlinear dynamics of the system, which starts from an initial state \( \xinit \). The functions \( h_k : \R^\nnx \times \R^\nnu \to \R^{n_h} \) for \( 0 \le k \lt N \) and \( h_N : \R^\nnx \to \R^{n_h^N} \) can be used to represent the (possibly time-varying) output mapping of the system, and the convex functions \( \ell_k : \R^{n_h} \to \R \) and \( \ell_N : \R^{n_h^N} \to \R \) define the stage costs and the terminal cost respectively. Stage constraints and terminal constraints are represented by the functions \( c_k : \R^{n_x} \to \R^{n_c} \) and \( c_N : \R^{n_x} \to \R^{n_c^N} \), and the boxes \( D \) and \( D_N \).

Additional functions for computing Gauss-Newton approximations of the cost Hessian are included as well:

\[\begin{split} \begin{aligned} q^k &\defeq \tp{\jac_{h_k}^x\!(\barxuk)} \nabla \ell_k(\hhbar^k) \\ r^k &\defeq \tp{\jac_{h_k}^u\!(\barxuk)} \nabla \ell_k(\hhbar^k) \\ \Lambda_k &\defeq \partial^2 \ell_k(\hhbar^k) \\ Q_k &\defeq \tp{\jac_{h_k}^x\!(\barxuk)} \Lambda_k\, \jac_{h_k}^x\!(\barxuk) \\ S_k &\defeq \tp{\jac_{h_k}^u\!(\barxuk)} \Lambda_k\, \jac_{h_k}^x\!(\barxuk) \\ R_k &\defeq \tp{\jac_{h_k}^u\!(\barxuk)} \Lambda_k\, \jac_{h_k}^u\!(\barxuk). \\ \end{aligned} \end{split}\]
See [3] for more details.

Problem dimensions

inline length_t get_N() const

Horizon length.

inline length_t get_nu() const

Number of inputs.

inline length_t get_nx() const

Number of states.

inline length_t get_nh() const

Number of outputs.

inline length_t get_nh_N() const
inline length_t get_nc() const

Number of constraints.

inline length_t get_nc_N() const
inline Dim get_dim() const

All dimensions.

inline length_t get_num_variables() const

Total number of variables.

inline length_t get_num_constraints() const

Total number of constraints.

Projections onto constraint sets

inline void eval_projecting_difference_constraints(crvec z, rvec e) const

[Required] Function that evaluates the difference between the given point \( z \) and its projection onto the constraint set \( D \).

Note

z and e can refer to the same vector.

Parameters:
  • z[in] Slack variable, \( z \in \R^m \)

  • e[out] The difference relative to its projection, \( e = z - \Pi_D(z) \in \R^m \)

inline void eval_projection_multipliers(rvec y, real_t M) const

[Required] Function that projects the Lagrange multipliers for ALM.

Parameters:
  • y[inout] Multipliers, \( y \leftarrow \Pi_Y(y) \in \R^m \)

  • M[in] The radius/size of the set \( Y \). See max_multiplier.

Constraint sets

inline void get_U(Box &U) const

Input box constraints \( U \).

inline void get_D(Box &D) const

Stage box constraints \( D \).

inline void get_D_N(Box &D) const

Terminal box constraints \( D_N \).

Dynamics and initial state

inline void get_x_init(rvec x_init) const

Initial state \( x_\text{init} \).

inline void eval_f(index_t timestep, crvec x, crvec u, rvec fxu) const

Discrete-time dynamics \( x^{k+1} = f_k(x^k, u^k) \).

inline void eval_jac_f(index_t timestep, crvec x, crvec u, rmat J_fxu) const

Jacobian of discrete-time dynamics \( \jac_f(x^k, u^k) \).

inline void eval_grad_f_prod(index_t timestep, crvec x, crvec u, crvec p, rvec grad_fxu_p) const

Gradient-vector product of discrete-time dynamics \( \nabla f(x^k, u^k)\,p \).

Output mapping

inline void eval_h(index_t timestep, crvec x, crvec u, rvec h) const

Stage output mapping \( h_k(x^k, u^k) \).

inline void eval_h_N(crvec x, rvec h) const

Terminal output mapping \( h_N(x^N) \).

Stage and terminal cost

inline real_t eval_l(index_t timestep, crvec h) const

Stage cost \( \ell_k(\hbar^k) \).

inline real_t eval_l_N(crvec h) const

Terminal cost \( \ell_N(\hbar^N) \).

Gauss-Newton approximations

inline void eval_qr(index_t timestep, crvec xu, crvec h, rvec qr) const

Cost gradients w.r.t.

states and inputs \( q^k = \tp{\jac_{h_k}^x\!(\barxuk)} \nabla \ell_k(\hbar^k) \) and \( r^k = \tp{\jac_{h_k}^u\!(\barxuk)} \nabla \ell_k(\hbar^k) \).

inline void eval_q_N(crvec x, crvec h, rvec q) const

Terminal cost gradient w.r.t.

states \( q^N = \tp{\jac_{h_N}(\bar x^N)} \nabla \ell_k(\hbar^N) \).

inline void eval_add_Q(index_t timestep, crvec xu, crvec h, rmat Q) const

Cost Hessian w.r.t.

states \( Q_k = \tp{\jac_{h_k}^x\!(\barxuk)} \partial^2\ell_k(\hbar^k)\, \jac_{h_k}^x\!(\barxuk) \), added to the given matrix Q. \( Q \leftarrow Q + Q_k \).

inline void eval_add_Q_N(crvec x, crvec h, rmat Q) const

Terminal cost Hessian w.r.t.

states \( Q_N = \tp{\jac_{h_N}(\bar x^N)} \partial^2\ell_N(\hbar^N)\, \jac_{h_N}(\bar x^N) \), added to the given matrix Q. \( Q \leftarrow Q + Q_N \).

inline void eval_add_R_masked(index_t timestep, crvec xu, crvec h, crindexvec mask, rmat R, rvec work) const

Cost Hessian w.r.t.

inputs \( R_k = \tp{\jac_{h_k}^u\!(\barxuk)} \partial^2\ell_k(\hbar^k)\, \jac_{h_k}^u\!(\barxuk) \), keeping only rows and columns in the mask \( \mathcal J \), added to the given matrix R. \( R \leftarrow R + R_k[\mathcal J, \mathcal J] \). The size of work should be get_R_work_size().

inline void eval_add_S_masked(index_t timestep, crvec xu, crvec h, crindexvec mask, rmat S, rvec work) const

Cost Hessian w.r.t.

inputs and states \( S_k = \tp{\jac_{h_k}^u\!(\barxuk)} \partial^2\ell_k(\hbar^k)\, \jac_{h_k}^x\!(\barxuk) \), keeping only rows in the mask \( \mathcal J \), added to the given matrix S. \( S \leftarrow S + S_k[\mathcal J, \cdot] \). The size of work should be get_S_work_size().

inline void eval_add_R_prod_masked(index_t timestep, crvec xu, crvec h, crindexvec mask_J, crindexvec mask_K, crvec v, rvec out, rvec work) const

\( out \leftarrow out + R[\mathcal J, \mathcal K]\,v[\mathcal K] \).

Work should contain the contents written to it by a prior call to eval_add_R_masked() in the same point.

inline void eval_add_S_prod_masked(index_t timestep, crvec xu, crvec h, crindexvec mask_K, crvec v, rvec out, rvec work) const

\( out \leftarrow out + \tp{S[\mathcal K, \cdot]}\, v[\mathcal K] \).

Work should contain the contents written to it by a prior call to eval_add_S_masked() in the same point.

inline length_t get_R_work_size() const

Size of the workspace required by eval_add_R_masked() and eval_add_R_prod_masked().

inline length_t get_S_work_size() const

Size of the workspace required by eval_add_S_masked() and eval_add_S_prod_masked().

Constraints

inline void eval_constr(index_t timestep, crvec x, rvec c) const

Stage constraints \( c_k(x^k) \).

inline void eval_constr_N(crvec x, rvec c) const

Terminal constraints \( c_N(x^N) \).

inline void eval_grad_constr_prod(index_t timestep, crvec x, crvec p, rvec grad_cx_p) const

Gradient-vector product of stage constraints \( \nabla c_k(x^k)\, p \).

inline void eval_grad_constr_prod_N(crvec x, crvec p, rvec grad_cx_p) const

Gradient-vector product of terminal constraints \( \nabla c_N(x^N)\, p \).

inline void eval_add_gn_hess_constr(index_t timestep, crvec x, crvec M, rmat out) const

Gauss-Newton Hessian of stage constraints \( \tp{\jac_{c_k}}(x^k)\, \operatorname{diag}(M)\; \jac_{c_k}(x^k) \).

inline void eval_add_gn_hess_constr_N(crvec x, crvec M, rmat out) const

Gauss-Newton Hessian of terminal constraints \( \tp{\jac_{c_N}}(x^N)\, \operatorname{diag}(M)\; \jac_{c_N}(x^N) \).

Checks

inline void check() const

Check that the problem formulation is well-defined, the dimensions match, etc.

Throws an exception if this is not the case.

Querying specialized implementations

inline bool provides_get_D() const
inline bool provides_get_D_N() const
inline bool provides_eval_h() const
inline bool provides_eval_h_N() const
inline bool provides_eval_add_Q_N() const
inline bool provides_eval_add_R_prod_masked() const
inline bool provides_eval_add_S_prod_masked() const
inline bool provides_get_R_work_size() const
inline bool provides_get_S_work_size() const
inline bool provides_eval_constr() const
inline bool provides_eval_constr_N() const
inline bool provides_eval_grad_constr_prod() const
inline bool provides_eval_grad_constr_prod_N() const
inline bool provides_eval_add_gn_hess_constr() const
inline bool provides_eval_add_gn_hess_constr_N() const

Public Types

using VTable = ControlProblemVTable<config_t>
using allocator_type = Allocator
using Box = typename VTable::Box
using Dim = OCPDim<config_t>
using TypeErased = guanaqo::TypeErased<VTable, allocator_type>

Public Static Functions

template<class T, class ...Args>
static inline TypeErasedControlProblem make(Args&&... args)
template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
class TypeErasedProblem : public guanaqo::TypeErased<ProblemVTable<DefaultConfig>, std::allocator<std::byte>>
#include <alpaqa/problem/type-erased-problem.hpp>

The main polymorphic minimization problem interface.

This class wraps the actual problem implementation class, filling in the missing member functions with sensible defaults, and providing a uniform interface that is used by the solvers.

The problem implementations do not inherit from an abstract base class. Instead, structural typing is used. The ProblemVTable constructor uses reflection to discover which member functions are provided by the problem implementation. See Problem formulations for more information, and C++/CustomCppProblem/main.cpp for an example.

Problem dimensions

length_t get_num_variables() const

[Required] Number of decision variables.

length_t get_num_constraints() const

[Required] Number of constraints.

Required cost and constraint functions

real_t eval_objective(crvec x) const

[Required] Function that evaluates the cost, \( f(x) \)

Parameters:

x[in] Decision variable \( x \in \R^n \)

void eval_objective_gradient(crvec x, rvec grad_fx) const

[Required] Function that evaluates the gradient of the cost, \( \nabla f(x) \)

Parameters:
  • x[in] Decision variable \( x \in \R^n \)

  • grad_fx[out] Gradient of cost function \( \nabla f(x) \in \R^n \)

void eval_constraints(crvec x, rvec gx) const

[Required] Function that evaluates the constraints, \( g(x) \)

Parameters:
  • x[in] Decision variable \( x \in \R^n \)

  • gx[out] Value of the constraints \( g(x) \in \R^m \)

void eval_constraints_gradient_product(crvec x, crvec y, rvec grad_gxy) const

[Required] Function that evaluates the gradient of the constraints times a vector, \( \nabla g(x)\,y = \tp{\jac_g(x)}y \)

Parameters:
  • x[in] Decision variable \( x \in \R^n \)

  • y[in] Vector \( y \in \R^m \) to multiply the gradient by

  • grad_gxy[out] Gradient of the constraints \( \nabla g(x)\,y \in \R^n \)

Projections onto constraint sets and proximal mappings

void eval_projecting_difference_constraints(crvec z, rvec e) const

[Required] Function that evaluates the difference between the given point \( z \) and its projection onto the constraint set \( D \).

Note

z and e can refer to the same vector.

Parameters:
  • z[in] Slack variable, \( z \in \R^m \)

  • e[out] The difference relative to its projection, \( e = z - \Pi_D(z) \in \R^m \)

void eval_projection_multipliers(rvec y, real_t M) const

[Required] Function that projects the Lagrange multipliers for ALM.

Parameters:
  • y[inout] Multipliers, \( y \leftarrow \Pi_Y(y) \in \R^m \)

  • M[in] The radius/size of the set \( Y \). See max_multiplier.

real_t eval_proximal_gradient_step(real_t γ, crvec x, crvec grad_ψ, rvec x_hat, rvec p) const

[Required] Function that computes a proximal gradient step.

Note

The vector \( p \) is often used in stopping criteria, so its numerical accuracy is more important than that of \( \hat x \).

Parameters:
  • γ[in] Step size, \( \gamma \in \R_{>0} \)

  • x[in] Decision variable \( x \in \R^n \)

  • grad_ψ[in] Gradient of the subproblem cost, \( \nabla\psi(x) \in \R^n \)

  • [out] Next proximal gradient iterate, \( \hat x = T_\gamma(x) = \prox_{\gamma h}(x - \gamma\nabla\psi(x)) \in \R^n \)

  • p[out] The proximal gradient step, \( p = \hat x - x \in \R^n \)

Returns:

The nonsmooth function evaluated at x̂, \( h(\hat x) \).

index_t eval_inactive_indices_res_lna(real_t γ, crvec x, crvec grad_ψ, rindexvec J) const

[Optional] Function that computes the inactive indices \( \mathcal J(x) \) for the evaluation of the linear Newton approximation of the residual, as in [4].

For example, in the case of box constraints, we have

\[ \mathcal J(x) \defeq \defset{i \in \N_{[0, n-1]}}{\underline x_i \lt x_i - \gamma\nabla_{\!x_i}\psi(x) \lt \overline x_i}. \]

Parameters:
  • γ[in] Step size, \( \gamma \in \R_{>0} \)

  • x[in] Decision variable \( x \in \R^n \)

  • grad_ψ[in] Gradient of the subproblem cost, \( \nabla\psi(x) \in \R^n \)

  • J[out] The indices of the components of \( x \) that are in the index set \( \mathcal J(x) \). In ascending order, at most n.

Returns:

The number of inactive constraints, \( \# \mathcal J(x) \).

Constraint sets

const Box &get_variable_bounds() const

[Optional] Get the rectangular constraint set of the decision variables, \( x \in C \).

const Box &get_general_bounds() const

[Optional] Get the rectangular constraint set of the general constraint function, \( g(x) \in D \).

Functions for second-order solvers

void eval_constraints_jacobian(crvec x, rvec J_values) const

[Optional] Function that evaluates the nonzero values of the Jacobian matrix of the constraints, \( \jac_g(x) \)

Required for second-order solvers only.

Parameters:
  • x[in] Decision variable \( x \in \R^n \)

  • J_values[out] Nonzero values of the Jacobian \( \jac_g(x) \in \R^{m\times n} \)

Sparsity get_constraints_jacobian_sparsity() const

[Optional] Function that returns (a view of) the sparsity pattern of the Jacobian of the constraints.

Required for second-order solvers only.

void eval_grad_gi(crvec x, index_t i, rvec grad_gi) const

[Optional] Function that evaluates the gradient of one specific constraint, \( \nabla g_i(x) \)

Required for second-order solvers only.

Parameters:
  • x[in] Decision variable \( x \in \R^n \)

  • i[in] Which constraint \( 0 \le i \lt m \)

  • grad_gi[out] Gradient of the constraint \( \nabla g_i(x) \in \R^n \)

void eval_lagrangian_hessian_product(crvec x, crvec y, real_t scale, crvec v, rvec Hv) const

[Optional] Function that evaluates the Hessian of the Lagrangian multiplied by a vector, \( \nabla_{xx}^2L(x, y)\,v \)

Required for second-order solvers only.

Parameters:
  • x[in] Decision variable \( x \in \R^n \)

  • y[in] Lagrange multipliers \( y \in \R^m \)

  • scale[in] Scale factor for the cost function.

  • v[in] Vector to multiply by \( v \in \R^n \)

  • Hv[out] Hessian-vector product \( \nabla_{xx}^2 L(x, y)\,v \in \R^{n} \)

void eval_lagrangian_hessian(crvec x, crvec y, real_t scale, rvec H_values) const

[Optional] Function that evaluates the nonzero values of the Hessian of the Lagrangian, \( \nabla_{xx}^2L(x, y) \)

Required for second-order solvers only.

Parameters:
  • x[in] Decision variable \( x \in \R^n \)

  • y[in] Lagrange multipliers \( y \in \R^m \)

  • scale[in] Scale factor for the cost function.

  • H_values[out] Nonzero values of the Hessian \( \nabla_{xx}^2 L(x, y) \in \R^{n\times n} \).

Sparsity get_lagrangian_hessian_sparsity() const

[Optional] Function that returns (a view of) the sparsity pattern of the Hessian of the Lagrangian.

Required for second-order solvers only.

void eval_augmented_lagrangian_hessian_product(crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const

[Optional] Function that evaluates the Hessian of the augmented Lagrangian multiplied by a vector, \( \nabla_{xx}^2L_\Sigma(x, y)\,v \)

Required for second-order solvers only.

Parameters:
  • x[in] Decision variable \( x \in \R^n \)

  • y[in] Lagrange multipliers \( y \in \R^m \)

  • Σ[in] Penalty weights \( \Sigma \)

  • scale[in] Scale factor for the cost function.

  • v[in] Vector to multiply by \( v \in \R^n \)

  • Hv[out] Hessian-vector product \( \nabla_{xx}^2 L_\Sigma(x, y)\,v \in \R^{n} \)

void eval_augmented_lagrangian_hessian(crvec x, crvec y, crvec Σ, real_t scale, rvec H_values) const

[Optional] Function that evaluates the nonzero values of the Hessian of the augmented Lagrangian, \( \nabla_{xx}^2L_\Sigma(x, y) \)

Required for second-order solvers only.

Parameters:
  • x[in] Decision variable \( x \in \R^n \)

  • y[in] Lagrange multipliers \( y \in \R^m \)

  • Σ[in] Penalty weights \( \Sigma \)

  • scale[in] Scale factor for the cost function.

  • H_values[out] Nonzero values of the Hessian \( \nabla_{xx}^2 L_\Sigma(x, y) \in \R^{n\times n} \)

Sparsity get_augmented_lagrangian_hessian_sparsity() const

[Optional] Function that returns (a view of) the sparsity pattern of the Hessian of the augmented Lagrangian.

Required for second-order solvers only.

Combined evaluations

real_t eval_objective_and_gradient(crvec x, rvec grad_fx) const

[Optional] Evaluate both \( f(x) \) and its gradient, \( \nabla f(x) \).

Default implementation:

ProblemVTable::default_eval_objective_and_gradient

real_t eval_objective_and_constraints(crvec x, rvec g) const

[Optional] Evaluate both \( f(x) \) and \( g(x) \).

Default implementation:

ProblemVTable::default_eval_objective_and_constraints

void eval_objective_gradient_and_constraints_gradient_product(crvec x, crvec y, rvec grad_f, rvec grad_gxy) const

[Optional] Evaluate both \( \nabla f(x) \) and \( \nabla g(x)\,y \).

Default implementation:

ProblemVTable::default_eval_objective_gradient_and_constraints_gradient_product

void eval_lagrangian_gradient(crvec x, crvec y, rvec grad_L, rvec work_n) const

[Optional] Evaluate the gradient of the Lagrangian \( \nabla_x L(x, y) = \nabla f(x) + \nabla g(x)\,y \)

Default implementation:

ProblemVTable::default_eval_lagrangian_gradient

Augmented Lagrangian

real_t eval_augmented_lagrangian(crvec x, crvec y, crvec Σ, rvec ŷ) const

[Optional] Calculate both ψ(x) and the vector ŷ that can later be used to compute ∇ψ.

\[ \psi(x) = f(x) + \tfrac{1}{2} \text{dist}_\Sigma^2\left(g(x) + \Sigma^{-1}y,\;D\right) \]
\[ \hat y = \Sigma\, \left(g(x) + \Sigma^{-1}y - \Pi_D\left(g(x) + \Sigma^{-1}y\right)\right) \]
Default implementation:

ProblemVTable::default_eval_augmented_lagrangian

Parameters:
  • x – [in] Decision variable \( x \)

  • y – [in] Lagrange multipliers \( y \)

  • Σ – [in] Penalty weights \( \Sigma \)

  • ŷ – [out] \( \hat y \)

void eval_augmented_lagrangian_gradient(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const

[Optional] Calculate the gradient ∇ψ(x).

\[ \nabla \psi(x) = \nabla f(x) + \nabla g(x)\,\hat y(x) \]
Default implementation:

ProblemVTable::default_eval_augmented_lagrangian_gradient

Parameters:
  • x – [in] Decision variable \( x \)

  • y – [in] Lagrange multipliers \( y \)

  • Σ – [in] Penalty weights \( \Sigma \)

  • grad_ψ – [out] \( \nabla \psi(x) \)

  • work_n – Dimension \( n \)

  • work_m – Dimension \( m \)

real_t eval_augmented_lagrangian_and_gradient(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const

[Optional] Calculate both ψ(x) and its gradient ∇ψ(x).

\[ \psi(x) = f(x) + \tfrac{1}{2} \text{dist}_\Sigma^2\left(g(x) + \Sigma^{-1}y,\;D\right) \]
\[ \nabla \psi(x) = \nabla f(x) + \nabla g(x)\,\hat y(x) \]
Default implementation:

ProblemVTable::default_eval_augmented_lagrangian_and_gradient

Parameters:
  • x – [in] Decision variable \( x \)

  • y – [in] Lagrange multipliers \( y \)

  • Σ – [in] Penalty weights \( \Sigma \)

  • grad_ψ – [out] \( \nabla \psi(x) \)

  • work_n – Dimension \( n \)

  • work_m – Dimension \( m \)

Checks

void check() const

[Optional] Check that the problem formulation is well-defined, the dimensions match, etc.

Throws an exception if this is not the case.

Metadata

std::string get_name() const

[Optional] Get a descriptive name for the problem.

Querying specialized implementations

inline bool provides_eval_inactive_indices_res_lna() const

Returns true if the problem provides an implementation of eval_inactive_indices_res_lna.

inline bool provides_eval_constraints_jacobian() const

Returns true if the problem provides an implementation of eval_constraints_jacobian.

inline bool provides_get_constraints_jacobian_sparsity() const

Returns true if the problem provides an implementation of get_constraints_jacobian_sparsity.

inline bool provides_eval_grad_gi() const

Returns true if the problem provides an implementation of eval_grad_gi.

inline bool provides_eval_lagrangian_hessian_product() const

Returns true if the problem provides an implementation of eval_lagrangian_hessian_product.

inline bool provides_eval_lagrangian_hessian() const

Returns true if the problem provides an implementation of eval_lagrangian_hessian.

inline bool provides_get_lagrangian_hessian_sparsity() const

Returns true if the problem provides an implementation of get_lagrangian_hessian_sparsity.

inline bool provides_eval_augmented_lagrangian_hessian_product() const

Returns true if the problem provides an implementation of eval_augmented_lagrangian_hessian_product.

inline bool provides_eval_augmented_lagrangian_hessian() const

Returns true if the problem provides an implementation of eval_augmented_lagrangian_hessian.

inline bool provides_get_augmented_lagrangian_hessian_sparsity() const

Returns true if the problem provides an implementation of get_augmented_lagrangian_hessian_sparsity.

inline bool provides_eval_objective_and_gradient() const

Returns true if the problem provides a specialized implementation of eval_objective_and_gradient, false if it uses the default implementation.

inline bool provides_eval_objective_and_constraints() const

Returns true if the problem provides a specialized implementation of eval_objective_and_constraints, false if it uses the default implementation.

inline bool provides_eval_objective_gradient_and_constraints_gradient_product() const

Returns true if the problem provides a specialized implementation of eval_objective_gradient_and_constraints_gradient_product, false if it uses the default implementation.

inline bool provides_eval_lagrangian_gradient() const

Returns true if the problem provides a specialized implementation of eval_lagrangian_gradient, false if it uses the default implementation.

inline bool provides_eval_augmented_lagrangian() const

Returns true if the problem provides a specialized implementation of eval_augmented_lagrangian, false if it uses the default implementation.

inline bool provides_eval_augmented_lagrangian_gradient() const

Returns true if the problem provides a specialized implementation of eval_augmented_lagrangian_gradient, false if it uses the default implementation.

inline bool provides_eval_augmented_lagrangian_and_gradient() const

Returns true if the problem provides a specialized implementation of eval_augmented_lagrangian_and_gradient, false if it uses the default implementation.

inline bool provides_get_variable_bounds() const

Returns true if the problem provides an implementation of get_variable_bounds.

inline bool provides_get_general_bounds() const

Returns true if the problem provides an implementation of get_general_bounds.

inline bool provides_check() const

Returns true if the problem provides an implementation of check.

inline bool provides_get_name() const

Returns true if the problem provides an implementation of get_name.

Querying available functions

inline bool supports_eval_augmented_lagrangian_hessian_product() const

Returns true if eval_augmented_lagrangian_hessian_product can be called.

inline bool supports_eval_augmented_lagrangian_hessian() const

Returns true if eval_augmented_lagrangian_hessian can be called.

Helpers

real_t calc_ŷ_dᵀŷ(rvec g_ŷ, crvec y, crvec Σ) const

Given g(x), compute the intermediate results ŷ and dᵀŷ that can later be used to compute ψ(x) and ∇ψ(x).

Computes the result using the following algorithm:

\[\begin{split} \begin{aligned} \zeta &= g(x) + \Sigma^{-1} y \\[] d &= \zeta - \Pi_D(\zeta) = \operatorname{eval\_proj\_diff\_g}(\zeta, \zeta) \\[] \hat y &= \Sigma d \\[] \end{aligned} \end{split}\]

See also

page_math

Parameters:
  • g_ŷ[inout] Input \( g(x) \), outputs \( \hat y \)

  • y[in] Lagrange multipliers \( y \)

  • Σ[in] Penalty weights \( \Sigma \)

Returns:

The inner product \( d^\top \hat y \)

Public Types

using Box = alpaqa::Box<config_t>
using VTable = ProblemVTable<config_t>
using allocator_type = Allocator
using TypeErased = guanaqo::TypeErased<VTable, allocator_type>

Public Static Functions

template<class T, class ...Args>
static inline TypeErasedProblem make(Args&&... args)
template<Config Conf>
class UnconstrProblem
#include <alpaqa/problem/unconstr-problem.hpp>

Implements common problem functions for minimization problems without constraints.

Meant to be used as a base class for custom problem implementations.

Public Functions

inline UnconstrProblem(length_t num_variables)
Parameters:

num_variables – Number of decision variables

inline void resize(length_t num_variables)

Change the number of decision variables.

UnconstrProblem(const UnconstrProblem&) = default
UnconstrProblem &operator=(const UnconstrProblem&) = default
UnconstrProblem(UnconstrProblem&&) noexcept = default
UnconstrProblem &operator=(UnconstrProblem&&) noexcept = default
inline length_t get_num_variables() const

Number of decision variables \( n \), num_variables.

inline length_t get_num_constraints() const

Number of constraints (always zero)

inline void eval_constraints(crvec, rvec) const

No-op, no constraints.

See also

eval_constraints

inline void eval_constraints_gradient_product(crvec, crvec, rvec grad) const

Constraint gradient is always zero.

inline void eval_constraints_jacobian(crvec, rvec) const

Constraint Jacobian is always empty.

inline void eval_grad_gi(crvec, index_t, rvec grad_gi) const

Constraint gradient is always zero.

See also

eval_grad_gi

inline real_t eval_proximal_gradient_step(real_t γ, crvec x, crvec grad_ψ, rvec x_hat, rvec p) const

No proximal mapping, just a forward (gradient) step.

inline void eval_projecting_difference_constraints(crvec, rvec) const

inline void eval_projection_multipliers(rvec, real_t) const

inline index_t eval_inactive_indices_res_lna(real_t, crvec, crvec, rindexvec J) const

inline std::string get_name() const

See also

get_name

Public Members

length_t num_variables

Number of decision variables, dimension of x.

template<Config Conf = DefaultConfig>
struct WolfeParams
#include <alpaqa/inner/wolfe.hpp>

Tuning parameters for the unconstrained solver with Wolfe line search.

Public Members

unsigned max_iter = 100

Maximum number of inner iterations.

std::chrono::nanoseconds max_time = std::chrono::minutes(5)

Maximum duration.

real_t min_linesearch_coefficient = real_t(1. / 256)

Minimum weight factor between Newton step and projected gradient step.

bool force_linesearch = false

Ignore the line search condition and always accept the accelerated step.

(For testing purposes only).

real_t decrease_factor = real_t(1e-4)
real_t curvature_factor = NaN<config_t>
PANOCStopCrit stop_crit = PANOCStopCrit::ApproxKKT

What stopping criterion to use.

unsigned max_no_progress = 10

Maximum number of iterations without any progress before giving up.

unsigned print_interval = 0

When to print progress.

If set to zero, nothing will be printed. If set to N != 0, progress is printed every N iterations.

int print_precision = std::numeric_limits<real_t>::max_digits10 / 2

The precision of the floating point values printed by the solver.

real_t linesearch_tolerance_factor = 10 * std::numeric_limits<real_t>::epsilon()

Tolerance factor used in the line search.

Its goal is to account for numerical errors in the function and gradient evaluations. If you notice that accelerated steps are rejected (τ = 0) when getting closer to the solution, you may want to increase this factor.

template<Config Conf = DefaultConfig>
struct WolfeProgressInfo
#include <alpaqa/inner/wolfe.hpp>

Iterate information for the unconstrained solver with Wolfe line search.

Public Members

unsigned k
SolverStatus status
crvec x
real_t ψ
crvec grad_ψ
crvec q
real_t τ
real_t ε
crvec Σ
crvec y
unsigned outer_iter
const TypeErasedProblem<config_t> *problem
const WolfeParams<config_t> *params
template<class DirectionT>
class WolfeSolver
#include <alpaqa/inner/wolfe.hpp>

Unconstrained solver with Wolfe line search.

Public Types

using Problem = TypeErasedProblem<config_t>
using Params = WolfeParams<config_t>
using Direction = DirectionT
using Stats = WolfeStats<config_t>
using ProgressInfo = WolfeProgressInfo<config_t>
using SolveOptions = InnerSolveOptions<config_t>

Public Functions

inline WolfeSolver(const Params &params)
inline WolfeSolver(const Params &params, Direction &&direction)
inline WolfeSolver(const Params &params, const Direction &direction)
Stats operator()(const Problem &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec err_z)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec e)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec x)
inline WolfeSolver &set_progress_callback(std::function<void(const ProgressInfo&)> cb)

Specify a callable that is invoked with some intermediate results on each iteration of the algorithm.

See also

ProgressInfo

std::string get_name() const
inline void stop()
inline const Params &get_params() const

Public Members

Direction direction
std::ostream *os = &std::cout
template<Config Conf = DefaultConfig>
struct WolfeStats
#include <alpaqa/inner/wolfe.hpp>

Statistics for the unconstrained solver with Wolfe line search.

Public Members

SolverStatus status = SolverStatus::Busy
real_t ε = inf<config_t>
std::chrono::nanoseconds elapsed_time = {}
std::chrono::nanoseconds time_progress_callback = {}
unsigned iterations = 0
unsigned linesearch_failures = 0
unsigned linesearch_backtracks = 0
unsigned direction_failures = 0
unsigned direction_update_rejected = 0
unsigned τ_1_accepted = 0
unsigned count_τ = 0
real_t sum_τ = 0
real_t final_ψ = 0
template<Config Conf = DefaultConfig>
struct ZeroFPRParams
#include <alpaqa/inner/zerofpr.hpp>

Tuning parameters for the ZeroFPR algorithm.

Public Members

LipschitzEstimateParams<config_t> Lipschitz = {}

Parameters related to the Lipschitz constant estimate and step size.

unsigned max_iter = 100

Maximum number of inner ZeroFPR iterations.

std::chrono::nanoseconds max_time = std::chrono::minutes(5)

Maximum duration.

real_t min_linesearch_coefficient = real_t(1. / 256)

Minimum weight factor between Newton step and projected gradient step.

bool force_linesearch = false

Ignore the line search condition and always accept the accelerated step.

(For testing purposes only).

real_t linesearch_strictness_factor = real_t(0.95)

Parameter β used in the line search (see Algorithm 2 in [2]).

\( 0 < \beta < 1 \)

real_t L_min = real_t(1e-5)

Minimum Lipschitz constant estimate.

real_t L_max = real_t(1e20)

Maximum Lipschitz constant estimate.

PANOCStopCrit stop_crit = PANOCStopCrit::ApproxKKT

What stopping criterion to use.

unsigned max_no_progress = 10

Maximum number of iterations without any progress before giving up.

unsigned print_interval = 0

When to print progress.

If set to zero, nothing will be printed. If set to N != 0, progress is printed every N iterations.

int print_precision = std::numeric_limits<real_t>::max_digits10 / 2

The precision of the floating point values printed by the solver.

real_t quadratic_upperbound_tolerance_factor = 10 * std::numeric_limits<real_t>::epsilon()

Tolerance factor used in the quadratic upper bound condition that determines the step size.

Its goal is to account for numerical errors in the function and gradient evaluations. If you notice that the step size γ becomes very small, you may want to increase this factor.

real_t linesearch_tolerance_factor = 10 * std::numeric_limits<real_t>::epsilon()

Tolerance factor used in the line search.

Its goal is to account for numerical errors in the function and gradient evaluations. If you notice that accelerated steps are rejected (τ = 0) when getting closer to the solution, you may want to increase this factor.

bool update_direction_in_candidate = false

Use the candidate point rather than the accepted point to update the quasi-Newton direction.

bool update_direction_in_accel = false

Use the point generated by the accelerator rather than the accepted point to update the quasi-Newton direction.

bool recompute_last_prox_step_after_stepsize_change = false

If the step size changes, the direction buffer is flushed.

The current step will still be used to update the direction, but may still use the old step size. If set to true, the current step will be recomputed with the new step size as well, to match the step in the candidate iterate.

bool update_direction_from_prox_step = false

Update the direction between current forward-backward point and the candidate iterate instead of between the current iterate and the candidate iterate.

template<Config Conf = DefaultConfig>
struct ZeroFPRProgressInfo
#include <alpaqa/inner/zerofpr.hpp>

Public Members

unsigned k
SolverStatus status
crvec x
crvec p
real_t norm_sq_p
crvec x_hat
crvec ŷ
real_t φγ
real_t ψ
crvec grad_ψ
real_t ψ_hat
crvec grad_ψ_hat
crvec q
real_t L
real_t γ
real_t τ
real_t ε
crvec Σ
crvec y
unsigned outer_iter
const TypeErasedProblem<config_t> *problem
const ZeroFPRParams<config_t> *params
template<class DirectionT>
class ZeroFPRSolver
#include <alpaqa/inner/zerofpr.hpp>

ZeroFPR solver for ALM.

Public Types

using Problem = TypeErasedProblem<config_t>
using Params = ZeroFPRParams<config_t>
using Direction = DirectionT
using Stats = ZeroFPRStats<config_t>
using ProgressInfo = ZeroFPRProgressInfo<config_t>
using SolveOptions = InnerSolveOptions<config_t>

Public Functions

inline ZeroFPRSolver(const Params &params)
inline ZeroFPRSolver(const Params &params, Direction &&direction)
inline ZeroFPRSolver(const Params &params, const Direction &direction)
Stats operator()(const Problem &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec err_z)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec e)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec x)
inline ZeroFPRSolver &set_progress_callback(std::function<void(const ProgressInfo&)> cb)

Specify a callable that is invoked with some intermediate results on each iteration of the algorithm.

See also

ProgressInfo

std::string get_name() const
inline void stop()
inline const Params &get_params() const

Public Members

Direction direction
std::ostream *os = &std::cout
template<Config Conf = DefaultConfig>
struct ZeroFPRStats
#include <alpaqa/inner/zerofpr.hpp>

Public Members

SolverStatus status = SolverStatus::Busy
real_t ε = inf<config_t>
std::chrono::nanoseconds elapsed_time = {}
std::chrono::nanoseconds time_progress_callback = {}
unsigned iterations = 0
unsigned linesearch_failures = 0
unsigned linesearch_backtracks = 0
unsigned stepsize_backtracks = 0
unsigned direction_failures = 0
unsigned direction_update_rejected = 0
unsigned τ_1_accepted = 0
unsigned count_τ = 0
real_t sum_τ = 0
real_t final_γ = 0
real_t final_ψ = 0
real_t final_h = 0
real_t final_φγ = 0
namespace casadi

Typedefs

using fname_incref = ExternalFunction<"_incref", void(void)>
using fname_decref = ExternalFunction<"_decref", void(void)>
using fname_n_in = ExternalFunction<"_n_in", casadi_int(void)>
using fname_n_out = ExternalFunction<"_n_out", casadi_int(void)>
using fname_name_in = ExternalFunction<"_name_in", const char*(casadi_int ind)>
using fname_name_out = ExternalFunction<"_name_out", const char*(casadi_int ind)>
using fname_sparsity_in = ExternalFunction<"_sparsity_in", const casadi_int*(casadi_int ind)>
using fname_sparsity_out = ExternalFunction<"_sparsity_out", const casadi_int*(casadi_int ind)>
using fname_alloc_mem = ExternalFunction<"_alloc_mem", int(void)>
using fname_init_mem = ExternalFunction<"_init_mem", int(int mem)>
using fname_free_mem = ExternalFunction<"_free_mem", void(int mem)>
using fname_work = ExternalFunction<"_work", int(casadi_int *sz_arg, casadi_int *sz_res, casadi_int *sz_iw, casadi_int *sz_w)>
using fname = ExternalFunction<"", int(const casadi_real **arg, casadi_real **res, casadi_int *iw, casadi_real *w, int mem)>

Functions

Function external(const std::string &name, const std::string &bin_name, DynamicLoadFlags dl_flags)

Load the given CasADi function from the given DLL/SO file.

Variables

static char no_handle
template<Name Nm, class Sgn>
struct ExternalFunction
#include <alpaqa/casadi/casadi-types.hpp>

Reference to CasADi function.

Public Types

using signature_t = Sgn

Public Static Functions

static signature_t *load(void *handle, std::string fname)

Public Static Attributes

static Name name = Nm
class Function
#include <alpaqa/casadi/casadi-external-function.hpp>

Class that loads and calls pre-compiled CasADi functions in a DLL/SO file.

Designed to match (part of) the casadi::Function API.

Public Functions

Function()
Function(std::shared_ptr<void> so_handle, const std::string &func_name)
Function(const Functions &functions)
Function(const Function&)
Function(Function&&) noexcept
~Function()
casadi_int n_in() const
casadi_int n_out() const
std::pair<casadi_int, casadi_int> size_in(casadi_int) const
std::pair<casadi_int, casadi_int> size_out(casadi_int) const
casadi_int size1_in(casadi_int) const
casadi_int size1_out(casadi_int) const
casadi_int size2_in(casadi_int) const
casadi_int size2_out(casadi_int) const
Sparsity sparsity_in(casadi_int) const
Sparsity sparsity_out(casadi_int) const
inline void operator()(std::span<const double*const> arg, std::span<double*const> res)
struct Functions
#include <alpaqa/casadi/casadi-external-function.hpp>

Public Members

fname_incref::signature_t *incref = nullptr
fname_decref::signature_t *decref = nullptr
fname_n_in::signature_t *n_in = nullptr
fname_n_out::signature_t *n_out = nullptr
fname_name_in::signature_t *name_in = nullptr
fname_name_out::signature_t *name_out = nullptr
fname_sparsity_in::signature_t *sparsity_in = nullptr
fname_sparsity_out::signature_t *sparsity_out = nullptr
fname_alloc_mem::signature_t *alloc_mem = nullptr
fname_init_mem::signature_t *init_mem = nullptr
fname_free_mem::signature_t *free_mem = nullptr
fname_work::signature_t *work = nullptr
fname::signature_t *call = nullptr
class Sparsity
#include <alpaqa/casadi/casadi-external-function.hpp>

Public Functions

inline std::pair<casadi_int, casadi_int> size() const
inline casadi_int size1() const
inline casadi_int size2() const
inline casadi_int nnz() const
inline bool is_dense() const
inline const casadi_int *row() const
inline const casadi_int *colind() const
template<size_t N>
struct Name
#include <alpaqa/casadi/casadi-types.hpp>

Compile-time string for CasADi function names.

Public Functions

inline constexpr Name(const char (&str)[N])

Public Members

std::array<char, N> value
namespace casadi_loader

Typedefs

using dim = std::pair<casadi_int, casadi_int>

Functions

CasADiFunctions deserialize_problem(const SerializedCasADiFunctions &functions)

Convert the map of strings to a map of CasADi functions.

void complete_problem(CasADiFunctions &functions)

Complete the given problem that contains only functions f and g, adding the necessary functions and gradients so that it can be used with CasADiProblem.

template<class Loader, class F>
auto wrap_load(Loader &&loader, const char *name, F f)
template<class T, class Loader, class ...Args>
auto wrapped_load(Loader &&loader, const char *name, Args&&... args)
template<class T, class Loader, class ...Args>
std::optional<T> try_load(Loader &&loader, const char *name, Args&&... args)
inline auto dims(auto... a)
template<class F>
auto wrap(const char *name, F f)
template<Config>
struct CasADiControlFunctionsWithParam
template<Config Conf, size_t N_in, size_t N_out>
class CasADiFunctionEvaluator
#include <alpaqa/casadi/CasADiFunctionWrapper.hpp>

Class for evaluating CasADi functions, allocating the necessary workspace storage in advance for allocation-free evaluations.

Public Types

using casadi_dim = std::pair<casadi_int, casadi_int>

Public Functions

inline CasADiFunctionEvaluator(casadi::Function &&f)
Throws:

invalid_argument_dimensions

inline CasADiFunctionEvaluator(casadi::Function &&f, const std::array<casadi_dim, N_in> &dim_in, const std::array<casadi_dim, N_out> &dim_out)
Throws:

invalid_argument_dimensions

inline void validate_dimensions(const std::array<casadi_dim, N_in> &dim_in = {}, const std::array<casadi_dim, N_out> &dim_out = {})
Throws:

invalid_argument_dimensions

inline void operator()(const double *const (&in)[N_in], double *const (&out)[N_out])

Public Members

casadi::Function fun

Public Static Functions

static inline void validate_num_args(const casadi::Function &fun)
Throws:

invalid_argument_dimensions

static inline void validate_dimensions(const casadi::Function &fun, const std::array<casadi_dim, N_in> &dim_in = {}, const std::array<casadi_dim, N_out> &dim_out = {})
Throws:

invalid_argument_dimensions

template<Config>
struct CasADiFunctionsWithParam
struct invalid_argument_dimensions : public invalid_argument
#include <alpaqa/casadi/CasADiFunctionWrapper.hpp>
namespace cutest

Typedefs

using csetup = Function<"cutest_cint_csetup_", void(integer *status, const integer *funit, const integer *iout, const integer *io_buffer, integer *n, integer *m, doublereal *x, doublereal *bl, doublereal *bu, doublereal *v, doublereal *cl, doublereal *cu, logical *equatn, logical *linear, const integer *e_order, const integer *l_order, const integer *v_order)>
using cterminate = Function<"cutest_cterminate_", void(integer *status)>
using cdimen = Function<"cutest_cdimen_", void(integer *status, const integer *funit, integer *n, integer *m)>
using cdimsj = Function<"cutest_cdimsj_", void(integer *status, integer *nnzj)>
using cdimsh = Function<"cutest_cdimsh_", void(integer *status, integer *nnzh)>
using probname = Function<"cutest_probname_", void(integer *status, char *pname)>
using creport = Function<"cutest_creport_", void(integer *status, doublereal *calls, doublereal *time)>
using ureport = Function<"cutest_ureport_", void(integer *status, doublereal *calls, doublereal *time)>
using cfn = Function<"cutest_cfn_", void(integer *status, const integer *n, const integer *m, const doublereal *x, doublereal *f, doublereal *c)>
using cofg = Function<"cutest_cint_cofg_", void(integer *status, const integer *n, const doublereal *x, doublereal *f, doublereal *g, const logical *grad)>
using ccfg = Function<"cutest_cint_ccfg_", void(integer *status, const integer *n, const integer *m, const doublereal *x, doublereal *c, const logical *jtrans, const integer *lcjac1, const integer *lcjac2, doublereal *cjac, const logical *grad)>
using clfg = Function<"cutest_cint_clfg_", void(integer *status, const integer *n, const integer *m, const doublereal *x, const doublereal *y, doublereal *f, doublereal *g, const logical *grad)>
using ccfsg = Function<"cutest_cint_ccfsg_", void(integer *status, const integer *n, const integer *m, const doublereal *x, doublereal *c, integer *nnzj, const integer *lcjac, doublereal *cjac, integer *indvar, integer *indfun, const logical *grad)>
using ccifg = Function<"cutest_cint_ccifg_", void(integer *status, const integer *n, const integer *icon, const doublereal *x, doublereal *ci, doublereal *gci, const logical *grad)>
using cdh = Function<"cutest_cdh_", void(integer *status, const integer *n, const integer *m, const doublereal *x, const doublereal *y, const integer *lh1, doublereal *h)>
using cshp = Function<"cutest_cshp_", void(integer *status, const integer *n, integer *nnzh, const integer *lh, integer *irnh, integer *icnh)>
using csh = Function<"cutest_csh_", void(integer *status, const integer *n, const integer *m, const doublereal *x, const doublereal *y, integer *nnzh, const integer *lh, doublereal *h, integer *irnh, integer *icnh)>
using cigr = Function<"cutest_cigr_", void(integer *status, const integer *n, const integer *iprob, const doublereal *x, doublereal *g)>
using chprod = Function<"cutest_chprod_", void(integer *status, const integer *n, const integer *m, const logical *goth, const doublereal *x, const doublereal *y, doublereal *p, doublereal *q)>
using cjprod = Function<"cutest_cjprod_", void(integer *status, const integer *n, const integer *m, const logical *gotj, const logical *jtrans, const doublereal *x, const doublereal *p, const integer *lp, doublereal *r, const integer *lr)>
using csjp = Function<"cutest_csjp_", void(integer *status, integer *nnzj, const integer *lj, integer *J_var, integer *J_con)>
using fortran_open = Function<"fortran_open_", void(const integer *funit, const char *fname, integer *ierr)>
using fortran_close = Function<"fortran_close_", void(const integer *funit, integer *ierr)>
using integer = int
using doublereal = double
using logical = int

Enums

enum class Status

Values:

enumerator Success

Successful call.

enumerator AllocErr

Array allocation/deallocation error.

enumerator BoundErr

Array bound error.

enumerator EvalErr

Evaluation error.

Functions

inline const char *enum_name(Status s)

Variables

logical True = 1
logical False = 0
doublereal inf = 1e20
size_t fstring_len = 10
template<Name Nm, class Sgn>
struct Function
#include </home/runner/work/alpaqa/alpaqa/src/interop/cutest/src/cutest-types.hpp>

Reference to CUTEst function.

Public Types

using signature_t = Sgn

Public Static Functions

static signature_t *load(void *handle)

Public Static Attributes

static Name name = Nm
struct function_call_error : public runtime_error
#include <alpaqa/cutest/cutest-errors.hpp>

Public Functions

inline function_call_error(std::string message, Status status)

Public Members

Status status
template<size_t N>
struct Name
#include </home/runner/work/alpaqa/alpaqa/src/interop/cutest/src/cutest-types.hpp>

Compile-time string for CUTEst function names.

Public Functions

inline constexpr Name(const char (&str)[N])

Public Members

std::array<char, N> value
namespace detail

Functions

template<Config Conf>
void assign_interleave_xu(const OCPVariables<Conf> &dim, crvec<Conf> u, rvec<Conf> storage)
template<Config Conf>
void assign_interleave_xu(const OCPVariables<Conf> &dim, crvec<Conf> x, crvec<Conf> u, rvec<Conf> storage)
template<Config Conf>
void assign_extract_u(const OCPVariables<Conf> &dim, crvec<Conf> storage, rvec<Conf> u)
template<Config Conf>
void assign_extract_x(const OCPVariables<Conf> &dim, crvec<Conf> storage, rvec<Conf> x)
template<Config Conf>
vec<Conf> extract_u(const TypeErasedControlProblem<Conf> &problem, crvec<Conf> xu)
template<Config Conf>
vec<Conf> extract_x(const TypeErasedControlProblem<Conf> &problem, crvec<Conf> xu)
template<class Signature>
function_wrapper_t(std::function<Signature>) -> function_wrapper_t<Signature>
template<auto Member, class Class, class Ret, class ...Args>
static auto member_caller(Ret (Class::*)(Args...))

Overload for non-const-qualified member functions.

Overload for const-qualified member functions.

See also

member_caller

template<auto Member, class Class, class Ret>
static auto member_caller(Ret Class::*)

Overload for member variables.

See also

member_caller

Variables

template<Eigen::Index R>
auto to_std_extent = R == Eigen::Dynamic ? std::dynamic_extent : static_cast<size_t>(R)
template<size_t E>
auto to_eigen_extent = E == std::dynamic_extent ? Eigen::Dynamic : static_cast<Eigen::Index>(E)
std::atomic<void*> solver_to_stop
template<Config Conf>
struct ALMHelpers
template<class Signature>
struct function_wrapper_t
#include <alpaqa/dl/dl-problem.h>

Custom type for which we can export the RTTI to support std::any across shared library boundaries when using libc++.

template<Config Conf>
struct IndexSet
#include <alpaqa/util/index-set.hpp>

Public Functions

inline IndexSet(length_t N, length_t n)
inline auto sizes()
inline auto sizes() const
inline auto indices()
inline auto indices() const
inline crindexvec indices(index_t i) const
inline crindexvec compl_indices(index_t i) const
template<class F>
inline void update(const F &condition)

Public Members

length_t N
length_t n
indexvec storage

Public Static Functions

static inline void compute_complement(std::span<const index_t> in, std::span<index_t> out)
static inline void compute_complement(std::span<const index_t> in, std::span<index_t> out, length_t n)
static inline void compute_complement(crindexvec in, rindexvec out, length_t n)
template<Config Conf>
struct PANOCHelpers
namespace dl
class DLControlProblem
#include <alpaqa/dl/dl-problem.hpp>

Class that loads an optimal control problem using dlopen.

The shared library should export a C function with the name function_name that accepts a void pointer with user data, and returns a struct of type alpaqa_control_problem_register_t that contains all data to represent the problem, as well as function pointers for all required operations.

Note

Copies are shallow, they all share the same problem instance, take that into account when using multiple threads.

Public Types

using Box = alpaqa::Box<config_t>
using instance_t = ExtraFuncs::instance_t

Public Functions

DLControlProblem(const std::filesystem::path &so_filename, const std::string &function_name = "register_alpaqa_control_problem", alpaqa_register_arg_t user_param = {}, DynamicLoadFlags dl_flags = {})

Load a problem from a shared library.

Parameters:
  • so_filename – Filename of the shared library to load.

  • function_name – Name of the problem registration function. Should have signature alpaqa_control_problem_register_t(alpaqa_register_arg_t user_param).

  • user_param – Pointer to custom user data to pass to the registration function.

  • dl_flags – Flags passed to dlopen when loading the problem.

inline length_t get_N() const
inline length_t get_nx() const
inline length_t get_nu() const
inline length_t get_nh() const
inline length_t get_nh_N() const
inline length_t get_nc() const
inline length_t get_nc_N() const
inline void check() const
void get_U(Box &U) const
void get_D(Box &D) const
void get_D_N(Box &D) const
void get_x_init(rvec x_init) const
void eval_f(index_t timestep, crvec x, crvec u, rvec fxu) const
void eval_jac_f(index_t timestep, crvec x, crvec u, rmat J_fxu) const
void eval_grad_f_prod(index_t timestep, crvec x, crvec u, crvec p, rvec grad_fxu_p) const
void eval_h(index_t timestep, crvec x, crvec u, rvec h) const
void eval_h_N(crvec x, rvec h) const
real_t eval_l(index_t timestep, crvec h) const
real_t eval_l_N(crvec h) const
void eval_qr(index_t timestep, crvec xu, crvec h, rvec qr) const
void eval_q_N(crvec x, crvec h, rvec q) const
void eval_add_Q(index_t timestep, crvec xu, crvec h, rmat Q) const
void eval_add_Q_N(crvec x, crvec h, rmat Q) const
void eval_add_R_masked(index_t timestep, crvec xu, crvec h, crindexvec mask, rmat R, rvec work) const
void eval_add_S_masked(index_t timestep, crvec xu, crvec h, crindexvec mask, rmat S, rvec work) const
void eval_add_R_prod_masked(index_t timestep, crvec xu, crvec h, crindexvec mask_J, crindexvec mask_K, crvec v, rvec out, rvec work) const
void eval_add_S_prod_masked(index_t timestep, crvec xu, crvec h, crindexvec mask_K, crvec v, rvec out, rvec work) const
length_t get_R_work_size() const
length_t get_S_work_size() const
void eval_constr(index_t timestep, crvec x, rvec c) const
void eval_constr_N(crvec x, rvec c) const
void eval_grad_constr_prod(index_t timestep, crvec x, crvec p, rvec grad_cx_p) const
void eval_grad_constr_prod_N(crvec x, crvec p, rvec grad_cx_p) const
void eval_add_gn_hess_constr(index_t timestep, crvec x, crvec M, rmat out) const
void eval_add_gn_hess_constr_N(crvec x, crvec M, rmat out) const
bool provides_get_D() const
bool provides_get_D_N() const
bool provides_eval_add_Q_N() const
bool provides_eval_add_R_prod_masked() const
bool provides_eval_add_S_prod_masked() const
bool provides_get_R_work_size() const
bool provides_get_S_work_size() const
bool provides_eval_constr() const
bool provides_eval_constr_N() const
bool provides_eval_grad_constr_prod() const
bool provides_eval_grad_constr_prod_N() const
bool provides_eval_add_gn_hess_constr() const
bool provides_eval_add_gn_hess_constr_N() const
template<class Signature, class ...Args>
inline decltype(auto) call_extra_func(const std::string &name, Args&&... args) const
template<class Signature, class ...Args>
inline decltype(auto) call_extra_func(const std::string &name, Args&&... args)
class DLProblem : public BoxConstrProblem<DefaultConfig>
#include <alpaqa/dl/dl-problem.hpp>

Class that loads a problem using dlopen.

The shared library should export a C function with the name function_name that accepts a void pointer with user data, and returns a struct of type alpaqa_problem_register_t that contains all data to represent the problem, as well as function pointers for all required operations. See C++/DLProblem/main.cpp and problems/sparse-logistic-regression.cpp for examples.

See also

alpaqa_problem_functions_t

See also

alpaqa_problem_register_t

Note

Copies are shallow, they all share the same problem instance, take that into account when using multiple threads.

Public Types

using instance_t = ExtraFuncs::instance_t

Public Functions

DLProblem(const std::filesystem::path &so_filename, const std::string &function_name = "register_alpaqa_problem", alpaqa_register_arg_t user_param = {}, DynamicLoadFlags dl_flags = {})

Load a problem from a shared library.

Parameters:
  • so_filename – Filename of the shared library to load.

  • function_name – Name of the problem registration function. Should have signature alpaqa_problem_register_t(alpaqa_register_arg_t user_param).

  • user_param – Pointer to custom user data to pass to the registration function.

  • dl_flags – Flags passed to dlopen when loading the problem.

DLProblem(const std::filesystem::path &so_filename, const std::string &function_name, std::any &user_param, DynamicLoadFlags dl_flags = {})

Load a problem from a shared library.

Parameters:
  • so_filename – Filename of the shared library to load.

  • function_name – Name of the problem registration function. Should have signature alpaqa_problem_register_t(alpaqa_register_arg_t user_param).

  • user_param – Custom user data to pass to the registration function.

  • dl_flags – Flags passed to dlopen when loading the problem.

DLProblem(const std::filesystem::path &so_filename, const std::string &function_name, std::span<std::string_view> user_param, DynamicLoadFlags dl_flags = {})

Load a problem from a shared library.

Parameters:
  • so_filename – Filename of the shared library to load.

  • function_name – Name of the problem registration function. Should have signature alpaqa_problem_register_t(alpaqa_register_arg_t user_param).

  • user_param – Custom string arguments to pass to the registration function.

  • dl_flags – Flags passed to dlopen when loading the problem.

void eval_projecting_difference_constraints(crvec z, rvec e) const
void eval_projection_multipliers(rvec y, real_t M) const
real_t eval_proximal_gradient_step(real_t γ, crvec x, crvec grad_ψ, rvec x_hat, rvec p) const
index_t eval_inactive_indices_res_lna(real_t γ, crvec x, crvec grad_ψ, rindexvec J) const
real_t eval_objective(crvec x) const
void eval_objective_gradient(crvec x, rvec grad_fx) const
void eval_constraints(crvec x, rvec gx) const
void eval_constraints_gradient_product(crvec x, crvec y, rvec grad_gxy) const
void eval_constraints_jacobian(crvec x, rvec J_values) const
Sparsity get_constraints_jacobian_sparsity() const
void eval_grad_gi(crvec x, index_t i, rvec grad_gi) const
void eval_lagrangian_hessian_product(crvec x, crvec y, real_t scale, crvec v, rvec Hv) const
void eval_lagrangian_hessian(crvec x, crvec y, real_t scale, rvec H_values) const
Sparsity get_lagrangian_hessian_sparsity() const
void eval_augmented_lagrangian_hessian_product(crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
void eval_augmented_lagrangian_hessian(crvec x, crvec y, crvec Σ, real_t scale, rvec H_values) const
Sparsity get_augmented_lagrangian_hessian_sparsity() const
real_t eval_objective_and_gradient(crvec x, rvec grad_fx) const
real_t eval_objective_and_constraints(crvec x, rvec g) const
void eval_objective_gradient_and_constraints_gradient_product(crvec x, crvec y, rvec grad_f, rvec grad_gxy) const
void eval_lagrangian_gradient(crvec x, crvec y, rvec grad_L, rvec work_n) const
real_t eval_augmented_lagrangian(crvec x, crvec y, crvec Σ, rvec ŷ) const
void eval_augmented_lagrangian_gradient(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
real_t eval_augmented_lagrangian_and_gradient(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
std::string get_name() const
bool provides_eval_objective() const
bool provides_eval_objective_gradient() const
bool provides_eval_constraints() const
bool provides_eval_constraints_gradient_product() const
bool provides_eval_constraints_jacobian() const
bool provides_get_constraints_jacobian_sparsity() const
bool provides_eval_grad_gi() const
bool provides_eval_lagrangian_hessian_product() const
bool provides_eval_lagrangian_hessian() const
bool provides_get_lagrangian_hessian_sparsity() const
bool provides_eval_augmented_lagrangian_hessian_product() const
bool provides_eval_augmented_lagrangian_hessian() const
bool provides_get_augmented_lagrangian_hessian_sparsity() const
bool provides_eval_objective_and_gradient() const
bool provides_eval_objective_and_constraints() const
bool provides_eval_objective_gradient_and_constraints_gradient_product() const
bool provides_eval_lagrangian_gradient() const
bool provides_eval_augmented_lagrangian() const
bool provides_eval_augmented_lagrangian_gradient() const
bool provides_eval_augmented_lagrangian_and_gradient() const
bool provides_get_variable_bounds() const
bool provides_get_general_bounds() const
bool provides_eval_inactive_indices_res_lna() const
template<class Signature, class ...Args>
inline decltype(auto) call_extra_func(const std::string &name, Args&&... args) const
template<class Signature, class ...Args>
inline decltype(auto) call_extra_func(const std::string &name, Args&&... args)
class ExtraFuncs
#include <alpaqa/dl/dl-problem.hpp>

Public Functions

ExtraFuncs() = default
inline ExtraFuncs(std::shared_ptr<function_dict_t> &&extra_funcs)
template<class Signature>
inline const std::function<Signature> &extra_func(const std::string &name) const
template<class Ret, class ...FArgs, class ...Args>
inline decltype(auto) call_extra_func_helper(const void *instance, FuncTag<Ret(const instance_t*, FArgs...)>, const std::string &name, Args&&... args) const
template<class Ret, class ...FArgs, class ...Args>
inline decltype(auto) call_extra_func_helper(void *instance, FuncTag<Ret(instance_t*, FArgs...)>, const std::string &name, Args&&... args)
template<class Ret, class ...FArgs, class ...Args>
inline decltype(auto) call_extra_func_helper(const void*, FuncTag<Ret(FArgs...)>, const std::string &name, Args&&... args) const

Public Members

std::shared_ptr<function_dict_t> extra_functions

An associative array of additional functions exposed by the problem.

template<class Func>
struct FuncTag
#include <alpaqa/dl/dl-problem.hpp>
struct invalid_abi_error : public dynamic_load_error
#include <alpaqa/dl/dl-problem.hpp>
namespace functions

Typedefs

template<Config Conf>
using DefaultSVD = Eigen::BDCSVD<typename Conf::mat>
template<Config Conf, class Weight = typename Conf::real_t>
struct L1Norm
#include <alpaqa/functions/l1-norm.hpp>

ℓ₁-norm.

Template Parameters:

Weight – Type of weighting factors. Either scalar or vector.

Public Types

using weight_t = Weight

Public Functions

inline L1Norm(weight_t λ)
inline L1Norm()
L1Norm() = default
inline real_t prox(crmat in, rmat out, real_t γ = 1)

Public Members

weight_t λ

Public Static Attributes

static bool scalar_weight = std::is_same_v<weight_t, real_t>

Friends

inline friend real_t guanaqo_tag_invoke(tag_t<alpaqa::prox>, L1Norm &self, crmat in, rmat out, real_t γ)
template<Config Conf, class Weight = typename Conf::real_t>
struct L1NormComplex
#include <alpaqa/functions/l1-norm.hpp>

ℓ₁-norm of complex numbers.

Template Parameters:

Weight – Type of weighting factors. Either scalar or vector.

Public Types

using weight_t = Weight

Public Functions

inline L1NormComplex(weight_t λ)
inline L1NormComplex()
L1NormComplex() = default
inline real_t prox(crcmat in, rcmat out, real_t γ = 1)
inline real_t prox(crmat in, rmat out, real_t γ = 1)

Note: a complex vector in ℂⁿ is represented by a real vector in ℝ²ⁿ.

Public Members

weight_t λ

Public Static Attributes

static bool scalar_weight = std::is_same_v<weight_t, real_t>

Friends

inline friend real_t guanaqo_tag_invoke(tag_t<alpaqa::prox>, L1NormComplex &self, crmat in, rmat out, real_t γ)
template<Config Conf, class SVD = DefaultSVD<Conf>>
struct NuclearNorm
#include <alpaqa/functions/nuclear-norm.hpp>

Nuclear norm (ℓ₁-norm of singular values).

Public Functions

inline NuclearNorm(real_t λ = 1)

Construct without pre-allocation.

inline NuclearNorm(real_t λ, length_t rows, length_t cols)

Construct with pre-allocation.

inline real_t prox(crmat in, rmat out, real_t γ = 1)

Public Members

real_t λ
length_t rows = 0
length_t cols = 0
SVD svd
vec singular_values

Friends

inline friend real_t guanaqo_tag_invoke(tag_t<alpaqa::prox>, NuclearNorm &self, crmat in, rmat out, real_t γ)
namespace lbfgsb
struct LBFGSBParams
#include <alpaqa/lbfgsb/lbfgsb-adapter.hpp>

Tuning parameters for the L-BFGS-B solver LBFGSBSolver.

Public Members

unsigned memory = 10
unsigned max_iter = 1000
std::chrono::nanoseconds max_time = std::chrono::minutes(5)
PANOCStopCrit stop_crit = PANOCStopCrit::ProjGradUnitNorm
int print = -1
unsigned print_interval = 0
int print_precision = std::numeric_limits<real_t>::max_digits10 / 2
struct LBFGSBProgressInfo
#include <alpaqa/lbfgsb/lbfgsb-adapter.hpp>

Public Members

unsigned k
SolverStatus status
crvec x
real_t ψ
crvec grad_ψ
real_t τ_max
real_t τ
real_t ε
crvec Σ
crvec y
unsigned outer_iter
const TypeErasedProblem<config_t> *problem
const LBFGSBParams *params
class LBFGSBSolver
#include <alpaqa/lbfgsb/lbfgsb-adapter.hpp>

L-BFGS-B solver for ALM.

Public Types

using Problem = TypeErasedProblem<config_t>
using Params = LBFGSBParams
using Stats = LBFGSBStats
using ProgressInfo = LBFGSBProgressInfo
using SolveOptions = InnerSolveOptions<config_t>

Public Functions

inline LBFGSBSolver(const Params &params)
Stats operator()(const Problem &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec err_z)
Parameters:
  • problem – [in] Problem description

  • opts – [in] Solve options

  • x – [inout] Decision variable \( x \)

  • y – [inout] Lagrange multipliers \( y \)

  • Σ – [in] Constraint weights \( \Sigma \)

  • err_z – [out] Slack variable error \( g(x) - \Pi_D(g(x) + \Sigma^{-1} y) \)

template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec u, rvec y, crvec Σ, rvec e)
inline LBFGSBSolver &set_progress_callback(std::function<void(const ProgressInfo&)> cb)

Specify a callable that is invoked with some intermediate results on each iteration of the algorithm.

See also

ProgressInfo

std::string get_name() const
inline void stop()
inline const Params &get_params() const

Public Members

std::ostream *os = &std::cout
struct LBFGSBStats
#include <alpaqa/lbfgsb/lbfgsb-adapter.hpp>

Public Members

SolverStatus status = SolverStatus::Busy
real_t ε = inf<config_t>
std::chrono::nanoseconds elapsed_time = {}
std::chrono::nanoseconds time_progress_callback = {}
unsigned iterations = 0
real_t final_ψ = 0
unsigned direction_update_rejected = 0
namespace lbfgspp
template<Config Conf>
class LBFGSBSolver
#include <alpaqa/lbfgsb-adapter.hpp>

L-BFGS-B solver for ALM.

Public Types

using Problem = TypeErasedProblem<config_t>
using Params = ::LBFGSpp::LBFGSBParam<real_t>
using Stats = LBFGSBStats<config_t>
using SolveOptions = InnerSolveOptions<config_t>

Public Functions

inline LBFGSBSolver(const Params &params)
Stats operator()(const Problem &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec err_z)
template<class P>
inline Stats operator()(const P &problem, const SolveOptions &opts, rvec u, rvec y, crvec Σ, rvec e)
std::string get_name() const
inline void stop()
inline const Params &get_params() const

Public Members

std::ostream *os = &std::cout
template<Config Conf = DefaultConfig>
struct LBFGSBStats
#include <alpaqa/lbfgsb-adapter.hpp>

Public Members

SolverStatus status = SolverStatus::Busy
real_t ε = inf<config_t>
std::chrono::nanoseconds elapsed_time = {}
unsigned iterations = 0
real_t final_ψ = 0
namespace params

Typedefs

template<class S>
using attribute_table_t = std::map<std::string_view, attribute_accessor<S>>

Dictionary that maps struct attribute names to type-erased functions that set those attributes.

template<class S>
using attribute_alias_table_t = std::map<std::string_view, std::string_view>

Dictionary that maps struct attribute names to type-erased functions that set those attributes.

template<class T, class S>
using enum_table_t = std::map<std::string_view, enum_accessor<T, S>>

Dictionary that maps enumerator names to their values and documentation.

Functions

template<class T>
void set_param(T&, const json &j)

Update/overwrite the first argument based on the JSON object j.

template<class T>
void get_param(const T&, json &j)

Get the first argument as a JSON object j.

inline auto split_key(std::string_view full, char tok = '.')

Split the string full on the first occurrence of tok.

Returns (s, “”) if tok was not found.

template<class T>
void set_param(T&, ParamString)

Update/overwrite the first argument based on the option in s.

template<class T>
void set_params(T &t, std::string_view prefix, std::span<const std::string_view> options, std::optional<std::span<unsigned>> used = std::nullopt)

Overwrites t based on the options that start with prefix.

If used is not nullopt, sets corresponding flag of the options that were used.

template<class T>
bool is_leaf()
template<class T>
Result get_members(const MemberGetter &s)

Catch-all.

template<class T>
Result get_members(const MemberGetter &s)

Struct types.

template<class T>
Result get_members(const MemberGetter &s)

Enum types.

template<>
Result get_members<bool>(const MemberGetter &s)

True/false.

template<class Duration>
void set_param_default(Duration &t, const json &j)
template<class Duration>
void get_param_default(const Duration &t, json &s)
template<>
void set_param(alpaqa::vec<config_t> &v, const json &j)
template<>
void set_param(vec_from_file<config_t> &v, const json &j)
template<>
void set_param(std::monostate&, const nlohmann::json&)
template<>
void set_param(bool &t, const nlohmann::json &j)
template<>
void set_param(std::string &t, const nlohmann::json &j)
template<std::integral T>
void set_param_default(T &t, const nlohmann::json &j)
template<std::floating_point T>
void set_param_default(T &t, const nlohmann::json &j)
template<class T>
void get_param_default(const T &t, nlohmann::json &j)
template<std::floating_point T>
void get_param_default(const T &t, nlohmann::json &j)
template<class ...Ts>
void set_param(guanaqo::detail::dummy<Ts...>&, const json&)
template<class ...Ts>
void get_param(const guanaqo::detail::dummy<Ts...>&, json&)
template void get_param (const guanaqo::possible_alias_t< std::string > &, json &)
template void get_param (const guanaqo::possible_alias_t< bool > &, json &)
template void set_param (guanaqo::possible_alias_t< float > &, const json &)
template void get_param (const guanaqo::possible_alias_t< float > &, json &)
template void set_param (guanaqo::possible_alias_t< double, float > &, const json &)
template void get_param (const guanaqo::possible_alias_t< double, float > &, json &)
template void set_param (guanaqo::possible_alias_t< long double, double, float > &, const json &)
template void get_param (const guanaqo::possible_alias_t< long double, double, float > &, json &)
template void set_param (guanaqo::possible_alias_t< int8_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< int8_t > &, json &)
template void set_param (guanaqo::possible_alias_t< uint8_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< uint8_t > &, json &)
template void set_param (guanaqo::possible_alias_t< int16_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< int16_t > &, json &)
template void set_param (guanaqo::possible_alias_t< uint16_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< uint16_t > &, json &)
template void set_param (guanaqo::possible_alias_t< int32_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< int32_t > &, json &)
template void set_param (guanaqo::possible_alias_t< int64_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< int64_t > &, json &)
template void set_param (guanaqo::possible_alias_t< uint32_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< uint32_t > &, json &)
template void set_param (guanaqo::possible_alias_t< uint64_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< uint64_t > &, json &)
template void set_param (guanaqo::possible_alias_t< short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, json &)
template void set_param (guanaqo::possible_alias_t< int, short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< int, short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, json &)
template void set_param (guanaqo::possible_alias_t< long, int, short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< long, int, short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, json &)
template void set_param (guanaqo::possible_alias_t< long long, long, int, short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< long long, long, int, short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, json &)
template void set_param (guanaqo::possible_alias_t< ptrdiff_t, long long, long, int, short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< ptrdiff_t, long long, long, int, short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, json &)
template void set_param (guanaqo::possible_alias_t< unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, json &)
template void set_param (guanaqo::possible_alias_t< unsigned int, unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< unsigned int, unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, json &)
template void set_param (guanaqo::possible_alias_t< unsigned long, unsigned int, unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< unsigned long, unsigned int, unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, json &)
template void set_param (guanaqo::possible_alias_t< unsigned long long, unsigned long, unsigned int, unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< unsigned long long, unsigned long, unsigned int, unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, json &)
template void set_param (guanaqo::possible_alias_t< size_t, unsigned long long, unsigned long, unsigned int, unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, const json &)
template void get_param (const guanaqo::possible_alias_t< size_t, unsigned long long, unsigned long, unsigned int, unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, json &)
template void set_param (guanaqo::possible_alias_t< std::chrono::nanoseconds > &, const json &)
template void get_param (const guanaqo::possible_alias_t< std::chrono::nanoseconds > &, json &)
template void set_param (guanaqo::possible_alias_t< std::chrono::microseconds > &, const json &)
template void get_param (const guanaqo::possible_alias_t< std::chrono::microseconds > &, json &)
template void set_param (guanaqo::possible_alias_t< std::chrono::milliseconds > &, const json &)
template void get_param (const guanaqo::possible_alias_t< std::chrono::milliseconds > &, json &)
template void set_param (guanaqo::possible_alias_t< std::chrono::seconds > &, const json &)
template void get_param (const guanaqo::possible_alias_t< std::chrono::seconds > &, json &)
template void set_param (guanaqo::possible_alias_t< std::chrono::minutes > &, const json &)
template void get_param (const guanaqo::possible_alias_t< std::chrono::minutes > &, json &)
template void set_param (guanaqo::possible_alias_t< std::chrono::hours > &, const json &)
template void get_param (const guanaqo::possible_alias_t< std::chrono::hours > &, json &)
template void set_param (guanaqo::possible_alias_t< PANOCStopCrit > &, const json &)
template void get_param (const guanaqo::possible_alias_t< PANOCStopCrit > &, json &)
template void set_param (guanaqo::possible_alias_t< LBFGSStepSize > &, const json &)
template void get_param (const guanaqo::possible_alias_t< LBFGSStepSize > &, json &)
template void set_param (guanaqo::possible_alias_t< guanaqo::DynamicLoadFlags > &, const json &)
template void get_param (const guanaqo::possible_alias_t< guanaqo::DynamicLoadFlags > &, json &)
template void set_param (guanaqo::possible_alias_t< CBFGSParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< CBFGSParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< LipschitzEstimateParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< LipschitzEstimateParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< PANOCParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< PANOCParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< FISTAParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< FISTAParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< ZeroFPRParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< ZeroFPRParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< PANTRParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< PANTRParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< LBFGSParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< LBFGSParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< AndersonAccelParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< AndersonAccelParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< LBFGSDirectionParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< LBFGSDirectionParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< AndersonDirectionParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< AndersonDirectionParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< StructuredLBFGSDirectionParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< StructuredLBFGSDirectionParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< NewtonTRDirectionParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< NewtonTRDirectionParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< SteihaugCGParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< SteihaugCGParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< StructuredNewtonRegularizationParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< StructuredNewtonRegularizationParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< StructuredNewtonDirectionParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< StructuredNewtonDirectionParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< ConvexNewtonRegularizationParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< ConvexNewtonRegularizationParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< ConvexNewtonDirectionParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< ConvexNewtonDirectionParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< ALMParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< ALMParams< config_t > > &, json &)
template void set_param (guanaqo::possible_alias_t< PANOCOCPParams< config_t > > &, const json &)
template void get_param (const guanaqo::possible_alias_t< PANOCOCPParams< config_t > > &, json &)
template<>
void set_param(std::monostate&, ParamString)
template<>
void set_param(bool &b, ParamString s)
template<>
void set_param(std::string_view &v, ParamString s)
template<>
void set_param(std::string &v, ParamString s)
template<class T>
void set_param_default(T &f, ParamString s)
template<>
void set_param(alpaqa::vec<config_t> &v, ParamString s)
template<>
void set_param(vec_from_file<config_t> &v, ParamString s)
template<class Duration>
void set_param_default(Duration &t, ParamString s)
template<class ...Ts>
void set_param(guanaqo::detail::dummy<Ts...>&, ParamString)
template void set_param (guanaqo::possible_alias_t< float > &, ParamString)
template void set_param (guanaqo::possible_alias_t< double, float > &, ParamString)
template void set_param (guanaqo::possible_alias_t< long double, double, float > &, ParamString)
template void set_param (guanaqo::possible_alias_t< int8_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< uint8_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< int16_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< uint16_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< int32_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< int64_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< uint32_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< uint64_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< int, short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< long, int, short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< long long, long, int, short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< ptrdiff_t, long long, long, int, short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< unsigned int, unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< unsigned long, unsigned int, unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< unsigned long long, unsigned long, unsigned int, unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< size_t, unsigned long long, unsigned long, unsigned int, unsigned short, int8_t, uint8_t, int16_t, uint16_t, int32_t, int64_t, uint32_t, uint64_t > &, ParamString)
template void set_param (guanaqo::possible_alias_t< std::chrono::nanoseconds > &, ParamString)
template void set_param (guanaqo::possible_alias_t< std::chrono::microseconds > &, ParamString)
template void set_param (guanaqo::possible_alias_t< std::chrono::milliseconds > &, ParamString)
template void set_param (guanaqo::possible_alias_t< std::chrono::seconds > &, ParamString)
template void set_param (guanaqo::possible_alias_t< std::chrono::minutes > &, ParamString)
template void set_param (guanaqo::possible_alias_t< std::chrono::hours > &, ParamString)
template void set_param (guanaqo::possible_alias_t< PANOCStopCrit > &, ParamString)
template void set_param (guanaqo::possible_alias_t< LBFGSStepSize > &, ParamString)
template void set_param (guanaqo::possible_alias_t< guanaqo::DynamicLoadFlags > &, ParamString)
template void set_param (guanaqo::possible_alias_t< PANOCParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< FISTAParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< ZeroFPRParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< PANTRParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< LBFGSParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< AndersonAccelParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< LBFGSDirectionParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< AndersonDirectionParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< StructuredLBFGSDirectionParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< NewtonTRDirectionParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< SteihaugCGParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< StructuredNewtonRegularizationParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< StructuredNewtonDirectionParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< ConvexNewtonRegularizationParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< ConvexNewtonDirectionParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< ALMParams< config_t > > &, ParamString)
template void set_param (guanaqo::possible_alias_t< PANOCOCPParams< config_t > > &, ParamString)
template<>
void set_param(Ipopt::IpoptApplication&, const json &j)
template<>
void get_param(const Ipopt::IpoptApplication&, json &j)
template<class T>
static auto possible_keys(const T &tbl)
template<>
void set_param(Ipopt::IpoptApplication &app, ParamString s)
template<>
void set_param(lbfgsb::LBFGSBSolver::Params &t, const json &j)
template<>
void get_param(const lbfgsb::LBFGSBSolver::Params &t, json &j)
template<>
void set_param(lbfgsb::LBFGSBSolver::Params &t, ParamString s)
template<>
void set_param(qpalm::Settings &t, const json &j)
template<>
void get_param(const qpalm::Settings &t, json &j)
template<>
void set_param(qpalm::Settings &t, ParamString s)

Variables

template<class T>
bool is_duration = false
template<class Rep, class Period>
bool is_duration<std::chrono::duration<Rep, Period>> = true
template<class S>
struct attribute_accessor

Function wrapper to set attributes of a struct, type-erasing the type of the attribute.

template<>
struct attribute_accessor<MemberGetter>
#include </home/runner/work/alpaqa/alpaqa/src/alpaqa/src/driver/param-complete.hpp>

Public Types

using get_members_func_t = Result(const MemberGetter&)

Public Members

get_members_func_t *get
std::string_view doc
bool leaf

Public Static Functions

template<class T, class T_actual, class A>
static inline attribute_accessor make(A T_actual::*, std::string_view doc = "")
template<class T, class S>
struct attribute_alias_table

Specialize this type to define the alternative attribute name to attribute setters dictionaries for a struct type T.

template<Config Conf, class S>
struct attribute_alias_table<CBFGSParams<Conf>, S>

Public Types

using type = CBFGSParams<Conf>
using type = CBFGSParams<Conf>
using type = CBFGSParams<Conf>

Public Static Attributes

static const attribute_alias_table_t<S> table = {{"alpha", "α"}, {"epsilon", "ϵ"},}
template<Config Conf, class S>
struct attribute_alias_table<LipschitzEstimateParams<Conf>, S>

Public Types

using type = LipschitzEstimateParams<Conf>
using type = LipschitzEstimateParams<Conf>
using type = LipschitzEstimateParams<Conf>

Public Static Attributes

static const attribute_alias_table_t<S> table = {{"delta", "δ"}, {"epsilon", "ε"}, {"L_gamma_factor", "Lγ_factor"},}
template<class T, class S>
struct attribute_table

Specialize this type to define the attribute name to attribute setters dictionaries for a struct type T.

template<Config Conf, class S>
struct attribute_table<ALMParams<Conf>, S>

Public Types

using type = ALMParams<Conf>
using type = ALMParams<Conf>
using type = ALMParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"tolerance", attribute_accessor<S>::template make<type>(&type::tolerance, "")}, {"dual_tolerance", attribute_accessor<S>::template make<type>(&type::dual_tolerance, "")}, {"penalty_update_factor", attribute_accessor<S>::template make<type>(&type::penalty_update_factor, "")}, {"initial_penalty", attribute_accessor<S>::template make<type>(&type::initial_penalty, "")}, {"initial_penalty_factor", attribute_accessor<S>::template make<type>(&type::initial_penalty_factor, "")}, {"initial_tolerance", attribute_accessor<S>::template make<type>(&type::initial_tolerance, "")}, {"tolerance_update_factor", attribute_accessor<S>::template make<type>(&type::tolerance_update_factor, "")}, {"rel_penalty_increase_threshold", attribute_accessor<S>::template make<type>(&type::rel_penalty_increase_threshold, "")}, {"max_multiplier", attribute_accessor<S>::template make<type>(&type::max_multiplier, "")}, {"max_penalty", attribute_accessor<S>::template make<type>(&type::max_penalty, "")}, {"min_penalty", attribute_accessor<S>::template make<type>(&type::min_penalty, "")}, {"max_iter", attribute_accessor<S>::template make<type>(&type::max_iter, "")}, {"max_time", attribute_accessor<S>::template make<type>(&type::max_time, "")}, {"print_interval", attribute_accessor<S>::template make<type>(&type::print_interval, "")}, {"print_precision", attribute_accessor<S>::template make<type>(&type::print_precision, "")}, {"single_penalty_factor", attribute_accessor<S>::template make<type>(&type::single_penalty_factor, "")},}
template<Config Conf, class S>
struct attribute_table<AndersonAccelParams<Conf>, S>

Public Types

using type = AndersonAccelParams<Conf>
using type = AndersonAccelParams<Conf>
using type = AndersonAccelParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"memory", attribute_accessor<S>::template make<type>(&type::memory, "")}, {"min_div_fac", attribute_accessor<S>::template make<type>(&type::min_div_fac, "")},}
template<Config Conf, class S>
struct attribute_table<AndersonDirectionParams<Conf>, S>

Public Types

using type = AndersonDirectionParams<Conf>
using type = AndersonDirectionParams<Conf>
using type = AndersonDirectionParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"rescale_on_step_size_changes", attribute_accessor<S>::template make<type>(&type::rescale_on_step_size_changes, "")},}
template<Config Conf, class S>
struct attribute_table<CBFGSParams<Conf>, S>

Public Types

using type = CBFGSParams<Conf>
using type = CBFGSParams<Conf>
using type = CBFGSParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"α", attribute_accessor<S>::template make<type>(&type::α, "")}, {"ϵ", attribute_accessor<S>::template make<type>(&type::ϵ, "")},}
template<Config Conf, class S>
struct attribute_table<ConvexNewtonDirectionParams<Conf>, S>

Public Static Attributes

static const attribute_table_t<S> table = {{"hessian_vec_factor", attribute_accessor<S>::template make<type>(&type::hessian_vec_factor, "")}, {"quadratic", attribute_accessor<S>::template make<type>(&type::quadratic, "")},}
template<Config Conf, class S>
struct attribute_table<ConvexNewtonRegularizationParams<Conf>, S>

Public Static Attributes

static const attribute_table_t<S> table = {{"ζ", attribute_accessor<S>::template make<type>(&type::ζ, "")}, {"ν", attribute_accessor<S>::template make<type>(&type::ν, "")}, {"ldlt", attribute_accessor<S>::template make<type>(&type::ldlt, "")},}
template<Config Conf, class S>
struct attribute_table<FISTAParams<Conf>, S>

Public Types

using type = FISTAParams<Conf>
using type = FISTAParams<Conf>
using type = FISTAParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"Lipschitz", attribute_accessor<S>::template make<type>(&type::Lipschitz, "")}, {"max_iter", attribute_accessor<S>::template make<type>(&type::max_iter, "")}, {"max_time", attribute_accessor<S>::template make<type>(&type::max_time, "")}, {"L_min", attribute_accessor<S>::template make<type>(&type::L_min, "")}, {"L_max", attribute_accessor<S>::template make<type>(&type::L_max, "")}, {"stop_crit", attribute_accessor<S>::template make<type>(&type::stop_crit, "")}, {"max_no_progress", attribute_accessor<S>::template make<type>(&type::max_no_progress, "")}, {"print_interval", attribute_accessor<S>::template make<type>(&type::print_interval, "")}, {"print_precision", attribute_accessor<S>::template make<type>(&type::print_precision, "")}, {"quadratic_upperbound_tolerance_factor", attribute_accessor<S>::template make<type>(&type::quadratic_upperbound_tolerance_factor, "")}, {"disable_acceleration", attribute_accessor<S>::template make<type>(&type::disable_acceleration, "")},}
template<class S>
struct attribute_table<guanaqo::DynamicLoadFlags, S>

Public Types

using type = guanaqo::DynamicLoadFlags
using type = guanaqo::DynamicLoadFlags
using type = guanaqo::DynamicLoadFlags

Public Static Attributes

static const attribute_table_t<S> table = {{"global", attribute_accessor<S>::template make<type>(&type::global, "")}, {"lazy", attribute_accessor<S>::template make<type>(&type::lazy, "")}, {"nodelete", attribute_accessor<S>::template make<type>(&type::nodelete, "")}, {"deepbind", attribute_accessor<S>::template make<type>(&type::deepbind, "")},}
template<class S>
struct attribute_table<lbfgsb::LBFGSBSolver::Params, S>

Public Types

using type = lbfgsb::LBFGSBSolver::Params
using type = lbfgsb::LBFGSBSolver::Params

Public Static Attributes

static const attribute_table_t<S> table = {{"memory", attribute_accessor<S>::template make<type>(&type::memory, "")}, {"max_iter", attribute_accessor<S>::template make<type>(&type::max_iter, "")}, {"max_time", attribute_accessor<S>::template make<type>(&type::max_time, "")}, {"stop_crit", attribute_accessor<S>::template make<type>(&type::stop_crit, "")}, {"print", attribute_accessor<S>::template make<type>(&type::print, "")}, {"print_interval", attribute_accessor<S>::template make<type>(&type::print_interval, "")}, {"print_precision", attribute_accessor<S>::template make<type>(&type::print_precision, "")},}
template<Config Conf, class S>
struct attribute_table<LBFGSDirectionParams<Conf>, S>

Public Types

using type = LBFGSDirectionParams<Conf>
using type = LBFGSDirectionParams<Conf>
using type = LBFGSDirectionParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"rescale_on_step_size_changes", attribute_accessor<S>::template make<type>(&type::rescale_on_step_size_changes, "")},}
template<Config Conf, class S>
struct attribute_table<LBFGSParams<Conf>, S>

Public Types

using type = LBFGSParams<Conf>
using type = LBFGSParams<Conf>
using type = LBFGSParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"memory", attribute_accessor<S>::template make<type>(&type::memory, "")}, {"min_div_fac", attribute_accessor<S>::template make<type>(&type::min_div_fac, "")}, {"min_abs_s", attribute_accessor<S>::template make<type>(&type::min_abs_s, "")}, {"cbfgs", attribute_accessor<S>::template make<type>(&type::cbfgs, "")}, {"force_pos_def", attribute_accessor<S>::template make<type>(&type::force_pos_def, "")}, {"stepsize", attribute_accessor<S>::template make<type>(&type::stepsize, "")},}
template<Config Conf, class S>
struct attribute_table<LipschitzEstimateParams<Conf>, S>

Public Types

using type = LipschitzEstimateParams<Conf>
using type = LipschitzEstimateParams<Conf>
using type = LipschitzEstimateParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"L_0", attribute_accessor<S>::template make<type>(&type::L_0, "")}, {"δ", attribute_accessor<S>::template make<type>(&type::δ, "")}, {"ε", attribute_accessor<S>::template make<type>(&type::ε, "")}, {"Lγ_factor", attribute_accessor<S>::template make<type>(&type::Lγ_factor, "")},}
template<Config Conf, class S>
struct attribute_table<NewtonTRDirectionParams<Conf>, S>

Public Types

using type = NewtonTRDirectionParams<Conf>
using type = NewtonTRDirectionParams<Conf>
using type = NewtonTRDirectionParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"hessian_vec_factor", attribute_accessor<S>::template make<type>(&type::hessian_vec_factor, "")}, {"finite_diff", attribute_accessor<S>::template make<type>(&type::finite_diff, "")}, {"finite_diff_stepsize", attribute_accessor<S>::template make<type>(&type::finite_diff_stepsize, "")},}
template<Config Conf, class S>
struct attribute_table<PANOCOCPParams<Conf>, S>

Public Types

using type = PANOCOCPParams<Conf>
using type = PANOCOCPParams<Conf>
using type = PANOCOCPParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"Lipschitz", attribute_accessor<S>::template make<type>(&type::Lipschitz, "")}, {"max_iter", attribute_accessor<S>::template make<type>(&type::max_iter, "")}, {"max_time", attribute_accessor<S>::template make<type>(&type::max_time, "")}, {"min_linesearch_coefficient", attribute_accessor<S>::template make<type>(&type::min_linesearch_coefficient, "")}, {"linesearch_strictness_factor", attribute_accessor<S>::template make<type>(&type::linesearch_strictness_factor, "")}, {"L_min", attribute_accessor<S>::template make<type>(&type::L_min, "")}, {"L_max", attribute_accessor<S>::template make<type>(&type::L_max, "")}, {"L_max_inc", attribute_accessor<S>::template make<type>(&type::L_max_inc, "")}, {"stop_crit", attribute_accessor<S>::template make<type>(&type::stop_crit, "")}, {"max_no_progress", attribute_accessor<S>::template make<type>(&type::max_no_progress, "")}, {"gn_interval", attribute_accessor<S>::template make<type>(&type::gn_interval, "")}, {"gn_sticky", attribute_accessor<S>::template make<type>(&type::gn_sticky, "")}, {"reset_lbfgs_on_gn_step", attribute_accessor<S>::template make<type>(&type::reset_lbfgs_on_gn_step, "")}, {"lqr_factor_cholesky", attribute_accessor<S>::template make<type>(&type::lqr_factor_cholesky, "")}, {"lbfgs_params", attribute_accessor<S>::template make<type>(&type::lbfgs_params, "")}, {"print_interval", attribute_accessor<S>::template make<type>(&type::print_interval, "")}, {"print_precision", attribute_accessor<S>::template make<type>(&type::print_precision, "")}, {"quadratic_upperbound_tolerance_factor", attribute_accessor<S>::template make<type>(&type::quadratic_upperbound_tolerance_factor, "")}, {"linesearch_tolerance_factor", attribute_accessor<S>::template make<type>(&type::linesearch_tolerance_factor, "")}, {"disable_acceleration", attribute_accessor<S>::template make<type>(&type::disable_acceleration, "")},}
template<Config Conf, class S>
struct attribute_table<PANOCParams<Conf>, S>

Public Types

using type = PANOCParams<Conf>
using type = PANOCParams<Conf>
using type = PANOCParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"Lipschitz", attribute_accessor<S>::template make<type>(&type::Lipschitz, "")}, {"max_iter", attribute_accessor<S>::template make<type>(&type::max_iter, "")}, {"max_time", attribute_accessor<S>::template make<type>(&type::max_time, "")}, {"min_linesearch_coefficient", attribute_accessor<S>::template make<type>(&type::min_linesearch_coefficient, "")}, {"linesearch_coefficient_update_factor", attribute_accessor<S>::template make<type>(&type::linesearch_coefficient_update_factor, "")}, {"force_linesearch", attribute_accessor<S>::template make<type>(&type::force_linesearch, "")}, {"linesearch_strictness_factor", attribute_accessor<S>::template make<type>(&type::linesearch_strictness_factor, "")}, {"L_min", attribute_accessor<S>::template make<type>(&type::L_min, "")}, {"L_max", attribute_accessor<S>::template make<type>(&type::L_max, "")}, {"stop_crit", attribute_accessor<S>::template make<type>(&type::stop_crit, "")}, {"max_no_progress", attribute_accessor<S>::template make<type>(&type::max_no_progress, "")}, {"print_interval", attribute_accessor<S>::template make<type>(&type::print_interval, "")}, {"print_precision", attribute_accessor<S>::template make<type>(&type::print_precision, "")}, {"quadratic_upperbound_tolerance_factor", attribute_accessor<S>::template make<type>(&type::quadratic_upperbound_tolerance_factor, "")}, {"linesearch_tolerance_factor", attribute_accessor<S>::template make<type>(&type::linesearch_tolerance_factor, "")}, {"update_direction_in_candidate", attribute_accessor<S>::template make<type>(&type::update_direction_in_candidate, "")}, {"recompute_last_prox_step_after_stepsize_change", attribute_accessor<S>::template make<type>(&type::recompute_last_prox_step_after_stepsize_change, "")}, {"eager_gradient_eval", attribute_accessor<S>::template make<type>(&type::eager_gradient_eval, "")},}
template<Config Conf, class S>
struct attribute_table<PANTRParams<Conf>, S>

Public Types

using type = PANTRParams<Conf>
using type = PANTRParams<Conf>
using type = PANTRParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"Lipschitz", attribute_accessor<S>::template make<type>(&type::Lipschitz, "")}, {"max_iter", attribute_accessor<S>::template make<type>(&type::max_iter, "")}, {"max_time", attribute_accessor<S>::template make<type>(&type::max_time, "")}, {"L_min", attribute_accessor<S>::template make<type>(&type::L_min, "")}, {"L_max", attribute_accessor<S>::template make<type>(&type::L_max, "")}, {"stop_crit", attribute_accessor<S>::template make<type>(&type::stop_crit, "")}, {"max_no_progress", attribute_accessor<S>::template make<type>(&type::max_no_progress, "")}, {"print_interval", attribute_accessor<S>::template make<type>(&type::print_interval, "")}, {"print_precision", attribute_accessor<S>::template make<type>(&type::print_precision, "")}, {"quadratic_upperbound_tolerance_factor", attribute_accessor<S>::template make<type>(&type::quadratic_upperbound_tolerance_factor, "")}, {"TR_tolerance_factor", attribute_accessor<S>::template make<type>(&type::TR_tolerance_factor, "")}, {"ratio_threshold_acceptable", attribute_accessor<S>::template make<type>(&type::ratio_threshold_acceptable, "")}, {"ratio_threshold_good", attribute_accessor<S>::template make<type>(&type::ratio_threshold_good, "")}, {"radius_factor_rejected", attribute_accessor<S>::template make<type>(&type::radius_factor_rejected, "")}, {"radius_factor_acceptable", attribute_accessor<S>::template make<type>(&type::radius_factor_acceptable, "")}, {"radius_factor_good", attribute_accessor<S>::template make<type>(&type::radius_factor_good, "")}, {"initial_radius", attribute_accessor<S>::template make<type>(&type::initial_radius, "")}, {"min_radius", attribute_accessor<S>::template make<type>(&type::min_radius, "")}, {"compute_ratio_using_new_stepsize", attribute_accessor<S>::template make<type>(&type::compute_ratio_using_new_stepsize, "")}, {"update_direction_on_prox_step", attribute_accessor<S>::template make<type>(&type::update_direction_on_prox_step, "")}, {"recompute_last_prox_step_after_direction_reset", attribute_accessor<S>::template make<type>(&type::recompute_last_prox_step_after_direction_reset, "")}, {"disable_acceleration", attribute_accessor<S>::template make<type>(&type::disable_acceleration, "")}, {"ratio_approx_fbe_quadratic_model", attribute_accessor<S>::template make<type>(&type::ratio_approx_fbe_quadratic_model, "")},}
template<class S>
struct attribute_table<qpalm::Settings, S>

Public Types

using type = qpalm::Settings
using type = qpalm::Settings

Public Static Attributes

static const attribute_table_t<S> table = {{"max_iter", attribute_accessor<S>::template make<type>(&type::max_iter, "")}, {"inner_max_iter", attribute_accessor<S>::template make<type>(&type::inner_max_iter, "")}, {"eps_abs", attribute_accessor<S>::template make<type>(&type::eps_abs, "")}, {"eps_rel", attribute_accessor<S>::template make<type>(&type::eps_rel, "")}, {"eps_abs_in", attribute_accessor<S>::template make<type>(&type::eps_abs_in, "")}, {"eps_rel_in", attribute_accessor<S>::template make<type>(&type::eps_rel_in, "")}, {"rho", attribute_accessor<S>::template make<type>(&type::rho, "")}, {"eps_prim_inf", attribute_accessor<S>::template make<type>(&type::eps_prim_inf, "")}, {"eps_dual_inf", attribute_accessor<S>::template make<type>(&type::eps_dual_inf, "")}, {"theta", attribute_accessor<S>::template make<type>(&type::theta, "")}, {"delta", attribute_accessor<S>::template make<type>(&type::delta, "")}, {"sigma_max", attribute_accessor<S>::template make<type>(&type::sigma_max, "")}, {"sigma_init", attribute_accessor<S>::template make<type>(&type::sigma_init, "")}, {"proximal", attribute_accessor<S>::template make<type>(&type::proximal, "")}, {"gamma_init", attribute_accessor<S>::template make<type>(&type::gamma_init, "")}, {"gamma_upd", attribute_accessor<S>::template make<type>(&type::gamma_upd, "")}, {"gamma_max", attribute_accessor<S>::template make<type>(&type::gamma_max, "")}, {"scaling", attribute_accessor<S>::template make<type>(&type::scaling, "")}, {"nonconvex", attribute_accessor<S>::template make<type>(&type::nonconvex, "")}, {"verbose", attribute_accessor<S>::template make<type>(&type::verbose, "")}, {"print_iter", attribute_accessor<S>::template make<type>(&type::print_iter, "")}, {"warm_start", attribute_accessor<S>::template make<type>(&type::warm_start, "")}, {"reset_newton_iter", attribute_accessor<S>::template make<type>(&type::reset_newton_iter, "")}, {"enable_dual_termination", attribute_accessor<S>::template make<type>(&type::enable_dual_termination, "")}, {"dual_objective_limit", attribute_accessor<S>::template make<type>(&type::dual_objective_limit, "")}, {"time_limit", attribute_accessor<S>::template make<type>(&type::time_limit, "")}, {"ordering", attribute_accessor<S>::template make<type>(&type::ordering, "")}, {"factorization_method", attribute_accessor<S>::template make<type>(&type::factorization_method, "")}, {"max_rank_update", attribute_accessor<S>::template make<type>(&type::max_rank_update, "")}, {"max_rank_update_fraction", attribute_accessor<S>::template make<type>(&type::max_rank_update_fraction, "")},}
template<class S>
struct attribute_table<RootOpts, S>

Public Types

using type = RootOpts

Public Static Attributes

static const attribute_table_t<S> table = {{"method", attribute_accessor<S>::template make<type>(&type::method, "Solver to use")}, {"out", attribute_accessor<S>::template make<type>(&type::out, "File to write output to")}, {"sol", attribute_accessor<S>::template make<type>(&type::sol, "Folder to write the solutions and statistics to")}, {"x0", attribute_accessor<S>::template make<type>(&type::x0, "Initial guess for the solution")}, {"mul_g0", attribute_accessor<S>::template make<type>(&type::mul_g0, "Initial guess for the general constraint multipliers")}, {"mul_x0", attribute_accessor<S>::template make<type>(&type::mul_x0, "Initial guess for the bound constraint multipliers")}, {"num_exp", attribute_accessor<S>::template make<type>(&type::num_exp, "Number of times to repeat the experiment")}, {"extra_stats", attribute_accessor<S>::template make<type>(&type::extra_stats, "Log more per-iteration solver statistics")}, {"show_funcs", attribute_accessor<S>::template make<type>(&type::show_funcs, "Print the provided problem functions")}, {"problem", attribute_accessor<S>::template make<type>(&type::problem, "Options to pass to the problem")}, {"dl_flags", attribute_accessor<S>::template make<type>(&type::dl_flags, "Flags to pass to dlopen")},}
template<Config Conf, class S>
struct attribute_table<SteihaugCGParams<Conf>, S>

Public Types

using type = SteihaugCGParams<Conf>
using type = SteihaugCGParams<Conf>
using type = SteihaugCGParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"tol_scale", attribute_accessor<S>::template make<type>(&type::tol_scale, "")}, {"tol_scale_root", attribute_accessor<S>::template make<type>(&type::tol_scale_root, "")}, {"tol_max", attribute_accessor<S>::template make<type>(&type::tol_max, "")}, {"max_iter_factor", attribute_accessor<S>::template make<type>(&type::max_iter_factor, "")},}
template<class S>
struct attribute_table<Struct, S>

Public Types

using type = Struct

Public Static Attributes

static const attribute_table_t<S> table = {}
template<Config Conf, class S>
struct attribute_table<StructuredLBFGSDirectionParams<Conf>, S>

Public Static Attributes

static const attribute_table_t<S> table = {{"hessian_vec_factor", attribute_accessor<S>::template make<type>(&type::hessian_vec_factor, "")}, {"hessian_vec_finite_differences", attribute_accessor<S>::template make<type>(&type::hessian_vec_finite_differences, "")}, {"full_augmented_hessian", attribute_accessor<S>::template make<type>(&type::full_augmented_hessian, "")},}
template<Config Conf, class S>
struct attribute_table<StructuredNewtonDirectionParams<Conf>, S>

Public Static Attributes

static const attribute_table_t<S> table = {{"hessian_vec_factor", attribute_accessor<S>::template make<type>(&type::hessian_vec_factor, "")},}
template<Config Conf, class S>
struct attribute_table<StructuredNewtonRegularizationParams<Conf>, S>

Public Static Attributes

static const attribute_table_t<S> table = {{"min_eig", attribute_accessor<S>::template make<type>(&type::min_eig, "")}, {"print_eig", attribute_accessor<S>::template make<type>(&type::print_eig, "")},}
template<Config Conf, class S>
struct attribute_table<ZeroFPRParams<Conf>, S>

Public Types

using type = ZeroFPRParams<Conf>
using type = ZeroFPRParams<Conf>
using type = ZeroFPRParams<Conf>

Public Static Attributes

static const attribute_table_t<S> table = {{"Lipschitz", attribute_accessor<S>::template make<type>(&type::Lipschitz, "")}, {"max_iter", attribute_accessor<S>::template make<type>(&type::max_iter, "")}, {"max_time", attribute_accessor<S>::template make<type>(&type::max_time, "")}, {"min_linesearch_coefficient", attribute_accessor<S>::template make<type>(&type::min_linesearch_coefficient, "")}, {"force_linesearch", attribute_accessor<S>::template make<type>(&type::force_linesearch, "")}, {"linesearch_strictness_factor", attribute_accessor<S>::template make<type>(&type::linesearch_strictness_factor, "")}, {"L_min", attribute_accessor<S>::template make<type>(&type::L_min, "")}, {"L_max", attribute_accessor<S>::template make<type>(&type::L_max, "")}, {"stop_crit", attribute_accessor<S>::template make<type>(&type::stop_crit, "")}, {"max_no_progress", attribute_accessor<S>::template make<type>(&type::max_no_progress, "")}, {"print_interval", attribute_accessor<S>::template make<type>(&type::print_interval, "")}, {"print_precision", attribute_accessor<S>::template make<type>(&type::print_precision, "")}, {"quadratic_upperbound_tolerance_factor", attribute_accessor<S>::template make<type>(&type::quadratic_upperbound_tolerance_factor, "")}, {"linesearch_tolerance_factor", attribute_accessor<S>::template make<type>(&type::linesearch_tolerance_factor, "")}, {"update_direction_in_candidate", attribute_accessor<S>::template make<type>(&type::update_direction_in_candidate, "")}, {"update_direction_in_accel", attribute_accessor<S>::template make<type>(&type::update_direction_in_accel, "")}, {"recompute_last_prox_step_after_stepsize_change", attribute_accessor<S>::template make<type>(&type::recompute_last_prox_step_after_stepsize_change, "")}, {"update_direction_from_prox_step", attribute_accessor<S>::template make<type>(&type::update_direction_from_prox_step, "")},}
template<class T, class S>
struct enum_accessor

Function wrapper access the enumerators of an enum, type-erasing the type of the enum.

template<class T>
struct enum_accessor<T, json>
#include <alpaqa/params/json.hpp>

Public Functions

inline enum_accessor(T value, std::string_view = "")

Public Members

T value
template<class T>
struct enum_accessor<T, MemberGetter>
#include </home/runner/work/alpaqa/alpaqa/src/alpaqa/src/driver/param-complete.hpp>

Public Functions

inline enum_accessor(T, std::string_view doc = "")

Public Members

std::string_view doc
template<class T, class S>
struct enum_table

Specialize this type to define the enumerator name to value dictionaries for an enum type T.

template<class S>
struct enum_table<LBFGSStepSize, S>

Public Types

using type = LBFGSStepSize
using type = LBFGSStepSize
using type = LBFGSStepSize

Public Static Attributes

static const enum_table_t<type, S> table = {{"BasedOnExternalStepSize", {type::BasedOnExternalStepSize,}}, {"BasedOnCurvature", {type::BasedOnCurvature,}},}
template<class S>
struct enum_table<PANOCStopCrit, S>

Public Types

using type = PANOCStopCrit
using type = PANOCStopCrit
using type = PANOCStopCrit

Public Static Attributes

static const enum_table_t<type, S> table = {{"ApproxKKT", {type::ApproxKKT,}}, {"ApproxKKT2", {type::ApproxKKT2,}}, {"ProjGradNorm", {type::ProjGradNorm,}}, {"ProjGradNorm2", {type::ProjGradNorm2,}}, {"ProjGradUnitNorm", {type::ProjGradUnitNorm,}}, {"ProjGradUnitNorm2", {type::ProjGradUnitNorm2,}}, {"FPRNorm", {type::FPRNorm,}}, {"FPRNorm2", {type::FPRNorm2,}},}
struct invalid_json_param : public invalid_argument
#include <alpaqa/params/json.hpp>

Custom parameter parsing exception.

Public Members

std::vector<std::string> backtrace
struct invalid_param : public invalid_argument
#include <alpaqa/params/params.hpp>

Custom parameter parsing exception.

struct MemberGetter
#include </home/runner/work/alpaqa/alpaqa/src/alpaqa/src/driver/param-complete.hpp>

Public Members

std::string_view full_key

Full key string, used for diagnostics.

std::string_view key

The subkey to resolve next.

std::optional<std::string_view> value

The value of the parameter to store.

struct ParamString
#include <alpaqa/params/params.hpp>

Represents a parameter value encoded as a string in the format abc.def.key=value.

Public Members

std::string_view full_key

Full key string, used for diagnostics.

std::string_view key

The subkey to resolve next.

std::string_view value

The value of the parameter to store.

struct Result
#include </home/runner/work/alpaqa/alpaqa/src/alpaqa/src/driver/param-complete.hpp>

Public Members

bool leaf
std::string_view prefix
std::vector<Member> members
struct Member
#include </home/runner/work/alpaqa/alpaqa/src/alpaqa/src/driver/param-complete.hpp>

Public Members

std::string_view name
std::optional<std::string_view> doc = std::nullopt
std::optional<char> suffix = std::nullopt
struct RootOpts

Public Members

Value method
Value out
Value sol
Value x0
Value mul_g0
Value mul_x0
Value num_exp
bool extra_stats
bool show_funcs
Struct problem
guanaqo::DynamicLoadFlags dl_flags
struct Struct
struct Value
template<Config Conf>
struct vec_from_file
#include <alpaqa/params/vec-from-file.hpp>

Public Members

length_t expected_size
std::optional<vec> value = std::nullopt
namespace sets

Functions

template<Config Conf>
Conf::real_t guanaqo_tag_invoke(tag_t<alpaqa::prox>, Box<Conf> &self, typename Conf::crmat in, typename Conf::rmat out, typename Conf::real_t γ)
template<Config Conf>
Conf::real_t guanaqo_tag_invoke(tag_t<alpaqa::prox_step>, Box<Conf> &self, typename Conf::crmat in, typename Conf::crmat fwd_step, typename Conf::rmat out, typename Conf::rmat fb_step, typename Conf::real_t γ, typename Conf::real_t γ_fwd)
template<Config Conf>
inline auto project(const auto &v, const Box<Conf> &box)

Project a vector onto a box.

\[ \Pi_C(v) \]

Parameters:
  • v – [in] The vector to project

  • box – [in] The box to project onto

template<Config Conf>
inline auto projecting_difference(const auto &v, const Box<Conf> &box)

Get the difference between the given vector and its projection.

\[ v - \Pi_C(v) \]

Warning

Beware catastrophic cancellation!

Parameters:
  • v – [in] The vector to project

  • box – [in] The box to project onto

template<Config Conf>
inline auto dist_squared(const auto &v, const Box<Conf> &box)

Get the distance squared between the given vector and its projection.

\[ \left\| v - \Pi_C(v) \right\|_2^2 \]

Warning

Beware catastrophic cancellation!

Parameters:
  • v – [in] The vector to project

  • box – [in] The box to project onto

template<Config Conf>
inline real_t<Conf> dist_squared(const auto &v, const Box<Conf> &box, const auto &Σ)

Get the distance squared between the given vector and its projection in the Σ norm.

\[ \left\| v - \Pi_C(v) \right\|_\Sigma^2 = \left(v - \Pi_C(v)\right)^\top \Sigma \left(v - \Pi_C(v)\right) \]

Warning

Beware catastrophic cancellation!

Parameters:
  • v – [in] The vector to project

  • box – [in] The box to project onto

  • Σ – [in] Diagonal matrix defining norm

template<Config Conf = DefaultConfig>
struct Box
#include <alpaqa/problem/box.hpp>

Public Functions

inline Box()
inline Box(length_t n)

Public Members

vec lower
vec upper

Public Static Functions

static inline Box NaN(length_t n)
static inline Box from_lower_upper(vec lower, vec upper)
namespace sparsity
template<Config Conf, class To>
struct ConvertingEvaluator
#include <alpaqa/problem/sparsity-conversions.hpp>

Public Functions

inline ConvertingEvaluator(const Sparsity &sp)
template<class E>
inline rvec eval(E &&evaluator)

Public Members

SparsityConverter<Sparsity, To> converter
vec values
vec work
template<Config Conf>
struct DenseEvaluator
#include <alpaqa/problem/sparsity-conversions.hpp>

Public Functions

inline DenseEvaluator(const Sparsity &sp)
template<class E>
inline rmat eval(E &&evaluator)

Public Members

ConvertingEvaluator<Conf, Dense> converter
namespace util

Functions

template<class V>
void check_dim_msg(const V &v, auto sz, std::string msg)
template<class V>
void check_dim_msg(std::optional<V> &v, auto sz, std::string msg)
template<class V>
void check_dim(std::string name, V &&v, auto sz)
template<class M>
void check_dim_msg(const M &m, auto rows, auto cols, std::string msg)
template<class M>
void check_dim(std::string name, M &&m, auto rows, auto cols)
template<class SpMat, class Mat, class MaskVec>
void sparse_add_masked(const SpMat &R_full, Mat &&R, const MaskVec &mask)

R += R_full(mask,mask)

template<class SpMat, class Mat, class MaskVec>
void sparse_add_masked_rows(const SpMat &S_full, Mat &&S, const MaskVec &mask)

S += S_full(mask,:)

template<class SpMat, class CVec, class Vec, class MaskVec>
void sparse_matvec_add_masked_rows_cols(const SpMat &R, const CVec &v, Vec &&out, const MaskVec &mask_J, const MaskVec &mask_K)

out += R(mask_J,mask_K) * v(mask_K);

template<class SpMat, class CVec, class Vec, class MaskVec>
void sparse_matvec_add_transpose_masked_rows(const SpMat &S, const CVec &v, Vec &&out, const MaskVec &mask)

out += S(mask,:)ᵀ * v(mask);

namespace detail

Functions

template<class SpMat, class MaskVec>
auto select_rows_in_col(const SpMat &sp_mat, MaskVec &mask, auto column)

Returns a range over the row indices in the given column of sp_mat that are also in mask.

The range consists of the full Eigen InnerIterators (row, column, value).

template<class SpMat, class MaskVec>
auto select_rows_in_col_iota(const SpMat &sp_mat, MaskVec &mask, auto column)

Like select_rows_in_col, but returns a range of tuples containing the Eigen InnerIterator and a linear index into the mask.

namespace vec_util

Functions

template<class Derived>
auto norm_inf(const Eigen::MatrixBase<Derived> &v)

Get the maximum or infinity-norm of the given vector.

Returns:

\( \left\|v\right\|_\infty \)

template<class Derived>
auto norm_1(const Eigen::MatrixBase<Derived> &v)

Get the 1-norm of the given vector.

Returns:

\( \left\|v\right\|_1 \)