alpaqa pantr
Nonconvex constrained optimization
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TypeErasedControlProblem< Conf, Allocator > Class Template Reference

#include <alpaqa/include/alpaqa/problem/ocproblem.hpp>

Detailed Description

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
class alpaqa::TypeErasedControlProblem< Conf, Allocator >

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

\[ \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} \]

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{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} \]

See [3] for more details.

Definition at line 243 of file ocproblem.hpp.

+ Inheritance diagram for TypeErasedControlProblem< Conf, Allocator >:
+ Collaboration diagram for TypeErasedControlProblem< Conf, Allocator >:

Problem dimensions

length_t get_N () const
 Horizon length.
 
length_t get_nu () const
 Number of inputs.
 
length_t get_nx () const
 Number of states.
 
length_t get_nh () const
 Number of outputs.
 
length_t get_nh_N () const
 
length_t get_nc () const
 Number of constraints.
 
length_t get_nc_N () const
 
Dim get_dim () const
 All dimensions.
 
length_t get_n () const
 Total number of variables.
 
length_t get_m () const
 Total number of constraints.
 

Projections onto constraint sets

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 \).
 
void eval_proj_multipliers (rvec y, real_t M) const
 [Required] Function that projects the Lagrange multipliers for ALM.
 

Constraint sets

void get_U (Box &U) const
 Input box constraints \( U \).
 
void get_D (Box &D) const
 Stage box constraints \( D \).
 
void get_D_N (Box &D) const
 Terminal box constraints \( D_N \).
 

Dynamics and initial state

void get_x_init (rvec x_init) const
 Initial state \( x_\text{init} \).
 
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) \).
 
void eval_jac_f (index_t timestep, crvec x, crvec u, rmat J_fxu) const
 Jacobian of discrete-time dynamics \( \jac_f(x^k, u^k) \).
 
void eval_grad_f_prod (index_t timestep, crvec x, crvec u, crvec p, rvec grad_fxu_p) const
 Gradient-vector product of discrete-time dynamics \( \nabla f(x^k, u^k)\,p \).
 

Output mapping

void eval_h (index_t timestep, crvec x, crvec u, rvec h) const
 Stage output mapping \( h_k(x^k, u^k) \).
 
void eval_h_N (crvec x, rvec h) const
 Terminal output mapping \( h_N(x^N) \).
 

Stage and terminal cost

real_t eval_l (index_t timestep, crvec h) const
 Stage cost \( \ell_k(\hbar^k) \).
 
real_t eval_l_N (crvec h) const
 Terminal cost \( \ell_N(\hbar^N) \).
 

Gauss-Newton approximations

void eval_qr (index_t timestep, crvec xu, crvec h, rvec qr) const
 Cost gradients w.r.t.
 
void eval_q_N (crvec x, crvec h, rvec q) const
 Terminal cost gradient w.r.t.
 
void eval_add_Q (index_t timestep, crvec xu, crvec h, rmat Q) const
 Cost Hessian w.r.t.
 
void eval_add_Q_N (crvec x, crvec h, rmat Q) const
 Terminal cost Hessian w.r.t.
 
void eval_add_R_masked (index_t timestep, crvec xu, crvec h, crindexvec mask, rmat R, rvec work) const
 Cost Hessian w.r.t.
 
void eval_add_S_masked (index_t timestep, crvec xu, crvec h, crindexvec mask, rmat S, rvec work) const
 Cost Hessian w.r.t.
 
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] \).
 
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] \).
 
length_t get_R_work_size () const
 Size of the workspace required by eval_add_R_masked() and eval_add_R_prod_masked().
 
length_t get_S_work_size () const
 Size of the workspace required by eval_add_S_masked() and eval_add_S_prod_masked().
 

Constraints

void eval_constr (index_t timestep, crvec x, rvec c) const
 Stage constraints \( c_k(x^k) \).
 
void eval_constr_N (crvec x, rvec c) const
 Terminal constraints \( c_N(x^N) \).
 
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 \).
 
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 \).
 
