C++ API Reference#
Note
The Doxygen documentation of the C++ API is often more readable.
-
namespace alpaqa#
Typedefs
-
template<Config Conf = DefaultConfig>
using real_t = typename Conf::real_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 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#
-
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 \).
-
enumerator BasedOnCurvature#
Initial inverse Hessian approximation is set to \( H_0 = \frac{s^\top y}{y^\top y} I \).
-
enumerator BasedOnGradientStepSize#
-
enumerator BasedOnExternalStepSize#
-
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 \]
-
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), \]\[\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}\]\[\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}\]\[ s_d \triangleq \max\left\{ s_\text{max},\;\frac{\|\hat y^k\|_1 + \|w^k\|_1}{2m + 2n} \right\} / s_\text{max}, \]
-
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\}} \]
-
enumerator ApproxKKT#
-
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.
-
enumerator Busy#
Functions
- template<Config Conf = DefaultConfig> inline void minimize_update_anderson (LimitedMemoryQR< Conf > &qr, rmat< Conf > G̃, 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̃ – [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 constexpr 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<ZeroFPRStats<Conf>> &operator+=(InnerStatsAccumulator<ZeroFPRStats<Conf>> &acc, const ZeroFPRStats<Conf> &s)#
-
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 auto dist_squared (const auto &v, const Box< Conf > &box, const auto &Σ) -> real_t< Conf >
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>
KKTError<Conf> compute_kkt_error(const alpaqa::TypeErasedProblem<Conf> &problem, alpaqa::crvec<Conf> x, alpaqa::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 messagemsg
.
-
inline void check_finiteness(const std::floating_point auto &v, std::string_view msg)#
-
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 Problem>
auto problem_with_counters(Problem &&p)# Wraps the given problem into a ProblemWithCounters and keeps track of how many times each function is called, and how long these calls took.
The wrapper has its own copy of the given problem. Making copies of the wrapper also copies the underlying problem, but does not copy the evaluation counters, all copies share the same counters.
-
template<class Problem>
auto problem_with_counters_ref(Problem &p)# Wraps the given problem into a ProblemWithCounters and keeps track of how many times each function is called, and how long these calls took.
The wrapper keeps only a reference to the given problem, it is the responsibility of the caller to make sure that the wrapper does not outlive the original problem. Making copies of the wrapper does not copy the evaluation counters, all copies share the same counters.
-
template<Config Conf>
void print_provided_functions(std::ostream &os, const TypeErasedProblem<Conf> &problem)#
-
template<std::floating_point F>
std::string float_to_str(F value, int precision = std::numeric_limits<F>::max_digits10)#
-
template<class T>
std::ostream &print_csv_impl(std::ostream &os, const T &M, std::string_view sep = ",", std::string_view begin = "", std::string_view end = "\n")#
-
template<class T>
std::ostream &print_matlab_impl(std::ostream &os, const T &M, std::string_view end = ";\n")#
-
template<class T>
std::ostream &print_python_impl(std::ostream &os, const T &M, std::string_view end = "\n")#
-
inline std::ostream &print_csv(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<float>> &M, std::string_view sep, std::string_view begin, std::string_view end)#
-
inline std::ostream &print_csv(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<float>> &M, std::string_view sep, std::string_view begin)#
-
inline std::ostream &print_csv(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<float>> &M, std::string_view sep)#
-
inline std::ostream &print_csv(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<float>> &M)#
-
inline std::ostream &print_matlab(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<float>> &M, std::string_view end)#
-
inline std::ostream &print_matlab(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<float>> &M)#
-
inline std::ostream &print_python(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<float>> &M, std::string_view end)#
-
inline std::ostream &print_python(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<float>> &M)#
-
inline std::ostream &print_csv(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<double>> &M, std::string_view sep, std::string_view begin, std::string_view end)#
-
inline std::ostream &print_csv(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<double>> &M, std::string_view sep, std::string_view begin)#
-
inline std::ostream &print_csv(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<double>> &M, std::string_view sep)#
-
inline std::ostream &print_csv(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<double>> &M)#
-
inline std::ostream &print_matlab(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<double>> &M, std::string_view end)#
-
inline std::ostream &print_matlab(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<double>> &M)#
-
inline std::ostream &print_python(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<double>> &M, std::string_view end)#
-
inline std::ostream &print_python(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<double>> &M)#
-
inline std::ostream &print_csv(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<long double>> &M, std::string_view sep, std::string_view begin, std::string_view end)#
-
inline std::ostream &print_csv(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<long double>> &M, std::string_view sep, std::string_view begin)#
-
inline std::ostream &print_csv(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<long double>> &M, std::string_view sep)#
-
inline std::ostream &print_csv(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<long double>> &M)#
-
inline std::ostream &print_matlab(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<long double>> &M, std::string_view end)#
-
inline std::ostream &print_matlab(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<long double>> &M)#
-
inline std::ostream &print_python(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<long double>> &M, std::string_view end)#
-
inline std::ostream &print_python(std::ostream &os, const Eigen::Ref<const Eigen::MatrixX<long double>> &M)#
-
std::ostream &operator<<(std::ostream &os, SolverStatus s)#
-
const char *enum_name(CUTEstProblem::Report::Status s)#
-
std::ostream &operator<<(std::ostream &os, CUTEstProblem::Report::Status s)#
-
std::ostream &operator<<(std::ostream &os, const CUTEstProblem::Report &r)#
-
template<class Func>
void register_function(function_dict_t *&extra_functions, std::string name, Func &&func)# Make the given function available to alpaqa.
-
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 of signature into a lambda function that accepts the instance as a void pointer.
Ret Class::member(args...)
→Ret(void *self, args...)
Ret Class::member(args...) const
→Ret(const void *self, args...)
Type Class::member
→Type &(void *self)
Type Class::member
→const 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)#
Variables
-
template<Config Conf>
const rvec<Conf> null_vec = mvec<Conf>{nullptr, 0}# Global empty vector for convenience.
-
template<class T>
constexpr bool is_complex_float_v = is_complex_float<T>::value#
-
template<>
class CASADI_OCP_LOADER_EXPORT CasADiControlProblem<EigenConfigd>#
-
template<>
class CASADI_OCP_LOADER_EXPORT CasADiControlProblem<DefaultConfig>#
-
template<Config Conf = DefaultConfig>
struct ALMParams# - #include <alpaqa/include/alpaqa/outer/alm.hpp>
Parameters for the Augmented Lagrangian solver.
Public Members
-
real_t penalty_update_factor_lower = real_t(0.8)#
Factor to reduce penalty_update_factor when inner convergence fails.
-
real_t min_penalty_update_factor = real_t(1.1)#
Minimum value for penalty_update_factor after reduction because of inner convergence failure.
-
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_penalty_lower = real_t(0.6)#
Factor to reduce the initial penalty factor by if convergence fails in in the first iteration.
-
real_t initial_tolerance_increase = real_t(1.1)#
Factor to increase the initial primal tolerance if convergence fails in the first iteration.
- real_t ρ_increase = real_t(2)
Factor to increase the primal tolerance update factor by if convergence fails.
- real_t ρ_max = real_t(0.5)
Maximum value of tolerance_update_factor after increase because of inner convergence failure.
-
unsigned int max_iter = 100#
Maximum number of outer ALM iterations.
-
std::chrono::nanoseconds max_time = std::chrono::minutes(5)#
Maximum duration.
-
unsigned max_num_initial_retries = 0#
How many times can the initial penalty initial_penalty or initial_penalty_factor and the initial primal tolerance initial_tolerance be reduced.
-
unsigned max_num_retries = 0#
How many times can the penalty update factor penalty_update_factor and the primal tolerance factor tolerance_update_factor be reduced.
-
unsigned max_total_num_retries = 0#
Combined limit for max_num_initial_retries and max_num_retries.
-
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.
-
real_t penalty_update_factor_lower = real_t(0.8)#
-
template<class InnerSolverT>
class ALMSolver# - #include <alpaqa/include/alpaqa/outer/alm.hpp>
Augmented Lagrangian Method solver.
Public Functions
-
inline ALMSolver(Params params, InnerSolver &&inner_solver)#
-
inline ALMSolver(Params params, const InnerSolver &inner_solver)#
-
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.
-
struct Stats#
- #include <alpaqa/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 initial_penalty_reduced = 0#
The number of times that the initial penalty factor was reduced by ALMParams::initial_penalty_lower and that the initial tolerance was increased by ALMParams::initial_tolerance_increase because the inner solver failed to converge in the first ALM iteration.
If this number is greater than zero, consider lowering the initial penalty factor ALMParams::initial_penalty or ALMParams::initial_penalty_factor or increasing the initial tolerance ALMParams::initial_tolerance (or both).
-
unsigned penalty_reduced = 0#
The number of times that the penalty update factor ALMParams::penalty_update_factor was reduced, that the tolerance update factor ALMParams::tolerance_update_factor was increased, and that an ALM iteration had to be restarted with a lower penalty factor and a higher tolerance because the inner solver failed to converge (not applicable in the first ALM iteration).
If this number is greater than zero, consider lowerering the penalty update factor ALMParams::penalty_update_factor or increasing the tolerance update factor (or both). Lowering the initial penalty factor could help as well.
-
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 \]
-
SolverStatus status = SolverStatus::Busy#
Whether the solver converged or not.
See also
-
InnerStatsAccumulator<typename InnerSolver::Stats> inner#
The statistics of the inner solver invocations, accumulated over all ALM iterations.
-
unsigned outer_iterations = 0#
-
inline ALMSolver(Params params, InnerSolver &&inner_solver)#
-
template<Config Conf = DefaultConfig>
class AndersonAccel# - #include <alpaqa/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, 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 std::string get_name() const#
-
using Params = AndersonAccelParams<config_t>#
-
template<Config Conf = DefaultConfig>
struct AndersonAccelParams# - #include <alpaqa/include/alpaqa/accelerators/anderson.hpp>
Parameters for the AndersonAccel class.
-
template<Config Conf>
struct AndersonDirection# - #include <alpaqa/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 typename AndersonAccel::Params ¶ms, 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
-
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
- inline bool apply (real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const
See also
- inline void changed_γ (real_t γₖ, real_t old_γₖ)
See also
-
inline void reset()#
See also
-
inline std::string get_name() const#
See also
-
inline auto get_params() const#
-
struct Params#
- #include <alpaqa/include/alpaqa/inner/directions/panoc/anderson.hpp>
-
using Problem = TypeErasedProblem<config_t>#
-
template<Config Conf>
struct AndersonDirectionParams# - #include <alpaqa/include/alpaqa/inner/directions/panoc/anderson.hpp>
Parameters for the AndersonDirection class.
Public Members
-
bool rescale_on_step_size_changes = false#
-
bool rescale_on_step_size_changes = false#
-
class AtomicStopSignal#
- #include <alpaqa/include/alpaqa/util/atomic-stop-signal.hpp>
Public Functions
-
AtomicStopSignal() = default#
-
inline AtomicStopSignal(const AtomicStopSignal&)#
-
AtomicStopSignal &operator=(const AtomicStopSignal&) = delete#
-
inline AtomicStopSignal(AtomicStopSignal&&)#
-
inline AtomicStopSignal &operator=(AtomicStopSignal&&)#
-
inline void stop()#
-
inline bool stop_requested() const#
-
AtomicStopSignal() = default#
-
template<Config Conf = DefaultConfig>
struct Box# - #include <alpaqa/include/alpaqa/problem/box.hpp>
-
template<Config Conf>
class BoxConstrProblem# - #include <alpaqa/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.
Subclassed by CasADiProblem< Conf >, FunctionalProblem< Conf >
Public Functions
-
inline BoxConstrProblem(length_t n, length_t m)#
- Parameters:
n – Number of decision variables
m – Number of constraints
-
BoxConstrProblem(const BoxConstrProblem&) = default#
-
BoxConstrProblem &operator=(const BoxConstrProblem&) = default#
-
BoxConstrProblem(BoxConstrProblem&&) noexcept = default#
-
BoxConstrProblem &operator=(BoxConstrProblem&&) noexcept = default#
- inline real_t eval_prox_grad_step (real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) const
- inline index_t eval_inactive_indices_res_lna (real_t γ, crvec x, crvec grad_ψ, rindexvec J) const
-
inline void check() const#
See also
Public Members
-
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̂, 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̂, 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̂, 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̂, 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}\]
-
inline BoxConstrProblem(length_t n, length_t m)#
-
template<Config Conf>
class CasADiControlProblem# - #include <interop/casadi/include/alpaqa/casadi/CasADiControlProblem.hpp>
Public Functions
-
~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:
U lower bound [nu]
U upper bound [nu]
D lower bound [nc]
D upper bound [nc]
D_N lower bound [nc_N]
D_N upper bound [nc_N]
x_init [nx]
param [p]
Line endings are encoded using a single line feed (
\n
), and the column separator can be specified using thesep
argument.
-
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#
-
inline void check() const#
Public Members
-
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.
-
~CasADiControlProblem()#
-
template<Config Conf = DefaultConfig>
class CasADiProblem : public alpaqa::BoxConstrProblem<DefaultConfig># - #include <interop/casadi/include/alpaqa/casadi/CasADiProblem.hpp>
Problem definition for a CasADi problem, loaded from a DLL.
Public Functions
-
CasADiProblem(const std::string &filename)#
Load a problem generated by CasADi (with parameters).
The file should contain functions with the names
f
,grad_f
,g
andgrad_g
. These functions evaluate the objective function, its gradient, the constraints, and the constraint gradient times a vector respectively. For second order solvers, additional functionshess_L
,hess_ψ
,hess_L_prod
andhess_ψ_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.
- Throws:
std::invalid_argument – The dimensions of the loaded functions do not match.
-
~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:
C lower bound [n]
C upper bound [n]
D lower bound [m]
D upper bound [m]
param [p]
l1_reg [0, 1 or n]
Line endings are encoded using a single line feed (
\n
), and the column separator can be specified using thesep
argument.
- void eval_grad_ψ (crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
- real_t eval_ψ_grad_ψ (crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
- real_t eval_ψ (crvec x, crvec y, crvec Σ, rvec ŷ) const
-
void eval_hess_L(crvec x, crvec y, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const#
- void eval_hess_ψ_prod (crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
- length_t get_hess_ψ_num_nonzeros () const
- void eval_hess_ψ (crvec x, crvec y, crvec Σ, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const
-
bool provides_eval_grad_gi() const#
-
bool provides_eval_jac_g() const#
-
bool provides_eval_hess_L_prod() const#
-
bool provides_eval_hess_L() const#
- bool provides_eval_hess_ψ_prod () const
- bool provides_eval_hess_ψ () const
-
CasADiProblem(const std::string &filename)#
-
template<Config Conf = DefaultConfig>
struct CBFGSParams# - #include <alpaqa/include/alpaqa/accelerators/lbfgs.hpp>
Cautious BFGS update.
See also
Public Functions
-
inline explicit operator bool() const#
Public Members
- real_t α = 1
- real_t ϵ = 0
Set to zero to disable CBFGS check.
-
inline explicit operator bool() const#
-
template<class IndexT = size_t>
struct CircularIndexIterator# - #include <alpaqa/include/alpaqa/util/ringbuffer.hpp>
Public Types
-
using Indices = CircularIndices<Index>#
-
using reference = value_type#
-
using difference_type = std::ptrdiff_t#
-
using pointer = void#
-
using iterator_category = std::input_iterator_tag#
Public Functions
-
inline CircularIndexIterator()#
-
inline CircularIndexIterator &operator++()#
-
inline CircularIndexIterator &operator--()#
-
inline CircularIndexIterator operator++(int)#
-
inline CircularIndexIterator operator--(int)#
-
template<class IndexT>
bool operator==(CircularIndexIterator<IndexT> a, CircularIndexIterator<IndexT> b)# Note
Only valid for two indices in the same range.
-
template<class IndexT>
bool operator!=(CircularIndexIterator<IndexT> a, CircularIndexIterator<IndexT> b)# Note
Only valid for two indices in the same range.
-
using Indices = CircularIndices<Index>#
-
template<class IndexT = size_t>
struct CircularIndices# - #include <alpaqa/include/alpaqa/util/ringbuffer.hpp>
-
template<class IndexT>
bool operator==(CircularIndices<IndexT> a, CircularIndices<IndexT> b)# Note
Only valid for two indices in the same range.
-
template<class IndexT>
bool operator!=(CircularIndices<IndexT> a, CircularIndices<IndexT> b)# Note
Only valid for two indices in the same range.
-
template<class IndexT>
-
template<class IndexT>
class CircularRange# - #include <alpaqa/include/alpaqa/util/ringbuffer.hpp>
Public Types
-
using Indices = CircularIndices<Index>#
-
using const_iterator = CircularIndexIterator<Index>#
-
using iterator = const_iterator#
-
using const_reverse_iterator = ReverseCircularIndexIterator<Index>#
-
using reverse_iterator = const_reverse_iterator#
Public Functions
-
inline const_iterator cbegin() const#
-
inline const_iterator cend() const#
-
inline reverse_iterator rbegin() const#
-
inline reverse_iterator rend() const#
-
inline const_reverse_iterator crbegin() const#
-
inline const_reverse_iterator crend() const#
-
using Indices = CircularIndices<Index>#
-
template<Config Conf>
struct ControlProblemVTable : public BasicVTable# - #include <alpaqa/include/alpaqa/problem/ocproblem.hpp>
Public Types
-
template<class F>
using optional_function_t = util::BasicVTable::optional_function_t<F, ControlProblemVTable>#
-
template<class F>
using optional_const_function_t = util::BasicVTable::optional_const_function_t<F, ControlProblemVTable>#
Public Functions
-
ControlProblemVTable() = default#
Public Members
-
optional_const_function_t<void(Box &D)> get_D = nullptr#
-
optional_const_function_t<void(Box &D)> get_D_N = &default_get_D_N#
-
required_const_function_t<void(index_t timestep, crvec x, crvec u, crvec p, rvec grad_fxu_p)> eval_grad_f_prod#
-
optional_const_function_t<void(crvec x, rvec h)> eval_h_N = nullptr#
-
optional_const_function_t<void(crvec x, crvec h, rmat Q)> eval_add_Q_N = &default_eval_add_Q_N#
-
required_const_function_t<void(index_t timestep, crvec xu, crvec h, crindexvec mask, rmat R, rvec work)> eval_add_R_masked#
-
required_const_function_t<void(index_t timestep, crvec xu, crvec h, crindexvec mask, rmat S, rvec work)> eval_add_S_masked#
-
optional_const_function_t<void(index_t timestep, crvec xu, crvec h, crindexvec mask_J, crindexvec mask_K, crvec v, rvec out, rvec work)> eval_add_R_prod_masked = &default_eval_add_R_prod_masked#
-
optional_const_function_t<void(index_t timestep, crvec xu, crvec h, crindexvec mask_K, crvec v, rvec out, rvec work)> eval_add_S_prod_masked = &default_eval_add_S_prod_masked#
-
optional_const_function_t<length_t()> get_R_work_size = &default_get_R_work_size#
-
optional_const_function_t<length_t()> get_S_work_size = &default_get_S_work_size#
-
optional_const_function_t<void(index_t timestep, crvec x, rvec c)> eval_constr = nullptr#
-
optional_const_function_t<void(crvec x, rvec c)> eval_constr_N = &default_eval_constr_N#
-
optional_const_function_t<void(index_t timestep, crvec x, crvec p, rvec grad_cx_p)> eval_grad_constr_prod = nullptr#
-
optional_const_function_t<void(crvec x, crvec p, rvec grad_cx_p)> eval_grad_constr_prod_N = &default_eval_grad_constr_prod_N#
-
optional_const_function_t<void(index_t timestep, crvec x, crvec M, rmat out)> eval_add_gn_hess_constr = nullptr#
-
optional_const_function_t<void(crvec x, crvec M, rmat out)> eval_add_gn_hess_constr_N = &default_eval_add_gn_hess_constr_N#
-
required_const_function_t<void()> check#
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 F>
-
template<class Problem>
struct ControlProblemWithCounters# - #include <alpaqa/include/alpaqa/problem/ocproblem.hpp>
Public Types
-
using Box = typename TypeErasedControlProblem<config_t>::Box#
Public Functions
-
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 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#
-
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>()#
-
using Box = typename TypeErasedControlProblem<config_t>::Box#
-
class CUTEstLoader#
Public Types
-
using logical_vec = Eigen::VectorX<logical>#
Pointers to loaded problem functions.
Public Functions
-
inline CUTEstLoader(const char *so_fname, const char *outsdif_fname)#
-
inline std::string get_name()#
-
inline integer get_report(doublereal *calls, doublereal *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
-
struct ConstrFuncs#
Public Members
-
decltype(CUTEST_cfn) *cfn#
-
decltype(CUTEST_cofg) *cofg#
-
decltype(CUTEST_ccfg) *ccfg#
-
decltype(CUTEST_clfg) *clfg#
-
decltype(CUTEST_cjprod) *cjprod#
-
decltype(CUTEST_ccifg) *ccifg#
-
decltype(CUTEST_cigr) *cigr#
-
decltype(CUTEST_cdimsj) *cdimsj#
-
decltype(FUNDERSCORE(cutest_csjp)) *csjp#
-
decltype(CUTEST_ccfsg) *ccfsg#
-
decltype(CUTEST_cdh) *cdh#
-
decltype(CUTEST_cdimsh) *cdimsh#
-
decltype(CUTEST_cshp) *cshp#
-
decltype(CUTEST_csh) *csh#
-
decltype(CUTEST_chprod) *chprod#
-
decltype(CUTEST_cfn) *cfn#
-
using logical_vec = Eigen::VectorX<logical>#
-
class CUTEstProblem : public BoxConstrProblem<alpaqa::DefaultConfig>#
- #include <interop/cutest/include/alpaqa/cutest/cutest-loader.hpp>
Wrapper for CUTEst problems loaded from an external shared library.
Warning
The lifetime of the wrapper should be at least as long as the lifetime of the CUTEstProblem::problem member. Do not make a copy of the problem that could outlive the wrapper.
Public Functions
-
CUTEstProblem(const char *so_fname, const char *outsdif_fname, bool sparse = false)#
Load a CUTEst problem from the given shared library and OUTSDIF.d file.
-
CUTEstProblem(const CUTEstProblem&)#
-
CUTEstProblem &operator=(const CUTEstProblem&)#
-
CUTEstProblem(CUTEstProblem&&) noexcept#
-
CUTEstProblem &operator=(CUTEstProblem&&) noexcept#
-
~CUTEstProblem()#
Public Members
-
std::string name = "<UNKNOWN>"#
Problem name.
-
struct Report#
- #include <interop/cutest/include/alpaqa/cutest/cutest-loader.hpp>
The report generated by CUTEst.
See also
man CUTEST_creport
andman CUTEST_ureport
Public Types
Public Members
-
std::string name#
Name of the problem.
-
int nvar = 0#
Number of independent variables.
-
int ncon = 0#
Number of constraints.
-
struct alpaqa::CUTEstProblem::Report::[anonymous] calls#
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. 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.
-
std::ostream &operator<<(std::ostream&, const CUTEstProblem::Report&)#
-
std::string name#
- Report.calls
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#
Number of calls to the objective function.
-
unsigned objective_grad#
Number of calls to the objective gradient.
-
unsigned objective_hess#
Number of calls to the objective Hessian.
-
unsigned hessian_times_vector#
Number of Hessian times vector products.
-
unsigned constraints#
Number of calls to the constraint functions.
-
unsigned constraints_grad#
Number of calls to the constraint gradients.
-
unsigned constraints_hess#
Number of calls to the constraint Hessians.
-
unsigned objective#
-
CUTEstProblem(const char *so_fname, const char *outsdif_fname, bool sparse = false)#
-
struct DefaultConfig : public EigenConfigd#
- #include <alpaqa/include/alpaqa/config/config.hpp>
-
template<Config Conf>
struct Dim# - #include <alpaqa/include/alpaqa/inner/directions/panoc-ocp/lqr.hpp>
-
struct Horizon#
- #include <alpaqa/include/alpaqa/inner/directions/panoc-ocp/lqr.hpp>
-
struct Horizon#
-
template<class RealT>
struct EigenConfig# - #include <alpaqa/include/alpaqa/config/config.hpp>
-
struct EigenConfigd : public EigenConfig<double>#
- #include <alpaqa/include/alpaqa/config/config.hpp>
Double-precision
double
configuration.Subclassed by DefaultConfig
Public Static Functions
-
static inline constexpr const char *get_name()#
-
static inline constexpr const char *get_name()#
-
struct EigenConfigf : public EigenConfig<float>#
- #include <alpaqa/include/alpaqa/config/config.hpp>
Single-precision
float
configuration.Public Static Functions
-
static inline constexpr const char *get_name()#
-
static inline constexpr const char *get_name()#
-
struct EigenConfigl : public EigenConfig<long double>#
- #include <alpaqa/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 constexpr const char *get_name()#
-
static inline constexpr const char *get_name()#
-
struct EvalCounter#
- #include <alpaqa/include/alpaqa/problem/problem-counters.hpp>
Public Functions
-
inline void reset()#
Public Members
-
unsigned proj_diff_g = {}#
-
unsigned proj_multipliers = {}#
-
unsigned prox_grad_step = {}#
-
unsigned inactive_indices_res_lna = {}#
-
unsigned f = {}#
-
unsigned grad_f = {}#
-
unsigned f_grad_f = {}#
-
unsigned f_g = {}#
-
unsigned grad_f_grad_g_prod = {}#
-
unsigned g = {}#
-
unsigned grad_g_prod = {}#
-
unsigned grad_gi = {}#
-
unsigned jac_g = {}#
-
unsigned grad_L = {}#
-
unsigned hess_L_prod = {}#
-
unsigned hess_L = {}#
- unsigned hess_ψ_prod = {}
- unsigned hess_ψ = {}
- unsigned ψ = {}
- unsigned grad_ψ = {}
- unsigned ψ_grad_ψ = {}
-
struct alpaqa::EvalCounter::EvalTimer time#
-
struct EvalTimer#
- #include <alpaqa/include/alpaqa/problem/problem-counters.hpp>
Public Members
-
std::chrono::nanoseconds proj_diff_g = {}#
-
std::chrono::nanoseconds proj_multipliers = {}#
-
std::chrono::nanoseconds prox_grad_step = {}#
-
std::chrono::nanoseconds inactive_indices_res_lna = {}#
-
std::chrono::nanoseconds f = {}#
-
std::chrono::nanoseconds grad_f = {}#
-
std::chrono::nanoseconds f_grad_f = {}#
-
std::chrono::nanoseconds f_g = {}#
-
std::chrono::nanoseconds grad_f_grad_g_prod = {}#
-
std::chrono::nanoseconds g = {}#
-
std::chrono::nanoseconds grad_g_prod = {}#
-
std::chrono::nanoseconds grad_gi = {}#
-
std::chrono::nanoseconds jac_g = {}#
-
std::chrono::nanoseconds grad_L = {}#
-
std::chrono::nanoseconds hess_L_prod = {}#
-
std::chrono::nanoseconds hess_L = {}#
- std::chrono::nanoseconds hess_ψ_prod = {}
- std::chrono::nanoseconds hess_ψ = {}
- std::chrono::nanoseconds ψ = {}
- std::chrono::nanoseconds grad_ψ = {}
- std::chrono::nanoseconds ψ_grad_ψ = {}
-
std::chrono::nanoseconds proj_diff_g = {}#
-
inline void reset()#
-
template<Config Conf = DefaultConfig>
class FunctionalProblem : public alpaqa::BoxConstrProblem<DefaultConfig># - #include <alpaqa/include/alpaqa/problem/functional-problem.hpp>
Problem class that allows specifying the basic functions as C++
std::function
s.Public Functions
- inline void eval_hess_ψ_prod (crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
- inline void eval_hess_ψ (crvec x, crvec y, crvec Σ, real_t scale, rindexvec, rindexvec, rvec H_values) const
-
inline bool provides_eval_grad_gi() const#
-
inline bool provides_eval_jac_g() const#
-
inline bool provides_eval_hess_L_prod() const#
-
inline bool provides_eval_hess_L() const#
- inline bool provides_eval_hess_ψ_prod () const
- inline bool provides_eval_hess_ψ () const
-
FunctionalProblem(const FunctionalProblem&) = default#
-
FunctionalProblem &operator=(const FunctionalProblem&) = default#
-
FunctionalProblem(FunctionalProblem&&) noexcept = default#
-
FunctionalProblem &operator=(FunctionalProblem&&) noexcept = default#
Public Members
- 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/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 TypeErasedProblem::check() before starting to solve.
-
bool always_overwrite_results = true#
-
template<class InnerSolverStats>
struct InnerStatsAccumulator#
- template<> LBFGSBStats >
- #include <interop/lbfgsb/include/alpaqa/lbfgsb/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) \).
-
unsigned lbfgs_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).
-
std::chrono::nanoseconds elapsed_time = {}#
- template<Config Conf> LBFGSBStats< Conf > >
- #include <interop/lbfgspp/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) \).
-
std::chrono::nanoseconds elapsed_time = {}
-
template<Config Conf>
struct InnerStatsAccumulator<PANOCOCPStats<Conf>># - #include <alpaqa/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 lbfgs_failures = 0#
Total number of times that the L-BFGS direction was not finite.
-
unsigned lbfgs_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_φγ = 0
Final value of the forward-backward envelope, \( \varphi_\gamma(x) \) (note that this is in the point \( x \), not \( \hat x \)).
-
std::chrono::nanoseconds elapsed_time = {}#
-
template<Config Conf>
struct InnerStatsAccumulator<PANOCStats<Conf>># - #include <alpaqa/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 lbfgs_failures = 0#
Total number of times that the L-BFGS direction was not finite.
-
unsigned lbfgs_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_φγ = 0
Final value of the forward-backward envelope, \( \varphi_\gamma(x) \) (note that this is in the point \( x \), not \( \hat x \)).
-
std::chrono::nanoseconds elapsed_time = {}#
-
template<Config Conf>
struct InnerStatsAccumulator<PANTRStats<Conf>># - #include <alpaqa/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_φγ = 0
Final value of the forward-backward envelope, \( \varphi_\gamma(x) \) (note that this is in the point \( x \), not \( \hat x \)).
-
std::chrono::nanoseconds elapsed_time = {}#
-
template<Config Conf>
struct InnerStatsAccumulator<ZeroFPRStats<Conf>># - #include <alpaqa/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 lbfgs_failures = 0#
Total number of times that the L-BFGS direction was not finite.
-
unsigned lbfgs_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_φγ = 0
Final value of the forward-backward envelope, \( \varphi_\gamma(x) \) (note that this is in the point \( x \), not \( \hat x \)).
-
std::chrono::nanoseconds elapsed_time = {}#
-
class IpoptAdapter : public TNLP#
- #include <interop/ipopt/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_jac_g(Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values) override#
Public Types
-
using Problem = TypeErasedProblem<config_t>#
-
using Index = Ipopt::Index#
-
using Number = Ipopt::Number#
Public Members
-
struct alpaqa::IpoptAdapter::Results results#
-
struct Results#
- #include <interop/ipopt/include/alpaqa/ipopt/ipopt-adapter.hpp>
-
bool get_nlp_info(Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style) override#
-
template<typename T>
struct is_complex_float : public false_type# - #include <alpaqa/include/alpaqa/util/float.hpp>
- template<std::floating_point T> complex< T > > : public true_type
- #include <alpaqa/include/alpaqa/util/float.hpp>
-
template<class T>
struct is_config : public false_type# - #include <alpaqa/include/alpaqa/config/config.hpp>
-
template<>
struct is_config<DefaultConfig> : public true_type# - #include <alpaqa/include/alpaqa/config/config.hpp>
-
template<>
struct is_config<EigenConfigd> : public true_type# - #include <alpaqa/include/alpaqa/config/config.hpp>
-
template<>
struct is_config<EigenConfigf> : public true_type# - #include <alpaqa/include/alpaqa/config/config.hpp>
-
template<>
struct is_config<EigenConfigl> : public true_type# - #include <alpaqa/include/alpaqa/config/config.hpp>
-
template<Config Conf>
struct KKTError# - #include <alpaqa/include/alpaqa/problem/kkt-error.hpp>
Public Members
-
template<Config Conf = DefaultConfig>
class LBFGS# - #include <alpaqa/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) \)
-
enumerator Positive#
-
using Params = LBFGSParams<config_t>#
Public Functions
-
LBFGS() = default#
- 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
- 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.
-
inline std::string get_name() const#
Get a string identifier for this accelerator.
-
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 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 Static Functions
- static bool update_valid (const Params ¶ms, 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.
-
enum class Sign#
-
template<Config Conf>
struct LBFGSDirection# - #include <alpaqa/include/alpaqa/inner/directions/panoc/lbfgs.hpp>
Public Types
-
using Problem = TypeErasedProblem<config_t>#
-
using DirectionParams = LBFGSDirectionParams<config_t>#
Public Functions
-
LBFGSDirection() = default#
-
inline LBFGSDirection(const typename LBFGS::Params ¶ms, 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
-
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
- inline bool apply (real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const
See also
- inline void changed_γ (real_t γₖ, real_t old_γₖ)
See also
-
inline void reset()#
See also
-
inline std::string get_name() const#
See also
-
inline auto get_params() const#
-
struct Params#
- #include <alpaqa/include/alpaqa/inner/directions/panoc/lbfgs.hpp>
-
using Problem = TypeErasedProblem<config_t>#
-
template<Config Conf>
struct LBFGSDirectionParams# - #include <alpaqa/include/alpaqa/inner/directions/panoc/lbfgs.hpp>
Parameters for the LBFGSDirection class.
Public Members
-
bool rescale_on_step_size_changes = false#
-
bool rescale_on_step_size_changes = false#
-
template<Config Conf = DefaultConfig>
struct LBFGSParams# - #include <alpaqa/include/alpaqa/accelerators/lbfgs.hpp>
Parameters for the LBFGS class.
Public Members
-
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 \).
-
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} \).
-
CBFGSParams<config_t> cbfgs = {}#
Parameters in the cautious BFGS update condition.
\[ \frac{y^\top s}{s^\top s} \ge \epsilon \| g \|^\alpha \]
-
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#
See also
-
real_t min_div_fac = std::numeric_limits<real_t>::epsilon()#
-
template<Config Conf = DefaultConfig>
struct LBFGSStorage# - #include <alpaqa/include/alpaqa/accelerators/lbfgs.hpp>
Layout:
┌───── 2 m ─────┐ ┌ ┌───┬───┬───┬───┐ │ │ │ │ │ │ │ │ s │ y │ s │ y │ n+1 │ │ │ │ │ │ │ ├───┼───┼───┼───┤ │ │ ρ │ α │ ρ │ α │ └ └───┴───┴───┴───┘
Public Functions
- 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<Config Conf = DefaultConfig>
class LimitedMemoryQR# - #include <alpaqa/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
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 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_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 unsigned long get_reorth_count() const#
Get the number of MGS reorthogonalizations.
-
inline void clear_reorth_count()#
Reset the number of MGS reorthogonalizations.
-
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 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 CircularRange<index_t> ring_iter() const#
Get iterators in the circular buffer.
-
inline ReverseCircularRange<index_t> ring_reverse_iter() const#
Get reverse iterators in the circular buffer.
-
LimitedMemoryQR() = default#
-
template<Config Conf = DefaultConfig>
struct LipschitzEstimateParams# - #include <alpaqa/include/alpaqa/inner/internal/lipschitz.hpp>
Public Functions
-
inline void verify() const#
Public Members
- 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 [1]. \( 0 < \alpha < 1 \)
-
inline void verify() const#
-
template<class T>
class MaxHistory# - #include <alpaqa/include/alpaqa/util/max-history.hpp>
Keep track of the maximum value over a specified horizon length.
-
template<Config Conf>
struct NewtonTRDirection# - #include <alpaqa/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 AcceleratorParams ¶ms, 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
-
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
- inline real_t apply (real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, real_t radius, rvec qₖ) const
See also
- inline void changed_γ (real_t γₖ, real_t old_γₖ)
See also
-
inline void reset()#
See also
-
inline std::string get_name() const#
See also
-
inline auto get_params() const#
Public Members
-
SteihaugCG<config_t> steihaug#
-
DirectionParams direction_params#
- std::optional< crvec > Σ = std::nullopt
-
struct Params#
- #include <alpaqa/include/alpaqa/inner/directions/pantr/newton-tr.hpp>
-
using Problem = TypeErasedProblem<config_t>#
-
template<Config Conf>
struct NewtonTRDirectionParams# - #include <alpaqa/include/alpaqa/inner/directions/pantr/newton-tr.hpp>
Parameters for the NewtonTRDirection class.
-
struct not_implemented_error : public logic_error#
- #include <alpaqa/include/alpaqa/util/not-implemented.hpp>
-
template<Config Conf>
struct OCPDim# - #include <alpaqa/include/alpaqa/problem/ocproblem.hpp>
-
struct OCPEvalCounter#
- #include <alpaqa/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/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 = {}#
-
std::chrono::nanoseconds f = {}#
-
inline void reset()#
-
template<Config Conf>
struct OCPEvaluator# - #include <alpaqa/include/alpaqa/inner/directions/panoc-ocp/ocp-vars.hpp>
Public Types
-
using OCPVars = OCPVariables<config_t>#
-
using Problem = TypeErasedControlProblem<config_t>#
Public Functions
- 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 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 void Sk(crvec storage, index_t k, crindexvec mask, rmat out)#
- Post:
initialize work_S
-
inline void Rk_prod(crvec storage, index_t k, crindexvec mask_J, crindexvec mask_K, crvec v, rvec out) const#
- Pre:
initialized work_R
Public Members
- mutable vec work_λ = {vars.nx()}
-
using OCPVars = OCPVariables<config_t>#
-
template<Config Conf>
struct OCPVariables# - #include <alpaqa/include/alpaqa/inner/directions/panoc-ocp/ocp-vars.hpp>
Public Types
-
template<Config Conf>
struct PANOCDirection# - #include <alpaqa/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.
-
using Problem = TypeErasedProblem<config_t>#
-
template<Config Conf = DefaultConfig>
struct PANOCOCPParams# - #include <alpaqa/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 [1]).
\( 0 < \beta < 1 \)
-
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#
-
bool reset_lbfgs_on_gn_step = false#
-
bool lqr_factor_cholesky = true#
-
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()#
-
bool disable_acceleration = false#
-
LipschitzEstimateParams<config_t> Lipschitz#
-
template<Config Conf = DefaultConfig>
struct PANOCOCPProgressInfo# - #include <alpaqa/include/alpaqa/inner/panoc-ocp.hpp>
Public Members
-
unsigned k#
-
SolverStatus status#
- crvec x̂u
- real_t φγ
- real_t ψ
- crvec grad_ψ
- real_t ψ_hat
-
bool gn#
- real_t γ
- real_t τ
- real_t ε
-
unsigned outer_iter#
-
const TypeErasedControlProblem<config_t> *problem#
-
const PANOCOCPParams<config_t> *params#
-
unsigned k#
-
template<Config Conf>
class PANOCOCPSolver# - #include <alpaqa/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
- 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
-
std::string get_name() const#
-
inline void stop()#
Public Members
-
std::ostream *os = &std::cout#
-
using Problem = alpaqa::TypeErasedControlProblem<config_t>#
-
template<Config Conf = DefaultConfig>
struct PANOCOCPStats# - #include <alpaqa/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 lbfgs_failures = 0#
-
unsigned lbfgs_rejected = 0#
- unsigned τ_1_accepted = 0
- unsigned count_τ = 0
- real_t sum_τ = 0
- real_t final_γ = 0
- real_t final_ψ = 0
- real_t final_φγ = 0
-
SolverStatus status = SolverStatus::Busy#
-
template<Config Conf = DefaultConfig>
struct PANOCParams# - #include <alpaqa/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.
-
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 [1]).
\( 0 < \beta < 1 \)
-
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.
-
bool update_direction_in_candidate = false#
-
bool recompute_last_prox_step_after_lbfgs_flush = false#
-
LipschitzEstimateParams<config_t> Lipschitz#
-
template<Config Conf = DefaultConfig>
struct PANOCProgressInfo# - #include <alpaqa/include/alpaqa/inner/panoc.hpp>
Public Members
-
unsigned k#
-
SolverStatus status#
- crvec x̂
- real_t φγ
- real_t ψ
- crvec grad_ψ
- real_t ψ_hat
- crvec grad_ψ_hat
- real_t γ
- real_t τ
- real_t ε
- crvec Σ
-
unsigned outer_iter#
-
const TypeErasedProblem<config_t> *problem#
-
const PANOCParams<config_t> *params#
-
unsigned k#
-
template<class DirectionT>
class PANOCSolver# - #include <alpaqa/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
- 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
-
std::string get_name() const#
-
inline void stop()#
-
using Problem = TypeErasedProblem<config_t>#
-
template<Config Conf = DefaultConfig>
struct PANOCStats# - #include <alpaqa/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 lbfgs_failures = 0#
-
unsigned lbfgs_rejected = 0#
- unsigned τ_1_accepted = 0
- unsigned count_τ = 0
- real_t sum_τ = 0
- real_t final_γ = 0
- real_t final_ψ = 0
- real_t final_φγ = 0
-
SolverStatus status = SolverStatus::Busy#
-
template<Config Conf>
struct PANTRDirection# - #include <alpaqa/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.
-
using Problem = TypeErasedProblem<config_t>#
-
template<Config Conf = DefaultConfig>
struct PANTRParams# - #include <alpaqa/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.
-
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.
-
bool compute_ratio_using_new_stepsize = false#
Check the quadratic upperbound 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}. \]\[ q_\mathrm{approx}(d) = \inv{(1-\alpha)} q(d), \]\[ 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}, \]
-
LipschitzEstimateParams<config_t> Lipschitz#
-
template<Config Conf = DefaultConfig>
struct PANTRProgressInfo# - #include <alpaqa/include/alpaqa/inner/pantr.hpp>
Public Members
-
unsigned k#
-
SolverStatus status#
- crvec x̂
- real_t φγ
- real_t ψ
- crvec grad_ψ
- real_t ψ_hat
- crvec grad_ψ_hat
- real_t γ
- real_t Δ
- real_t ρ
- real_t ε
- crvec Σ
-
unsigned outer_iter#
-
const TypeErasedProblem<config_t> *problem#
-
const PANTRParams<config_t> *params#
-
unsigned k#
-
template<class DirectionT>
class PANTRSolver# - #include <alpaqa/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
- 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
-
std::string get_name() const#
-
inline void stop()#
-
using Problem = TypeErasedProblem<config_t>#
-
template<Config Conf = DefaultConfig>
struct PANTRStats# - #include <alpaqa/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_φγ = 0
-
SolverStatus status = SolverStatus::Busy#
-
template<Config Conf>
struct ProblemVTable : public BasicVTable# - #include <alpaqa/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
-
template<class F>
using optional_function_t = util::BasicVTable::optional_function_t<F, ProblemVTable>#
-
template<class F>
using optional_const_function_t = util::BasicVTable::optional_const_function_t<F, ProblemVTable>#
Public Functions
-
ProblemVTable() = default#
Public Members
- required_const_function_t< real_t(real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)> eval_prox_grad_step
- optional_const_function_t< index_t(real_t γ, crvec x, crvec grad_ψ, rindexvec J)> eval_inactive_indices_res_lna = default_eval_inactive_indices_res_lna
-
optional_const_function_t<void(crvec x, rindexvec inner_idx, rindexvec outer_ptr, rvec J_values)> eval_jac_g = default_eval_jac_g#
-
optional_const_function_t<length_t()> get_jac_g_num_nonzeros = default_get_jac_g_num_nonzeros#
-
optional_const_function_t<void(crvec x, index_t i, rvec grad_gi)> eval_grad_gi = default_eval_grad_gi#
-
optional_const_function_t<void(crvec x, crvec y, real_t scale, crvec v, rvec Hv)> eval_hess_L_prod = default_eval_hess_L_prod#
-
optional_const_function_t<void(crvec x, crvec y, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values)> eval_hess_L = default_eval_hess_L#
-
optional_const_function_t<length_t()> get_hess_L_num_nonzeros = default_get_hess_L_num_nonzeros#
- optional_const_function_t< void(crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv)> eval_hess_ψ_prod = default_eval_hess_ψ_prod
- optional_const_function_t< void(crvec x, crvec y, crvec Σ, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values)> eval_hess_ψ = default_eval_hess_ψ
- optional_const_function_t< length_t()> get_hess_ψ_num_nonzeros = default_get_hess_ψ_num_nonzeros
-
optional_const_function_t<real_t(crvec x, rvec grad_fx)> eval_f_grad_f = default_eval_f_grad_f#
-
optional_const_function_t<real_t(crvec x, rvec g)> eval_f_g = default_eval_f_g#
-
optional_const_function_t<void(crvec x, crvec y, rvec grad_f, rvec grad_gxy)> eval_grad_f_grad_g_prod = default_eval_grad_f_grad_g_prod#
-
optional_const_function_t<void(crvec x, crvec y, rvec grad_L, rvec work_n)> eval_grad_L = default_eval_grad_L#
- optional_const_function_t< real_t(crvec x, crvec y, crvec Σ, rvec ŷ)> eval_ψ = default_eval_ψ
- optional_const_function_t< void(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m)> eval_grad_ψ = default_eval_grad_ψ
- optional_const_function_t< real_t(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m)> eval_ψ_grad_ψ = default_eval_ψ_grad_ψ
-
optional_const_function_t<const Box&()> get_box_C = default_get_box_C#
-
optional_const_function_t<const Box&()> get_box_D = default_get_box_D#
-
optional_const_function_t<void()> check = default_check#
Public Static Functions
- static real_t calc_ŷ_dᵀŷ (const void *self, rvec g_ŷ, crvec y, crvec Σ, const ProblemVTable &vtable)
-
static index_t default_eval_inactive_indices_res_lna(const void*, real_t, crvec, crvec, rindexvec, const ProblemVTable&)#
-
static void default_eval_jac_g(const void*, crvec, rindexvec, rindexvec, rvec, const ProblemVTable&)#
-
static length_t default_get_jac_g_num_nonzeros(const void*, const ProblemVTable&)#
-
static void default_eval_grad_gi(const void*, crvec, index_t, rvec, const ProblemVTable&)#
-
static void default_eval_hess_L_prod(const void*, crvec, crvec, real_t, crvec, rvec, const ProblemVTable&)#
-
static void default_eval_hess_L(const void*, crvec, crvec, real_t, rindexvec, rindexvec, rvec, const ProblemVTable&)#
-
static length_t default_get_hess_L_num_nonzeros(const void*, const ProblemVTable&)#
- static void default_eval_hess_ψ_prod (const void *self, crvec x, crvec y, crvec, real_t scale, crvec v, rvec Hv, const ProblemVTable &vtable)
- static void default_eval_hess_ψ (const void *self, crvec x, crvec y, crvec, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values, const ProblemVTable &vtable)
- static length_t default_get_hess_ψ_num_nonzeros (const void *, const ProblemVTable &)
-
static real_t default_eval_f_grad_f(const void *self, crvec x, rvec grad_fx, const ProblemVTable &vtable)#
-
static real_t default_eval_f_g(const void *self, crvec x, rvec g, const ProblemVTable &vtable)#
-
static void default_eval_grad_f_grad_g_prod(const void *self, crvec x, crvec y, rvec grad_f, rvec grad_gxy, const ProblemVTable &vtable)#
-
static void default_eval_grad_L(const void *self, crvec x, crvec y, rvec grad_L, rvec work_n, const ProblemVTable &vtable)#
- static real_t default_eval_ψ (const void *self, crvec x, crvec y, crvec Σ, rvec ŷ, const ProblemVTable &vtable)
- static void default_eval_grad_ψ (const void *self, crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m, const ProblemVTable &vtable)
- static real_t default_eval_ψ_grad_ψ (const void *self, crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m, const ProblemVTable &vtable)
-
static const Box &default_get_box_C(const void*, const ProblemVTable&)#
-
static const Box &default_get_box_D(const void*, const ProblemVTable&)#
-
static void default_check(const void*, const ProblemVTable&)#
-
template<class F>
-
template<class Problem>
struct ProblemWithCounters# - #include <alpaqa/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 real_t eval_prox_grad_step (real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) const
- inline index_t eval_inactive_indices_res_lna (real_t γ, crvec x, crvec grad_ψ, rindexvec J) const
-
inline void eval_hess_L(crvec x, crvec y, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const#
- inline void eval_hess_ψ_prod (crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
- inline void eval_hess_ψ (crvec x, crvec y, crvec Σ, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const
- inline length_t get_hess_ψ_num_nonzeros () const
- inline real_t eval_ψ (crvec x, crvec y, crvec Σ, rvec ŷ) const
- inline void eval_grad_ψ (crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
- inline real_t eval_ψ_grad_ψ (crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
-
inline void check() const#
-
inline bool provides_eval_grad_gi() const#
-
inline bool provides_eval_inactive_indices_res_lna() const#
-
inline bool provides_eval_jac_g() const#
-
inline bool provides_get_jac_g_num_nonzeros() const#
-
inline bool provides_eval_hess_L_prod() const#
-
inline bool provides_eval_hess_L() const#
-
inline bool provides_get_hess_L_num_nonzeros() const#
- inline bool provides_eval_hess_ψ_prod () const
- inline bool provides_eval_hess_ψ () const
- inline bool provides_get_hess_ψ_num_nonzeros () const
-
inline bool provides_eval_f_grad_f() const#
-
inline bool provides_eval_f_g() const#
-
inline bool provides_eval_grad_f_grad_g_prod() const#
-
inline bool provides_eval_grad_L() const#
- inline bool provides_eval_ψ () const
- inline bool provides_eval_grad_ψ () const
- inline bool provides_eval_ψ_grad_ψ () const
-
inline bool provides_get_box_C() const#
-
inline bool provides_get_box_D() const#
-
inline bool provides_check() const#
-
ProblemWithCounters() = default#
-
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>()#
-
using Box = typename TypeErasedProblem<config_t>::Box#
-
template<class IndexT = size_t>
struct ReverseCircularIndexIterator# - #include <alpaqa/include/alpaqa/util/ringbuffer.hpp>
Public Types
-
using ForwardIterator = CircularIndexIterator<IndexT>#
-
using Index = typename ForwardIterator::Index#
-
using Indices = typename ForwardIterator::Indices#
-
using reference = value_type#
-
using difference_type = std::ptrdiff_t#
-
using pointer = void#
-
using iterator_category = std::input_iterator_tag#
Public Functions
-
inline ReverseCircularIndexIterator()#
-
inline ReverseCircularIndexIterator(ForwardIterator forwardit)#
-
inline ReverseCircularIndexIterator &operator++()#
-
inline ReverseCircularIndexIterator &operator--()#
-
inline ReverseCircularIndexIterator operator++(int)#
-
inline ReverseCircularIndexIterator operator--(int)#
Public Members
-
ForwardIterator forwardit#
-
template<class IndexT>
bool operator==(ReverseCircularIndexIterator<IndexT> a, ReverseCircularIndexIterator<IndexT> b)# Note
Only valid for two indices in the same range.
-
template<class IndexT>
bool operator!=(ReverseCircularIndexIterator<IndexT> a, ReverseCircularIndexIterator<IndexT> b)# Note
Only valid for two indices in the same range.
-
using ForwardIterator = CircularIndexIterator<IndexT>#
-
template<class IndexT>
class ReverseCircularRange# - #include <alpaqa/include/alpaqa/util/ringbuffer.hpp>
Public Types
-
using ForwardRange = CircularRange<IndexT>#
-
using Index = typename ForwardRange::Index#
-
using Indices = typename ForwardRange::Indices#
-
using const_iterator = typename ForwardRange::const_reverse_iterator#
-
using iterator = typename ForwardRange::reverse_iterator#
-
using const_reverse_iterator = typename ForwardRange::const_iterator#
-
using reverse_iterator = typename ForwardRange::iterator#
Public Functions
-
inline ReverseCircularRange(const ForwardRange &forwardrange)#
-
inline const_iterator cbegin() const#
-
inline const_iterator cend() const#
-
inline reverse_iterator rbegin() const#
-
inline reverse_iterator rend() const#
-
inline const_reverse_iterator crbegin() const#
-
inline const_reverse_iterator crend() const#
-
using ForwardRange = CircularRange<IndexT>#
-
struct ScopedMallocAllower : public ScopedMallocChecker<true>#
- #include <alpaqa/include/alpaqa/util/alloc-check.hpp>
-
struct ScopedMallocBlocker : public ScopedMallocChecker<false>#
- #include <alpaqa/include/alpaqa/util/alloc-check.hpp>
-
template<bool>
struct ScopedMallocChecker# - #include <alpaqa/include/alpaqa/util/alloc-check.hpp>
-
template<Config Conf>
struct StatefulLQRFactor# - #include <alpaqa/include/alpaqa/inner/directions/panoc-ocp/lqr.hpp>
Public Functions
-
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
- vec R̅_sto = {dim.nu * dim.nu}
- vec S̅_sto = {dim.nu * dim.nx}
-
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)#
-
template<Config Conf>
struct SteihaugCG# - #include <alpaqa/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#
-
using Params = SteihaugCGParams<config_t>#
-
template<Config Conf>
struct SteihaugCGParams# - #include <alpaqa/include/alpaqa/accelerators/steihaugcg.hpp>
-
template<Config Conf = DefaultConfig>
struct StructuredLBFGSDirection# - #include <alpaqa/include/alpaqa/inner/directions/panoc/structured-lbfgs.hpp>
Public Types
-
using Problem = TypeErasedProblem<config_t>#
-
using DirectionParams = StructuredLBFGSDirectionParams<config_t>#
Public Functions
-
StructuredLBFGSDirection() = default#
-
inline StructuredLBFGSDirection(const typename LBFGS::Params ¶ms, 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
-
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
- bool apply (real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const
See also
- inline void changed_γ (real_t γₖ, real_t old_γₖ)
See also
-
inline void reset()#
See also
-
inline std::string get_name() const#
See also
-
inline auto get_params() const#
Public Members
-
DirectionParams direction_params#
-
struct Params#
- #include <alpaqa/include/alpaqa/inner/directions/panoc/structured-lbfgs.hpp>
-
using Problem = TypeErasedProblem<config_t>#
-
template<Config Conf>
struct StructuredLBFGSDirectionParams# - #include <alpaqa/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 \)).
-
enumerator FallbackToProjectedGradient#
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 [2], scaled by this parameter.
Set it to zero to leave out that term.
-
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).
-
enum FailurePolicy#
-
template<Config Conf = DefaultConfig>
struct StructuredNewtonDirection# - #include <alpaqa/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 AcceleratorParams ¶ms, 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
-
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
- inline bool apply (real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const
See also
- inline void changed_γ (real_t γₖ, real_t old_γₖ)
See also
-
inline void reset()#
See also
-
inline std::string get_name() const#
See also
-
inline const auto &get_params() const#
-
struct Params#
- #include <alpaqa/include/alpaqa/inner/directions/panoc/structured-newton.hpp>
-
using Problem = TypeErasedProblem<config_t>#
-
template<Config Conf>
struct StructuredNewtonDirectionParams# - #include <alpaqa/include/alpaqa/inner/directions/panoc/structured-newton.hpp>
Parameters for the StructuredNewtonDirection class.
-
template<Config Conf>
struct StructuredNewtonRegularizationParams# - #include <alpaqa/include/alpaqa/inner/directions/panoc/structured-newton.hpp>
Parameters for the StructuredNewtonDirection class.
-
template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
class TypeErasedControlProblem : public alpaqa::util::TypeErased<ControlProblemVTable<DefaultConfig>, std::allocator<std::byte>># - #include <alpaqa/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}\]Problem dimensions
Projections onto constraint sets
-
inline void eval_proj_diff_g(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
ande
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_proj_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 ALMParams::max_multiplier.
Constraint sets
Dynamics and initial state
-
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) \).
Output mapping
Stage and terminal cost
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 ofwork
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 ofwork
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_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 \).
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 TypeErased = util::TypeErased<VTable, allocator_type>#
Public Functions
-
TypeErased() noexcept(noexcept(allocator_type())) = default
Default constructor.
-
template<class Alloc>
inline TypeErased(std::allocator_arg_t, const Alloc &alloc)# Default constructor (allocator aware).
-
inline TypeErased(const TypeErased &other)
Copy constructor.
-
inline TypeErased(const TypeErased &other, allocator_type alloc)
Copy constructor (allocator aware).
-
inline TypeErased(TypeErased &&other) noexcept
Move constructor.
-
inline TypeErased(TypeErased &&other, const allocator_type &alloc) noexcept
Move constructor (allocator aware).
-
template<class T, class Alloc>
inline explicit TypeErased(std::allocator_arg_t, const Alloc &alloc, T &&d)# Main constructor that type-erases the given argument.
-
template<class T, class Alloc, class ...Args>
inline explicit TypeErased(std::allocator_arg_t, const Alloc &alloc, te_in_place_t<T>, Args&&... args)# Main constructor that type-erases the object constructed from the given argument.
Public Static Functions
-
template<class T, class ...Args>
static inline TypeErasedControlProblem make(Args&&... args)#
-
inline void eval_proj_diff_g(crvec z, rvec e) const#
-
template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
class TypeErasedProblem : public alpaqa::util::TypeErased<ProblemVTable<DefaultConfig>, std::allocator<std::byte>># - #include <alpaqa/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
Required cost and constraint functions
-
real_t eval_f(crvec x) const#
[Required] Function that evaluates the cost, \( f(x) \)
- Parameters:
x – [in] Decision variable \( x \in \R^n \)
-
void eval_grad_f(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_g(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_grad_g_prod(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_proj_diff_g(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
ande
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_proj_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 ALMParams::max_multiplier.
- real_t eval_prox_grad_step (real_t γ, crvec x, crvec grad_ψ, rvec x̂, 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 \)
x̂ – [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 [2].
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
Functions for second-order solvers
-
void eval_jac_g(crvec x, rindexvec inner_idx, rindexvec outer_ptr, rvec J_values) const#
[Optional] Function that evaluates the Jacobian of the constraints as a sparse matrix, \( \jac_g(x) \)
Required for second-order solvers only.
- Parameters:
x – [in] Decision variable \( x \in \R^n \)
inner_idx – [inout] Inner indices (row indices of nonzeros).
outer_ptr – [inout] Outer pointers (points to the first nonzero in each column).
J_values – [out] Nonzero values of the Jacobian \( \jac_g(x) \in \R^{m\times n} \) If
J_values
has size zero, this function should initializeinner_idx
andouter_ptr
. IfJ_values
is nonempty,inner_idx
andouter_ptr
can be assumed to be initialized, and this function should evaluateJ_values
.
-
length_t get_jac_g_num_nonzeros() const#
[Optional] Function that gets the number of nonzeros of the sparse Jacobian of the constraints.
Should return -1 for a dense Jacobian.
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_hess_L_prod(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_hess_L(crvec x, crvec y, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const#
[Optional] Function that evaluates the Hessian of the Lagrangian as a sparse matrix, \( \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.
inner_idx – [inout] Inner indices (row indices of nonzeros).
outer_ptr – [inout] Outer pointers (points to the first nonzero in each column).
H_values – [out] Nonzero values of the Hessian \( \nabla_{xx}^2 L(x, y) \in \R^{n\times n} \). If
H_values
has size zero, this function should initializeinner_idx
andouter_ptr
. IfH_values
is nonempty,inner_idx
andouter_ptr
can be assumed to be initialized, and this function should evaluateH_values
.
-
length_t get_hess_L_num_nonzeros() const#
[Optional] Function that gets the number of nonzeros of the sparse Hessian of the Lagrangian.
Should return -1 for a dense Hessian.
Required for second-order solvers only.
- void eval_hess_ψ_prod (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_hess_ψ (crvec x, crvec y, crvec Σ, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const
[Optional] Function that evaluates 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.
inner_idx – [inout] Inner indices (row indices of nonzeros).
outer_ptr – [inout] Outer pointers (points to the first nonzero in each column).
H_values – [out] Nonzero values of the Hessian \( \nabla_{xx}^2 L_\Sigma(x, y) \in \R^{n\times n} \) If
H_values
has size zero, this function should initializeinner_idx
andouter_ptr
. IfH_values
is nonempty,inner_idx
andouter_ptr
can be assumed to be initialized, and this function should evaluateH_values
.
- length_t get_hess_ψ_num_nonzeros () const
[Optional] Function that gets the number of nonzeros of the Hessian of the augmented Lagrangian.
Required for second-order solvers only.
Combined evaluations
-
real_t eval_f_grad_f(crvec x, rvec grad_fx) const#
[Optional] Evaluate both \( f(x) \) and its gradient, \( \nabla f(x) \).
- Default implementation:
-
real_t eval_f_g(crvec x, rvec g) const#
[Optional] Evaluate both \( f(x) \) and \( g(x) \).
- Default implementation:
Augmented Lagrangian
- real_t eval_ψ (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:
- Parameters:
x – [in] Decision variable \( x \)
y – [in] Lagrange multipliers \( y \)
Σ – [in] Penalty weights \( \Sigma \)
ŷ – [out] \( \hat y \)
- void eval_grad_ψ (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:
- 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_ψ_grad_ψ (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:
- 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.
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_jac_g() const#
Returns true if the problem provides an implementation of eval_jac_g.
-
inline bool provides_get_jac_g_num_nonzeros() const#
Returns true if the problem provides an implementation of get_jac_g_num_nonzeros.
-
inline bool provides_eval_grad_gi() const#
Returns true if the problem provides an implementation of eval_grad_gi.
-
inline bool provides_eval_hess_L_prod() const#
Returns true if the problem provides an implementation of eval_hess_L_prod.
-
inline bool provides_eval_hess_L() const#
Returns true if the problem provides an implementation of eval_hess_L.
-
inline bool provides_get_hess_L_num_nonzeros() const#
Returns true if the problem provides an implementation of get_hess_L_num_nonzeros.
- inline bool provides_eval_hess_ψ_prod () const
Returns true if the problem provides an implementation of eval_hess_ψ_prod.
- inline bool provides_eval_hess_ψ () const
Returns true if the problem provides an implementation of eval_hess_ψ.
- inline bool provides_get_hess_ψ_num_nonzeros () const
Returns true if the problem provides an implementation of get_hess_ψ_num_nonzeros.
-
inline bool provides_eval_f_grad_f() const#
Returns true if the problem provides a specialized implementation of eval_f_grad_f, false if it uses the default implementation.
-
inline bool provides_eval_f_g() const#
Returns true if the problem provides a specialized implementation of eval_f_g, false if it uses the default implementation.
-
inline bool provides_eval_grad_f_grad_g_prod() const#
Returns true if the problem provides a specialized implementation of eval_grad_f_grad_g_prod, false if it uses the default implementation.
-
inline bool provides_eval_grad_L() const#
Returns true if the problem provides a specialized implementation of eval_grad_L, false if it uses the default implementation.
- inline bool provides_eval_ψ () const
Returns true if the problem provides a specialized implementation of eval_ψ, false if it uses the default implementation.
- inline bool provides_eval_grad_ψ () const
Returns true if the problem provides a specialized implementation of eval_grad_ψ, false if it uses the default implementation.
- inline bool provides_eval_ψ_grad_ψ () const
Returns true if the problem provides a specialized implementation of eval_ψ_grad_ψ, false if it uses the default implementation.
-
inline bool provides_get_box_C() const#
Returns true if the problem provides an implementation of get_box_C.
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
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 VTable = ProblemVTable<config_t>#
-
using TypeErased = util::TypeErased<VTable, allocator_type>#
Public Functions
-
TypeErased() noexcept(noexcept(allocator_type())) = default
Default constructor.
-
template<class Alloc>
inline TypeErased(std::allocator_arg_t, const Alloc &alloc)# Default constructor (allocator aware).
-
inline TypeErased(const TypeErased &other)
Copy constructor.
-
inline TypeErased(const TypeErased &other, allocator_type alloc)
Copy constructor (allocator aware).
-
inline TypeErased(TypeErased &&other) noexcept
Move constructor.
-
inline TypeErased(TypeErased &&other, const allocator_type &alloc) noexcept
Move constructor (allocator aware).
-
template<class T, class Alloc>
inline explicit TypeErased(std::allocator_arg_t, const Alloc &alloc, T &&d)# Main constructor that type-erases the given argument.
-
template<class T, class Alloc, class ...Args>
inline explicit TypeErased(std::allocator_arg_t, const Alloc &alloc, te_in_place_t<T>, Args&&... args)# Main constructor that type-erases the object constructed from the given argument.
Public Static Functions
-
template<class T, class ...Args>
static inline TypeErasedProblem make(Args&&... args)#
-
real_t eval_f(crvec x) const#
-
template<Config Conf>
class UnconstrProblem# - #include <alpaqa/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.
-
template<Config Conf = DefaultConfig>
struct ZeroFPRParams# - #include <alpaqa/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 [1]).
\( 0 < \beta < 1 \)
-
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.
-
bool update_direction_in_candidate = false#
-
bool recompute_last_prox_step_after_lbfgs_flush = false#
-
bool update_direction_from_prox_step = false#
-
LipschitzEstimateParams<config_t> Lipschitz#
-
template<Config Conf = DefaultConfig>
struct ZeroFPRProgressInfo# - #include <alpaqa/include/alpaqa/inner/zerofpr.hpp>
Public Members
-
unsigned k#
-
SolverStatus status#
- crvec x̂
- real_t φγ
- real_t ψ
- crvec grad_ψ
- real_t ψ_hat
- crvec grad_ψ_hat
- real_t γ
- real_t τ
- real_t ε
- crvec Σ
-
unsigned outer_iter#
-
const TypeErasedProblem<config_t> *problem#
-
const ZeroFPRParams<config_t> *params#
-
unsigned k#
-
template<class DirectionT>
class ZeroFPRSolver# - #include <alpaqa/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
- 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
-
std::string get_name() const#
-
inline void stop()#
-
using Problem = TypeErasedProblem<config_t>#
-
template<Config Conf = DefaultConfig>
struct ZeroFPRStats# - #include <alpaqa/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 lbfgs_failures = 0#
-
unsigned lbfgs_rejected = 0#
- unsigned τ_1_accepted = 0
- unsigned count_τ = 0
- real_t sum_τ = 0
- real_t final_γ = 0
- real_t final_ψ = 0
- real_t final_φγ = 0
-
SolverStatus status = SolverStatus::Busy#
-
namespace casadi_loader#
Typedefs
-
using dim = std::pair<casadi_int, casadi_int>#
Functions
-
template<class T, class ...Args>
auto wrapped_load(const std::string &so_name, const char *name, Args&&... args)#
-
template<class T, class ...Args>
std::optional<T> try_load(const std::string &so_name, const char *name, Args&&... args)#
-
inline constexpr auto dims(auto... a)#
-
template<Config>
struct CasADiControlFunctionsWithParam#
-
template<Config Conf, size_t N_in, size_t N_out>
class CasADiFunctionEvaluator# - #include <interop/casadi/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:
std::invalid_argument –
-
inline CasADiFunctionEvaluator(casadi::Function &&f, const std::array<casadi_dim, N_in> &dim_in, const std::array<casadi_dim, N_out> &dim_out)#
- Throws:
std::invalid_argument –
-
inline void validate_dimensions(const std::array<casadi_dim, N_in> &dim_in = {}, const std::array<casadi_dim, N_out> &dim_out = {})#
- Throws:
std::invalid_argument –
Public Members
-
casadi::Function fun#
-
using casadi_dim = std::pair<casadi_int, casadi_int>#
-
template<Config>
struct CasADiFunctionsWithParam#
-
using dim = std::pair<casadi_int, casadi_int>#
-
namespace csv#
Functions
-
template<std::floating_point F>
void read_row_impl(std::istream &is, Eigen::Ref<Eigen::VectorX<F>> v, char sep = ',')#
-
template<std::floating_point F>
std::vector<F> read_row_std_vector(std::istream &is, char sep = ',')#
-
inline void read_row(std::istream &is, Eigen::Ref<Eigen::VectorX<float>> v, char sep)#
-
inline void read_row(std::istream &is, Eigen::Ref<Eigen::VectorX<float>> v)#
-
inline void read_row(std::istream &is, Eigen::Ref<Eigen::VectorX<double>> v, char sep)#
-
inline void read_row(std::istream &is, Eigen::Ref<Eigen::VectorX<double>> v)#
-
inline void read_row(std::istream &is, Eigen::Ref<Eigen::VectorX<long double>> v, char sep)#
-
inline void read_row(std::istream &is, Eigen::Ref<Eigen::VectorX<long double>> v)#
- template void read_row_impl (std::istream &, Eigen::Ref< Eigen::VectorX< float > >, char)
- template void read_row_impl (std::istream &, Eigen::Ref< Eigen::VectorX< double > >, char)
- template void read_row_impl (std::istream &, Eigen::Ref< Eigen::VectorX< long double > >, char)
- template std::vector< float > read_row_std_vector (std::istream &, char)
-
struct read_error : public runtime_error#
- #include <alpaqa/include/alpaqa/util/io/csv.hpp>
-
template<std::floating_point F>
-
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<Config Conf>
struct ALMHelpers#
-
template<Config Conf>
struct IndexSet# - #include <alpaqa/include/alpaqa/util/index-set.hpp>
Public Functions
-
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#
-
inline auto sizes()#
-
template<Config Conf>
struct PANOCHelpers#
-
template<Config Conf>
-
namespace dl#
-
class DLControlProblem : private DLLoader#
- #include <interop/dl/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
<symbol_prefix>_register
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. See C++/DLProblem/main.cppSee also
Note
Copies are shallow, they all share the same problem instance, take that into account when using multiple threads.
Public Functions
-
DLControlProblem(std::string so_filename, std::string symbol_prefix = "alpaqa_control_problem", void *user_param = nullptr)#
Load a problem from a shared library.
- Parameters:
so_filename – Filename of the shared library to load.
symbol_prefix – Prefix of the registration function.
user_param – Pointer to custom user data to pass to the registration function.
-
inline void check() 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#
-
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#
-
DLControlProblem(std::string so_filename, std::string symbol_prefix = "alpaqa_control_problem", void *user_param = nullptr)#
-
class DLLoader#
- #include <interop/dl/include/alpaqa/dl/dl-problem.hpp>
Subclassed by DLControlProblem, DLProblem
-
class DLProblem : private DLLoader, public BoxConstrProblem<DefaultConfig>#
- #include <interop/dl/include/alpaqa/dl/dl-problem.hpp>
Class that loads a problem using
dlopen
.The shared library should export a C function with the name
<symbol_prefix>_register
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.cppSee also
Note
Copies are shallow, they all share the same problem instance, take that into account when using multiple threads.
Public Functions
-
DLProblem(std::string so_filename, std::string symbol_prefix = "alpaqa_problem", void *user_param = nullptr)#
Load a problem from a shared library.
- Parameters:
so_filename – Filename of the shared library to load.
symbol_prefix – Prefix of the registration function.
user_param – Pointer to custom user data to pass to the registration function.
- real_t eval_prox_grad_step (real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) const
-
void eval_hess_L(crvec x, crvec y, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const#
- void eval_hess_ψ_prod (crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
- void eval_hess_ψ (crvec x, crvec y, crvec Σ, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const
- length_t get_hess_ψ_num_nonzeros () const
- real_t eval_ψ (crvec x, crvec y, crvec Σ, rvec ŷ) const
- void eval_grad_ψ (crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
- real_t eval_ψ_grad_ψ (crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
-
bool provides_eval_f() const#
-
bool provides_eval_grad_f() const#
-
bool provides_eval_g() const#
-
bool provides_eval_grad_g_prod() const#
-
bool provides_eval_jac_g() const#
-
bool provides_get_jac_g_num_nonzeros() const#
-
bool provides_eval_grad_gi() const#
-
bool provides_eval_hess_L_prod() const#
-
bool provides_eval_hess_L() const#
-
bool provides_get_hess_L_num_nonzeros() const#
- bool provides_eval_hess_ψ_prod () const
- bool provides_eval_hess_ψ () const
- bool provides_get_hess_ψ_num_nonzeros () const
-
bool provides_eval_f_grad_f() const#
-
bool provides_eval_f_g() const#
-
bool provides_eval_grad_f_grad_g_prod() const#
-
bool provides_eval_grad_L() const#
- bool provides_eval_ψ () const
- bool provides_eval_grad_ψ () const
- bool provides_eval_ψ_grad_ψ () const
-
bool provides_get_box_C() const#
-
DLProblem(std::string so_filename, std::string symbol_prefix = "alpaqa_problem", void *user_param = nullptr)#
-
class DLControlProblem : private DLLoader#
-
namespace lbfgsb#
-
struct LBFGSBParams#
- #include <interop/lbfgsb/include/alpaqa/lbfgsb/lbfgsb-adapter.hpp>
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#
-
unsigned memory = 10#
-
class LBFGSBSolver#
- #include <interop/lbfgsb/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 SolveOptions = InnerSolveOptions<config_t>#
Public Functions
- 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)
-
std::string get_name() const#
-
inline void stop()#
Public Members
-
std::ostream *os = &std::cout#
-
using Problem = TypeErasedProblem<config_t>#
-
struct LBFGSBStats#
- #include <interop/lbfgsb/include/alpaqa/lbfgsb/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
-
unsigned lbfgs_rejected = 0#
-
SolverStatus status = SolverStatus::Busy#
-
struct LBFGSBParams#
-
namespace lbfgspp#
-
template<Config Conf>
class LBFGSBSolver# - #include <interop/lbfgspp/include/alpaqa/lbfgsb-adapter.hpp>
L-BFGS-B solver for ALM.
Public Types
-
using Problem = TypeErasedProblem<config_t>#
-
using Stats = LBFGSBStats<config_t>#
-
using SolveOptions = InnerSolveOptions<config_t>#
Public Functions
- 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()#
Public Members
-
std::ostream *os = &std::cout#
-
using Problem = TypeErasedProblem<config_t>#
-
template<Config Conf = DefaultConfig>
struct LBFGSBStats# - #include <interop/lbfgspp/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
-
SolverStatus status = SolverStatus::Busy#
-
template<Config Conf>
-
namespace params#
Functions
-
inline auto split_key(std::string_view full, char tok = '.')#
Split the string
full
on the first occurrence oftok
.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<bool>> used = std::nullopt)# Overwrites
t
based on theoptions
that start withprefix
.If
used
is notnullopt
, sets corresponding flag of the options that were used.
-
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(T &f, ParamString s) Update/overwrite the first argument based on the option in
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 Rep, class Period>
void set_param(std::chrono::duration<Rep, Period> &t, ParamString s)#
-
template<>
void set_param(LBFGSStepSize &t, ParamString s)#
-
template<>
void set_param(PANOCStopCrit &t, ParamString s)#
-
template<class ...Ts>
void set_param(detail::_dummy<Ts...>&, ParamString)#
- template void set_param (detail::possible_alias_t< float > &, ParamString)
- template void set_param (detail::possible_alias_t< double, float > &, ParamString)
- template void set_param (detail::possible_alias_t< long double, double, float > &, ParamString)
- template void set_param (detail::possible_alias_t< int8_t > &, ParamString)
- template void set_param (detail::possible_alias_t< uint8_t > &, ParamString)
- template void set_param (detail::possible_alias_t< int16_t > &, ParamString)
- template void set_param (detail::possible_alias_t< uint16_t > &, ParamString)
- template void set_param (detail::possible_alias_t< int32_t > &, ParamString)
- template void set_param (detail::possible_alias_t< int64_t > &, ParamString)
- template void set_param (detail::possible_alias_t< uint32_t > &, ParamString)
- template void set_param (detail::possible_alias_t< uint64_t > &, ParamString)
- template void set_param (detail::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 (detail::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 (detail::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 (detail::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 (detail::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 (detail::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 (detail::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 (detail::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 (detail::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 (detail::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 (detail::possible_alias_t< std::chrono::nanoseconds > &, ParamString)
- template void set_param (detail::possible_alias_t< std::chrono::microseconds > &, ParamString)
- template void set_param (detail::possible_alias_t< std::chrono::milliseconds > &, ParamString)
- template void set_param (detail::possible_alias_t< std::chrono::seconds > &, ParamString)
- template void set_param (detail::possible_alias_t< std::chrono::minutes > &, ParamString)
- template void set_param (detail::possible_alias_t< std::chrono::hours > &, ParamString)
- template void set_param (detail::possible_alias_t< PANOCParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< ZeroFPRParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< PANTRParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< LBFGSParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< AndersonAccelParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< LBFGSDirectionParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< AndersonDirectionParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< StructuredLBFGSDirectionParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< NewtonTRDirectionParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< SteihaugCGParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< StructuredNewtonRegularizationParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< StructuredNewtonDirectionParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< ALMParams< config_t > > &, ParamString)
- template void set_param (detail::possible_alias_t< PANOCOCPParams< config_t > > &, ParamString)
- template<> void IPOPT_ADAPTER_EXPORT set_param (Ipopt::IpoptApplication &app, ParamString s)
- template void LBFGSB_ADAPTER_EXPORT set_param (lbfgsb::LBFGSBSolver::Params &, ParamString)
-
template<>
struct dict_to_struct_table<ALMParams<config_t>># -
Public Static Attributes
- static const dict_to_struct_table_t< type > table = { { "tolerance", &type:: tolerance }, { "dual_tolerance", &type:: dual_tolerance }, { "penalty_update_factor", &type:: penalty_update_factor }, { "penalty_update_factor_lower", &type:: penalty_update_factor_lower }, { "min_penalty_update_factor", &type:: min_penalty_update_factor }, { "initial_penalty", &type:: initial_penalty }, { "initial_penalty_factor", &type:: initial_penalty_factor }, { "initial_penalty_lower", &type:: initial_penalty_lower }, { "initial_tolerance", &type:: initial_tolerance }, { "initial_tolerance_increase", &type:: initial_tolerance_increase }, { "tolerance_update_factor", &type:: tolerance_update_factor }, { "ρ_increase", &type:: ρ_increase }, { "ρ_max", &type:: ρ_max }, { "rel_penalty_increase_threshold", &type:: rel_penalty_increase_threshold }, { "max_multiplier", &type:: max_multiplier }, { "max_penalty", &type:: max_penalty }, { "min_penalty", &type:: min_penalty }, { "max_iter", &type:: max_iter }, { "max_time", &type:: max_time }, { "max_num_initial_retries", &type:: max_num_initial_retries }, { "max_num_retries", &type:: max_num_retries }, { "max_total_num_retries", &type:: max_total_num_retries }, { "print_interval", &type:: print_interval }, { "print_precision", &type:: print_precision }, { "single_penalty_factor", &type:: single_penalty_factor }, }
-
template<>
struct dict_to_struct_table<AndersonAccelParams<config_t>># Public Types
-
using type = AndersonAccelParams<config_t>#
-
using type = AndersonAccelParams<config_t>#
-
template<>
struct dict_to_struct_table<AndersonDirectionParams<config_t>># Public Types
-
using type = AndersonDirectionParams<config_t>#
-
using type = AndersonDirectionParams<config_t>#
-
template<>
struct dict_to_struct_table<CBFGSParams<config_t>># Public Types
-
using type = CBFGSParams<config_t>#
Public Static Attributes
- static const dict_to_struct_table_t< type > table = { { "α", &type:: α }, { "ϵ", &type:: ϵ }, }
-
using type = CBFGSParams<config_t>#
- template<> Params >
Public Types
-
using type = lbfgsb::LBFGSBSolver::Params#
Public Static Attributes
-
using type = lbfgsb::LBFGSBSolver::Params#
-
template<>
struct dict_to_struct_table<LBFGSDirectionParams<config_t>># Public Types
-
using type = LBFGSDirectionParams<config_t>#
-
using type = LBFGSDirectionParams<config_t>#
-
template<>
struct dict_to_struct_table<LBFGSParams<config_t>># Public Types
-
using type = LBFGSParams<config_t>#
-
using type = LBFGSParams<config_t>#
-
template<>
struct dict_to_struct_table<LipschitzEstimateParams<config_t>># Public Types
-
using type = LipschitzEstimateParams<config_t>#
Public Static Attributes
- static const dict_to_struct_table_t< type > table = { { "L_0", &type:: L_0 }, { "δ", &type:: δ }, { "ε", &type:: ε }, { "Lγ_factor", &type:: Lγ_factor }, }
-
using type = LipschitzEstimateParams<config_t>#
-
template<>
struct dict_to_struct_table<NewtonTRDirectionParams<config_t>># Public Types
-
using type = NewtonTRDirectionParams<config_t>#
-
using type = NewtonTRDirectionParams<config_t>#
-
template<>
struct dict_to_struct_table<PANOCOCPParams<config_t>># Public Types
-
using type = PANOCOCPParams<config_t>#
Public Static Attributes
-
static const dict_to_struct_table_t<type> table = {{"Lipschitz", &type::Lipschitz}, {"max_iter", &type::max_iter}, {"max_time", &type::max_time}, {"min_linesearch_coefficient", &type::min_linesearch_coefficient}, {"linesearch_strictness_factor", &type::linesearch_strictness_factor}, {"L_min", &type::L_min}, {"L_max", &type::L_max}, {"L_max_inc", &type::L_max_inc}, {"stop_crit", &type::stop_crit}, {"max_no_progress", &type::max_no_progress}, {"gn_interval", &type::gn_interval}, {"gn_sticky", &type::gn_sticky}, {"reset_lbfgs_on_gn_step", &type::reset_lbfgs_on_gn_step}, {"lqr_factor_cholesky", &type::lqr_factor_cholesky}, {"lbfgs_params", &type::lbfgs_params}, {"print_interval", &type::print_interval}, {"print_precision", &type::print_precision}, {"quadratic_upperbound_tolerance_factor", &type::quadratic_upperbound_tolerance_factor}, {"linesearch_tolerance_factor", &type::linesearch_tolerance_factor}, {"disable_acceleration", &type::disable_acceleration},}#
-
using type = PANOCOCPParams<config_t>#
-
template<>
struct dict_to_struct_table<PANOCParams<config_t>># Public Types
-
using type = PANOCParams<config_t>#
Public Static Attributes
-
static const dict_to_struct_table_t<type> table = {{"Lipschitz", &type::Lipschitz}, {"max_iter", &type::max_iter}, {"max_time", &type::max_time}, {"min_linesearch_coefficient", &type::min_linesearch_coefficient}, {"force_linesearch", &type::force_linesearch}, {"linesearch_strictness_factor", &type::linesearch_strictness_factor}, {"L_min", &type::L_min}, {"L_max", &type::L_max}, {"stop_crit", &type::stop_crit}, {"max_no_progress", &type::max_no_progress}, {"print_interval", &type::print_interval}, {"print_precision", &type::print_precision}, {"quadratic_upperbound_tolerance_factor", &type::quadratic_upperbound_tolerance_factor}, {"linesearch_tolerance_factor", &type::linesearch_tolerance_factor}, {"update_direction_in_candidate", &type::update_direction_in_candidate}, {"recompute_last_prox_step_after_lbfgs_flush", &type::recompute_last_prox_step_after_lbfgs_flush},}#
-
using type = PANOCParams<config_t>#
-
template<>
struct dict_to_struct_table<PANTRParams<config_t>># Public Types
-
using type = PANTRParams<config_t>#
Public Static Attributes
-
static const dict_to_struct_table_t<type> table = {{"Lipschitz", &type::Lipschitz}, {"max_iter", &type::max_iter}, {"max_time", &type::max_time}, {"L_min", &type::L_min}, {"L_max", &type::L_max}, {"stop_crit", &type::stop_crit}, {"max_no_progress", &type::max_no_progress}, {"print_interval", &type::print_interval}, {"print_precision", &type::print_precision}, {"quadratic_upperbound_tolerance_factor", &type::quadratic_upperbound_tolerance_factor}, {"TR_tolerance_factor", &type::TR_tolerance_factor}, {"ratio_threshold_acceptable", &type::ratio_threshold_acceptable}, {"ratio_threshold_good", &type::ratio_threshold_good}, {"radius_factor_rejected", &type::radius_factor_rejected}, {"radius_factor_acceptable", &type::radius_factor_acceptable}, {"radius_factor_good", &type::radius_factor_good}, {"initial_radius", &type::initial_radius}, {"min_radius", &type::min_radius}, {"compute_ratio_using_new_stepsize", &type::compute_ratio_using_new_stepsize}, {"update_direction_on_prox_step", &type::update_direction_on_prox_step}, {"recompute_last_prox_step_after_direction_reset", &type::recompute_last_prox_step_after_direction_reset}, {"disable_acceleration", &type::disable_acceleration}, {"ratio_approx_fbe_quadratic_model", &type::ratio_approx_fbe_quadratic_model},}#
-
using type = PANTRParams<config_t>#
-
template<>
struct dict_to_struct_table<SteihaugCGParams<config_t>># Public Types
-
using type = SteihaugCGParams<config_t>#
-
using type = SteihaugCGParams<config_t>#
-
template<>
struct dict_to_struct_table<StructuredLBFGSDirectionParams<config_t>># Public Types
-
using type = StructuredLBFGSDirectionParams<config_t>#
-
using type = StructuredLBFGSDirectionParams<config_t>#
-
template<>
struct dict_to_struct_table<StructuredNewtonDirectionParams<config_t>># Public Types
-
using type = StructuredNewtonDirectionParams<config_t>#
-
using type = StructuredNewtonDirectionParams<config_t>#
-
template<>
struct dict_to_struct_table<StructuredNewtonRegularizationParams<config_t>># Public Types
-
using type = StructuredNewtonRegularizationParams<config_t>#
-
using type = StructuredNewtonRegularizationParams<config_t>#
-
template<>
struct dict_to_struct_table<ZeroFPRParams<config_t>># Public Types
-
using type = ZeroFPRParams<config_t>#
Public Static Attributes
-
static const dict_to_struct_table_t<type> table = {{"Lipschitz", &type::Lipschitz}, {"max_iter", &type::max_iter}, {"max_time", &type::max_time}, {"min_linesearch_coefficient", &type::min_linesearch_coefficient}, {"force_linesearch", &type::force_linesearch}, {"linesearch_strictness_factor", &type::linesearch_strictness_factor}, {"L_min", &type::L_min}, {"L_max", &type::L_max}, {"stop_crit", &type::stop_crit}, {"max_no_progress", &type::max_no_progress}, {"print_interval", &type::print_interval}, {"print_precision", &type::print_precision}, {"quadratic_upperbound_tolerance_factor", &type::quadratic_upperbound_tolerance_factor}, {"linesearch_tolerance_factor", &type::linesearch_tolerance_factor}, {"update_direction_in_candidate", &type::update_direction_in_candidate}, {"recompute_last_prox_step_after_lbfgs_flush", &type::recompute_last_prox_step_after_lbfgs_flush}, {"update_direction_from_prox_step", &type::update_direction_from_prox_step},}#
-
using type = ZeroFPRParams<config_t>#
-
struct invalid_param : public invalid_argument#
- #include <alpaqa/include/alpaqa/params/params.hpp>
Custom parameter parsing exception.
-
struct ParamString#
- #include <alpaqa/include/alpaqa/params/params.hpp>
Represents a parameter value encoded as a string in the format
abc.def.key=value
.
-
template<Config Conf>
struct vec_from_file# - #include <alpaqa/include/alpaqa/params/params.hpp>
-
namespace detail#
Typedefs
-
template<class NewAlias, class ...PossibleAliases>
using possible_alias_t = std::conditional_t<any_is_same<NewAlias, PossibleAliases...>(), _dummy<NewAlias, PossibleAliases...>, NewAlias># If
NewAlias
is not the same type as any ofPossibleAliases
, the result isNewAlias
.If
NewAlias
is not distinct fromPossibleAliases
, the result is a dummy type, uniquely determined byNewAlias
andPossibleAliases
.
Functions
-
template<class A, class ...Bs>
constexpr bool any_is_same()# Check if
A
is equal to any ofBs
.
-
template<class NewAlias, class ...PossibleAliases>
-
inline auto split_key(std::string_view full, char tok = '.')#
-
namespace util#
Typedefs
-
template<class M>
using class_from_member_ptr_impl_t = typename class_from_member_ptr_impl<M>::type#
-
template<auto M>
using class_from_member_ptr_t = class_from_member_ptr_impl_t<decltype(M)>#
-
template<class ...Pack>
using first_type_or_void_t = typename first_type_or_void<Pack...>::type#
Functions
-
template<std::ranges::viewable_range R1, std::ranges::viewable_range R2, class Comp = std::ranges::less, class Proj1 = std::identity, class Proj2 = std::identity>
set_intersection_iterable<std::ranges::views::all_t<R1>, std::ranges::views::all_t<R2>, Comp, Proj1, Proj2> iter_set_intersection(R1 &&r1, R2 &&r2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {})#
-
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);
-
template<class Class, auto Method, class ...ExtraArgs>
constexpr auto type_erased_wrapped()# Returns a function that accepts a void pointer, casts it to the class type of the member function
Method
, launders it, and then invokesMethod
with it, passing on the arguments toMethod
.The function can also accept additional arguments at the end, of type
ExtraArgs
.
-
template<class VTable, class Allocator>
inline constexpr size_t default_te_buffer_size()#
-
template<class ...Types>
inline constexpr size_t required_te_buffer_size_for()#
Variables
-
template<class T>
constexpr te_in_place_t<T> te_in_place# Convenience instance of te_in_place_t.
-
class bad_type_erased_type : public logic_error#
- #include <alpaqa/include/alpaqa/util/type-erasure.hpp>
-
struct BasicVTable#
- #include <alpaqa/include/alpaqa/util/type-erasure.hpp>
Struct that stores the size of a polymorphic object, as well as pointers to functions to copy, move or destroy the object.
Inherit from this struct to add useful functions.
Subclassed by ControlProblemVTable< DefaultConfig >, ProblemVTable< DefaultConfig >, ControlProblemVTable< Conf >, ProblemVTable< Conf >
Public Types
-
template<class F>
using required_function_t = typename required_function<F>::type# A required function includes a void pointer to self, in addition to the arguments of
F
.
-
template<class F>
using required_const_function_t = typename required_const_function<F>::type# A required function includes a void pointer to self, in addition to the arguments of
F
.For const-qualified member functions.
-
template<class F, class VTable = BasicVTable>
using optional_function_t = typename optional_function<F, VTable>::type# An optional function includes a void pointer to self, the arguments of
F
, and an additional reference to the VTable, so that it can be implemented in terms of other functions.
-
template<class F, class VTable = BasicVTable>
using optional_const_function_t = typename optional_const_function<F, VTable>::type# An optional function includes a void pointer to self, the arguments of
F
, and an additional reference to the VTable, so that it can be implemented in terms of other functions.For const-qualified member functions.
Public Functions
-
BasicVTable() = default#
Public Members
-
required_const_function_t<void(void *storage)> copy = nullptr#
Copy-construct a new instance into storage.
-
required_function_t<void(void *storage)> move = nullptr#
Move-construct a new instance into storage.
-
required_function_t<void()> destroy = nullptr#
Destruct the given instance.
-
const std::type_info *type = &typeid(void)#
The original type of the stored object.
-
template<class, class VTable = BasicVTable>
struct optional_const_function#
-
template<class R, class ...Args, class VTable>
struct optional_const_function<R(Args...), VTable># - #include <alpaqa/include/alpaqa/util/type-erasure.hpp>
-
template<class, class VTable = BasicVTable>
struct optional_function#
-
template<class R, class ...Args, class VTable>
struct optional_function<R(Args...), VTable># - #include <alpaqa/include/alpaqa/util/type-erasure.hpp>
-
template<class>
struct required_const_function#
-
template<class R, class ...Args>
struct required_const_function<R(Args...)># - #include <alpaqa/include/alpaqa/util/type-erasure.hpp>
-
template<class>
struct required_function#
-
template<class F>
-
template<class M>
struct class_from_member_ptr_impl# - #include <alpaqa/include/alpaqa/util/type-traits.hpp>
- template<class C, class Ret, class... Args> *)(Args...) const >
- #include <alpaqa/include/alpaqa/util/type-traits.hpp>
Public Types
-
using type = std::add_const_t<C>#
-
using type = std::add_const_t<C>#
- template<class C, class Ret, class... Args> *)(Args...)>
- #include <alpaqa/include/alpaqa/util/type-traits.hpp>
Public Types
-
using type = C
-
using type = C
-
template<class T>
struct copyable_unique_ptr# - #include <alpaqa/include/alpaqa/util/copyable_unique_ptr.hpp>
Public Functions
-
copyable_unique_ptr() = default#
-
inline copyable_unique_ptr(const copyable_unique_ptr &o)#
-
inline copyable_unique_ptr &operator=(const copyable_unique_ptr &o)#
-
copyable_unique_ptr(copyable_unique_ptr&&) noexcept = default#
-
copyable_unique_ptr &operator=(copyable_unique_ptr&&) noexcept = default#
-
inline auto &operator*()#
-
inline auto &operator*() const#
-
copyable_unique_ptr() = default#
-
template<class Rng>
struct enumerate_t : public std::ranges::view_interface<enumerate_t<Rng>># - #include <alpaqa/include/alpaqa/util/enumerate.hpp>
Public Types
Public Functions
-
enumerate_t() = default#
-
inline auto begin() const -> std::input_or_output_iterator auto#
-
inline auto end() const#
-
struct iter_t#
- #include <alpaqa/include/alpaqa/util/enumerate.hpp>
Public Types
-
using difference_type = std::ptrdiff_t#
Public Functions
-
iter_t() = default#
-
inline bool operator!=(sentinel_t s) const#
-
inline bool operator==(sentinel_t s) const#
-
inline value_type operator*() const#
Friends
-
inline friend bool operator!=(sentinel_t s, const iter_t &i)#
-
inline friend bool operator==(sentinel_t s, const iter_t &i)#
-
using difference_type = std::ptrdiff_t#
-
struct sentinel_t#
- #include <alpaqa/include/alpaqa/util/enumerate.hpp>
-
enumerate_t() = default#
-
template<class ...Pack>
struct first_type_or_void#
-
template<class First, class ...Pack>
struct first_type_or_void<First, Pack...># - #include <alpaqa/include/alpaqa/util/type-traits.hpp>
-
template<>
struct first_type_or_void<># - #include <alpaqa/include/alpaqa/util/type-traits.hpp>
Public Types
-
using type = void#
-
using type = void#
-
template<class It>
struct iter_range_adapter# - #include <alpaqa/include/alpaqa/util/iter-adapter.hpp>
Public Functions
-
iter_range_adapter() = default#
-
inline auto begin() const & -> std::input_or_output_iterator auto#
-
inline auto begin() && -> std::input_or_output_iterator auto#
-
struct iter_t : public std::remove_cvref_t<It>#
- #include <alpaqa/include/alpaqa/util/iter-adapter.hpp>
Public Types
-
using difference_type = std::ptrdiff_t#
Public Functions
-
iter_t() = default#
-
inline bool operator!=(sentinel_t) const#
-
inline bool operator==(sentinel_t) const#
Friends
-
inline friend bool operator!=(sentinel_t s, const iter_t &i)#
-
inline friend bool operator==(sentinel_t s, const iter_t &i)#
-
using difference_type = std::ptrdiff_t#
-
struct sentinel_t#
- #include <alpaqa/include/alpaqa/util/iter-adapter.hpp>
-
iter_range_adapter() = default#
-
template<class First, class ...Pack>
struct last_type# - #include <alpaqa/include/alpaqa/util/type-traits.hpp>
-
template<class Only>
struct last_type<Only># - #include <alpaqa/include/alpaqa/util/type-traits.hpp>
Public Types
-
using type = Only
-
using type = Only
-
template<class T>
struct noop_delete# - #include <alpaqa/include/alpaqa/util/noop-delete.hpp>
Deleter for
std::unique_ptr
that just destructs the object, without deallocating.
-
template<std::ranges::input_range R1, std::ranges::input_range R2, class Comp = std::ranges::less, class Proj1 = std::identity, class Proj2 = std::identity>
struct set_intersection_iterable : public std::ranges::view_interface<set_intersection_iterable<R1, R2, std::ranges::less, std::identity, std::identity>># - #include <alpaqa/include/alpaqa/util/set-intersection.hpp>
Public Functions
-
set_intersection_iterable() = default#
-
inline set_intersection_iterable(R1 &&range1, R2 &&range2, Comp &&comp, Proj1 &&proj1, Proj2 &&proj2)#
-
inline auto begin() const -> std::input_or_output_iterator auto#
-
inline auto end() const#
-
template<std::input_iterator I1, std::sentinel_for<I1> S1, std::input_iterator I2, std::sentinel_for<I2> S2>
struct iter_t# - #include <alpaqa/include/alpaqa/util/set-intersection.hpp>
Public Types
-
using difference_type = std::ptrdiff_t#
Public Functions
-
iter_t() = default#
-
inline bool operator!=(sentinel_t) const#
-
inline bool operator==(sentinel_t s) const#
-
inline value_type operator*() const#
-
inline void advance()#
Friends
-
inline friend bool operator!=(sentinel_t s, const iter_t &i)#
-
inline friend bool operator==(sentinel_t s, const iter_t &i)#
-
using difference_type = std::ptrdiff_t#
-
struct sentinel_t#
- #include <alpaqa/include/alpaqa/util/set-intersection.hpp>
-
set_intersection_iterable() = default#
-
template<class T>
struct te_in_place_t# - #include <alpaqa/include/alpaqa/util/type-erasure.hpp>
Similar to
std::in_place_t
.
-
template<class T>
struct Timed# - #include <alpaqa/include/alpaqa/util/timed.hpp>
Public Functions
-
inline ~Timed()#
-
inline ~Timed()#
-
template<class VTable = BasicVTable, class Allocator = std::allocator<std::byte>, size_t SmallBufferSize = default_te_buffer_size<VTable, Allocator>()>
class TypeErased# - #include <alpaqa/include/alpaqa/util/type-erasure.hpp>
Class for polymorphism through type erasure.
Saves the entire vtable, and uses small buffer optimization.
Subclassed by TypeErasedControlProblem< config_t >, TypeErasedProblem< config_t >, TypeErasedControlProblem< Conf, Allocator >, TypeErasedProblem< Conf, Allocator >
Public Functions
-
TypeErased() noexcept(noexcept(allocator_type())) = default#
Default constructor.
-
template<class Alloc>
inline TypeErased(std::allocator_arg_t, const Alloc &alloc)# Default constructor (allocator aware).
-
inline TypeErased(const TypeErased &other)#
Copy constructor.
-
inline TypeErased(const TypeErased &other, allocator_type alloc)#
Copy constructor (allocator aware).
-
inline TypeErased &operator=(const TypeErased &other)#
Copy assignment.
-
inline TypeErased(TypeErased &&other) noexcept#
Move constructor.
-
inline TypeErased(TypeErased &&other, const allocator_type &alloc) noexcept#
Move constructor (allocator aware).
-
inline TypeErased &operator=(TypeErased &&other) noexcept#
Move assignment.
-
inline ~TypeErased()#
Destructor.
-
template<class T, class Alloc>
inline explicit TypeErased(std::allocator_arg_t, const Alloc &alloc, T &&d)# Main constructor that type-erases the given argument.
-
template<class T, class Alloc, class ...Args>
inline explicit TypeErased(std::allocator_arg_t, const Alloc &alloc, te_in_place_t<T>, Args&&... args)# Main constructor that type-erases the object constructed from the given argument.
-
template<class T>
inline explicit TypeErased(T &&d)# Main constructor that type-erases the given argument.
Requirement prevents this constructor from taking precedence over the copy and move constructors.
-
template<class T, class ...Args>
inline explicit TypeErased(te_in_place_t<T>, Args&&... args)# Main constructor that type-erases the object constructed from the given argument.
-
inline explicit operator bool() const noexcept#
Check if this wrapper wraps an object.
False for default-constructed objects.
-
inline allocator_type get_allocator() const noexcept#
Get a copy of the allocator.
-
inline const std::type_info &type() const noexcept#
Query the contained type.
-
template<class T>
inline T &as() &# Convert the type-erased object to the given type.
The type is checked in debug builds only, use with caution.
Public Static Functions
Public Static Attributes
-
static constexpr size_t small_buffer_size = SmallBufferSize#
-
TypeErased() noexcept(noexcept(allocator_type())) = default#
-
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 inmask
.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.
-
template<class Class, class ...ExtraArgs>
struct Launderer# - #include <alpaqa/include/alpaqa/util/type-erasure.hpp>
Public Static Functions
-
template<auto Method>
static inline constexpr auto invoker()# Returns a function that accepts a void pointer, casts it to the class type of the member function
Method
, launders it, and then invokesMethod
with it, passing on the arguments toMethod
.The function can also accept additional arguments at the end, of type
ExtraArgs
.
-
template<auto Method>
-
template<class SpMat, class MaskVec>
-
template<class M>
-
namespace vec_util#
-
template<Config Conf = DefaultConfig>