void eval_add_gn_hess_constr (index_t timestep, crvec x, crvec M, rmat out) const
 Gauss-Newton Hessian of stage constraints \( \tp{\jac_{c_k}}(x^k)\, \operatorname{diag}(M)\; \jac_{c_k}(x^k) \).
 
void eval_add_gn_hess_constr_N (crvec x, crvec M, rmat out) const
 Gauss-Newton Hessian of terminal constraints \( \tp{\jac_{c_N}}(x^N)\, \operatorname{diag}(M)\; \jac_{c_N}(x^N) \).
 

Checks

void check () const
 Check that the problem formulation is well-defined, the dimensions match, etc.
 

Querying specialized implementations

bool provides_get_D () const
 
bool provides_get_D_N () const
 
bool provides_eval_h () const
 
bool provides_eval_h_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
 

Public Types

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

Public Member Functions

 TypeErased () noexcept(noexcept(allocator_type()))=default
 Default constructor.
 
template<class Alloc >
 TypeErased (std::allocator_arg_t, const Alloc &alloc)
 Default constructor (allocator aware).
 
 TypeErased (const TypeErased &other)
 Copy constructor.
 
 TypeErased (const TypeErased &other, allocator_type alloc)
 Copy constructor (allocator aware).
 
 TypeErased (TypeErased &&other) noexcept
 Move constructor.
 
 TypeErased (TypeErased &&other, const allocator_type &alloc) noexcept
 Move constructor (allocator aware).
 
template<class T , class Alloc >
 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>
 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 >
requires no_child_of_ours<T>
 TypeErased (T &&d)
 
template<class T , class... Args>
 TypeErased (te_in_place_t< T >, Args &&...args)
 Main constructor that type-erases the object constructed from the given argument.
 
 operator bool () const noexcept
 Check if this wrapper wraps an object.
 
allocator_type get_allocator () const noexcept
 Get a copy of the allocator.
 
const std::type_info & type () const noexcept
 Query the contained type.
 
template<class T >
T & as () &
 Convert the type-erased object to the given type.
 
template<class T >
const T & as () const &
 Convert the type-erased object to the given type.
 
template<class T >
const T && as () &&
 Convert the type-erased object to the given type.
 

Static Public Member Functions

template<class T , class... Args>
static TypeErasedControlProblem make (Args &&...args)
 
template<class Ret , class T , class Alloc , class... Args>
requires std::is_base_of_v<TypeErased, Ret>
static Ret make (std::allocator_arg_t tag, const Alloc &alloc, Args &&...args)
 Construct a type-erased wrapper of type Ret for an object of type T, initialized in-place with the given arguments.
 

Static Public Attributes

static constexpr size_t small_buffer_size = SmallBufferSize
 

Protected Member Functions

template<class Ret , class... FArgs, class... Args>
decltype(auto) call (Ret(*f)(const void *, FArgs...), Args &&...args) const
 Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
 
template<class Ret , class... FArgs, class... Args>
decltype(auto) call (Ret(*f)(void *, FArgs...), Args &&...args)
 Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
 
template<class Ret >
decltype(auto) call (Ret(*f)(const void *)) const
 Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
 
template<class Ret >
decltype(auto) call (Ret(*f)(void *))
 Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
 
template<class Ret >
decltype(auto) call (Ret(*f)(const void *, const VTable &)) const
 Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
 
template<class Ret >
decltype(auto) call (Ret(*f)(void *, const VTable &))
 Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
 
template<class T , class... Args>
void construct_inplace (Args &&...args)
 Ensure storage and construct the type-erased object of type T in-place.
 
template<class Ret >
decltype(auto) call (Ret(*f)(const void *, const VTable &)) const
 Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
 
template<class Ret >
decltype(auto) call (Ret(*f)(void *, const VTable &))
 Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.
 

Protected Attributes

void * self
 Pointer to the stored object.
 
VTable vtable
 
size_t size = invalid_size
 Size required to store the object.
 

Static Protected Attributes

static constexpr size_t invalid_size
 

Private Types

using allocator_traits = std::allocator_traits< allocator_type >
 
using buffer_type = std::array< std::byte, small_buffer_size >
 

Private Member Functions

Deallocator allocate (size_t size)
 Ensure that storage is available, either by using the small buffer if it is large enough, or by calling the allocator.
 
void deallocate ()
 Deallocate the memory without invoking the destructor.
 
void cleanup ()
 Destroy the type-erased object (if not empty), and deallocate the memory if necessary.
 
template<bool CopyAllocator>
void do_copy_assign (const TypeErased &other)
 

Private Attributes

buffer_type small_buffer
 
allocator_type allocator
 

Static Private Attributes

template<class T >
static constexpr auto no_child_of_ours
 True if T is not a child class of TypeErased.
 

Member Typedef Documentation

◆ VTable

using VTable = ControlProblemVTable<config_t>

Definition at line 246 of file ocproblem.hpp.

◆ allocator_type

using allocator_type = Allocator

Definition at line 247 of file ocproblem.hpp.

◆ Box

using Box = typename VTable::Box

Definition at line 248 of file ocproblem.hpp.

◆ Dim

using Dim = OCPDim<config_t>

Definition at line 249 of file ocproblem.hpp.

◆ TypeErased

Definition at line 250 of file ocproblem.hpp.

◆ allocator_traits

using allocator_traits = std::allocator_traits<allocator_type>
privateinherited

Definition at line 203 of file type-erasure.hpp.

◆ buffer_type

using buffer_type = std::array<std::byte, small_buffer_size>
privateinherited

Definition at line 204 of file type-erasure.hpp.

Member Function Documentation

◆ make() [1/2]

static TypeErasedControlProblem make ( Args &&...  args)
inlinestatic

Definition at line 260 of file ocproblem.hpp.

◆ get_N()

length_t get_N ( ) const
inline

Horizon length.

Definition at line 268 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ get_nu()

length_t get_nu ( ) const
inline

Number of inputs.

Definition at line 270 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ get_nx()

length_t get_nx ( ) const
inline

Number of states.

Definition at line 272 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ get_nh()

length_t get_nh ( ) const
inline

Number of outputs.

Definition at line 274 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ get_nh_N()

length_t get_nh_N ( ) const
inline

Definition at line 275 of file ocproblem.hpp.

◆ get_nc()

length_t get_nc ( ) const
inline

Number of constraints.

Definition at line 277 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ get_nc_N()

length_t get_nc_N ( ) const
inline

Definition at line 278 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ get_dim()

Dim get_dim ( ) const
inline

All dimensions.

Definition at line 280 of file ocproblem.hpp.

◆ get_n()

length_t get_n ( ) const
inline

Total number of variables.

Definition at line 292 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ get_m()

length_t get_m ( ) const
inline

Total number of constraints.

Definition at line 294 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ eval_proj_diff_g()

void eval_proj_diff_g ( crvec  z,
rvec  e 
) const
inline

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

Parameters
[in]zSlack variable, \( z \in \R^m \)
[out]eThe difference relative to its projection, \( e = z - \Pi_D(z) \in \R^m \)
Note
z and e can refer to the same vector.

Definition at line 525 of file ocproblem.hpp.

◆ eval_proj_multipliers()

void eval_proj_multipliers ( rvec  y,
real_t  M 
) const
inline

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

Parameters
[in,out]yMultipliers, \( y \leftarrow \Pi_Y(y) \in \R^m \)
[in]MThe radius/size of the set \( Y \). See ALMParams::max_multiplier.

Definition at line 526 of file ocproblem.hpp.

◆ get_U()

void get_U ( Box U) const
inline

Input box constraints \( U \).

Definition at line 527 of file ocproblem.hpp.

◆ get_D()

void get_D ( Box D) const
inline

Stage box constraints \( D \).

Definition at line 528 of file ocproblem.hpp.

◆ get_D_N()

void get_D_N ( Box D) const
inline

Terminal box constraints \( D_N \).

Definition at line 529 of file ocproblem.hpp.

◆ get_x_init()

void get_x_init ( rvec  x_init) const
inline

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

Definition at line 530 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ eval_f()

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

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

Definition at line 531 of file ocproblem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eval_jac_f()

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

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

Definition at line 532 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ eval_grad_f_prod()

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

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

Definition at line 533 of file ocproblem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eval_h()

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

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

Definition at line 534 of file ocproblem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eval_h_N()

void eval_h_N ( crvec  x,
rvec  h 
) const
inline

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

Definition at line 535 of file ocproblem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eval_l()

auto eval_l ( index_t  timestep,
crvec  h 
) const
inline

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

Definition at line 536 of file ocproblem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eval_l_N()

auto eval_l_N ( crvec  h) const
inline

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

Definition at line 537 of file ocproblem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eval_qr()

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

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) \).

Definition at line 538 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ eval_q_N()

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

Terminal cost gradient w.r.t.

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

Definition at line 539 of file ocproblem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eval_add_Q()

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

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 \).

Definition at line 540 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ eval_add_Q_N()

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

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 \).

Definition at line 541 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ eval_add_R_masked()

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

Cost Hessian w.r.t.

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

Definition at line 542 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ eval_add_S_masked()

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

Cost Hessian w.r.t.

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

Definition at line 543 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ eval_add_R_prod_masked()

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

\( 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.

Definition at line 544 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ eval_add_S_prod_masked()

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

\( 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.

Definition at line 545 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ get_R_work_size()

auto get_R_work_size
inline

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

Definition at line 546 of file ocproblem.hpp.

◆ get_S_work_size()

auto get_S_work_size
inline

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

Definition at line 547 of file ocproblem.hpp.

◆ eval_constr()

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

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

Definition at line 548 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ eval_constr_N()

void eval_constr_N ( crvec  x,
rvec  c 
) const
inline

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

Definition at line 549 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ eval_grad_constr_prod()

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

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

Definition at line 550 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ eval_grad_constr_prod_N()

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

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

Definition at line 551 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ eval_add_gn_hess_constr()

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

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

Definition at line 552 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ eval_add_gn_hess_constr_N()

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

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

Definition at line 553 of file ocproblem.hpp.

+ Here is the caller graph for this function:

◆ check()

void check
inline

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

Throws an exception if this is not the case.

Definition at line 554 of file ocproblem.hpp.

◆ provides_get_D()

bool provides_get_D ( ) const
inline

Definition at line 455 of file ocproblem.hpp.

◆ provides_get_D_N()

bool provides_get_D_N ( ) const
inline

Definition at line 456 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ provides_eval_h()

bool provides_eval_h ( ) const
inline

Definition at line 457 of file ocproblem.hpp.

◆ provides_eval_h_N()

bool provides_eval_h_N ( ) const
inline

Definition at line 458 of file ocproblem.hpp.

◆ provides_eval_add_Q_N()

bool provides_eval_add_Q_N ( ) const
inline

Definition at line 459 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ provides_eval_add_R_prod_masked()

bool provides_eval_add_R_prod_masked ( ) const
inline

Definition at line 460 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ provides_eval_add_S_prod_masked()

bool provides_eval_add_S_prod_masked ( ) const
inline

Definition at line 461 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ provides_get_R_work_size()

bool provides_get_R_work_size ( ) const
inline

Definition at line 462 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ provides_get_S_work_size()

bool provides_get_S_work_size ( ) const
inline

Definition at line 463 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ provides_eval_constr()

bool provides_eval_constr ( ) const
inline

Definition at line 464 of file ocproblem.hpp.

◆ provides_eval_constr_N()

bool provides_eval_constr_N ( ) const
inline

Definition at line 465 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ provides_eval_grad_constr_prod()

bool provides_eval_grad_constr_prod ( ) const
inline

Definition at line 466 of file ocproblem.hpp.

◆ provides_eval_grad_constr_prod_N()

bool provides_eval_grad_constr_prod_N ( ) const
inline

Definition at line 467 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ provides_eval_add_gn_hess_constr()

bool provides_eval_add_gn_hess_constr ( ) const
inline

Definition at line 468 of file ocproblem.hpp.

◆ provides_eval_add_gn_hess_constr_N()

bool provides_eval_add_gn_hess_constr_N ( ) const
inline

Definition at line 469 of file ocproblem.hpp.

+ Here is the call graph for this function:

◆ TypeErased() [1/10]

TypeErased ( )
defaultnoexcept

Default constructor.

◆ TypeErased() [2/10]

TypeErased ( std::allocator_arg_t  ,
const Alloc &  alloc 
)
inline

Default constructor (allocator aware).

Definition at line 228 of file type-erasure.hpp.

◆ TypeErased() [3/10]

TypeErased ( const TypeErased other)
inline

Copy constructor.

Definition at line 230 of file type-erasure.hpp.

◆ TypeErased() [4/10]

TypeErased ( const TypeErased other,
allocator_type  alloc 
)
inline

Copy constructor (allocator aware).

Definition at line 236 of file type-erasure.hpp.

◆ TypeErased() [5/10]

TypeErased ( TypeErased &&  other)
inlinenoexcept

Move constructor.

Definition at line 252 of file type-erasure.hpp.

◆ TypeErased() [6/10]

TypeErased ( TypeErased &&  other,
const allocator_type alloc 
)
inlinenoexcept

Move constructor (allocator aware).

Definition at line 270 of file type-erasure.hpp.

◆ TypeErased() [7/10]

TypeErased ( std::allocator_arg_t  ,
const Alloc &  alloc,
T &&  d 
)
inlineexplicit

Main constructor that type-erases the given argument.

Definition at line 355 of file type-erasure.hpp.

◆ TypeErased() [8/10]

TypeErased ( std::allocator_arg_t  ,
const Alloc &  alloc,
te_in_place_t< T >  ,
Args &&...  args 
)
inlineexplicit

Main constructor that type-erases the object constructed from the given argument.

Definition at line 362 of file type-erasure.hpp.

◆ TypeErased() [9/10]

TypeErased ( T &&  d)
inlineexplicit

Requirement prevents this constructor from taking precedence over the copy and move constructors.

Definition at line 372 of file type-erasure.hpp.

◆ TypeErased() [10/10]

TypeErased ( te_in_place_t< T >  ,
Args &&...  args 
)
inlineexplicit

Main constructor that type-erases the object constructed from the given argument.

Definition at line 378 of file type-erasure.hpp.

◆ call() [1/8]

decltype(auto) call ( Ret(*)(const void *, FArgs...)  f,
Args &&...  args 
) const
inlineprotected

Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.

Definition at line 517 of file type-erasure.hpp.

◆ call() [2/8]

decltype(auto) call ( Ret(*)(void *, FArgs...)  f,
Args &&...  args 
)
inlineprotected

Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.

Definition at line 529 of file type-erasure.hpp.

◆ call() [3/8]

decltype(auto) call ( Ret(*)(const void *)  f) const
inlineprotected

Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.

Definition at line 541 of file type-erasure.hpp.

◆ call() [4/8]

decltype(auto) call ( Ret(*)(void *)  f)
inlineprotected

Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.

Definition at line 548 of file type-erasure.hpp.

◆ call() [5/8]

decltype(auto) call ( Ret(*)(const void *, const VTable &)  f) const
inlineprotected

Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.

Definition at line 555 of file type-erasure.hpp.

◆ call() [6/8]

decltype(auto) call ( Ret(*)(void *, const VTable &)  f)
inlineprotected

Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.

Definition at line 563 of file type-erasure.hpp.

◆ make() [2/2]

static Ret make ( std::allocator_arg_t  tag,
const Alloc &  alloc,
Args &&...  args 
)
inlinestaticinherited

Construct a type-erased wrapper of type Ret for an object of type T, initialized in-place with the given arguments.

Definition at line 386 of file type-erasure.hpp.

◆ operator bool()

operator bool ( ) const
inlineexplicitnoexceptinherited

Check if this wrapper wraps an object.

False for default-constructed objects.

Definition at line 403 of file type-erasure.hpp.

◆ get_allocator()

allocator_type get_allocator ( ) const
inlinenoexceptinherited

Get a copy of the allocator.

Definition at line 406 of file type-erasure.hpp.

◆ type()

const std::type_info & type ( ) const
inlinenoexceptinherited

Query the contained type.

Definition at line 409 of file type-erasure.hpp.

+ Here is the caller graph for this function:

◆ as() [1/3]

T & as ( ) &
inlineinherited

Convert the type-erased object to the given type.

The type is checked in debug builds only, use with caution.

Definition at line 416 of file type-erasure.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ as() [2/3]

const T & as ( ) const &
inlineinherited

Convert the type-erased object to the given type.

The type is checked in debug builds only, use with caution.

Definition at line 423 of file type-erasure.hpp.

+ Here is the call graph for this function:

◆ as() [3/3]

const T && as ( ) &&
inlineinherited

Convert the type-erased object to the given type.

The type is checked in debug builds only, use with caution.

Definition at line 430 of file type-erasure.hpp.

+ Here is the call graph for this function:

◆ allocate()

Deallocator allocate ( size_t  size)
inlineprivateinherited

Ensure that storage is available, either by using the small buffer if it is large enough, or by calling the allocator.

Returns a RAII wrapper that deallocates the storage unless released.

Definition at line 453 of file type-erasure.hpp.

+ Here is the caller graph for this function:

◆ deallocate()

void deallocate ( )
inlineprivateinherited

Deallocate the memory without invoking the destructor.

Definition at line 463 of file type-erasure.hpp.

+ Here is the caller graph for this function:

◆ cleanup()

void cleanup ( )
inlineprivateinherited

Destroy the type-erased object (if not empty), and deallocate the memory if necessary.

Definition at line 473 of file type-erasure.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_copy_assign()

void do_copy_assign ( const TypeErased< VTable, Allocator, SmallBufferSize > &  other)
inlineprivateinherited

Definition at line 481 of file type-erasure.hpp.

+ Here is the call graph for this function:

◆ construct_inplace()

void construct_inplace ( Args &&...  args)
inlineprotectedinherited

Ensure storage and construct the type-erased object of type T in-place.

Definition at line 501 of file type-erasure.hpp.

+ Here is the call graph for this function:

◆ call() [7/8]

decltype(auto) call ( Ret(*)(const void *, const VTable &)  f) const
inlineprotectedinherited

Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.

Definition at line 555 of file type-erasure.hpp.

◆ call() [8/8]

decltype(auto) call ( Ret(*)(void *, const VTable &)  f)
inlineprotectedinherited

Call the vtable function f with the given arguments args, implicitly passing the self pointer and vtable reference if necessary.

Definition at line 563 of file type-erasure.hpp.

Member Data Documentation

◆ self

void* self
protected

Pointer to the stored object.

Definition at line 218 of file type-erasure.hpp.

◆ vtable

VTable vtable
protected

Definition at line 221 of file type-erasure.hpp.

◆ small_buffer_size

constexpr size_t small_buffer_size = SmallBufferSize
staticconstexprinherited

Definition at line 199 of file type-erasure.hpp.

◆ small_buffer

buffer_type small_buffer
privateinherited

Definition at line 205 of file type-erasure.hpp.

◆ allocator

allocator_type allocator
privateinherited

Definition at line 206 of file type-erasure.hpp.

◆ no_child_of_ours

constexpr auto no_child_of_ours
staticconstexprprivateinherited
Initial value:
=
!std::is_base_of_v<TypeErased, std::remove_cvref_t<T>>

True if T is not a child class of TypeErased.

Definition at line 211 of file type-erasure.hpp.

◆ invalid_size

constexpr size_t invalid_size
staticconstexprprotectedinherited
Initial value:
=
static_cast<size_t>(0xDEADBEEFDEADBEEF)

Definition at line 215 of file type-erasure.hpp.

◆ size

size_t size = invalid_size
protectedinherited

Size required to store the object.

Definition at line 220 of file type-erasure.hpp.


The documentation for this class was generated from the following file: