aligator  0.6.1
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
function-abstract.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include "aligator/fwd.hpp"
8
9#include <fmt/format.h>
10#include <ostream>
11
12namespace aligator {
13
15template <typename _Scalar>
17 : std::enable_shared_from_this<StageFunctionTpl<_Scalar>> {
18public:
19 using Scalar = _Scalar;
21 using Data = StageFunctionDataTpl<Scalar>;
22
24 const int ndx1;
26 const int nu;
28 const int ndx2;
30 const int nr;
31
32 StageFunctionTpl(const int ndx1, const int nu, const int ndx2, const int nr);
33
35 StageFunctionTpl(const int ndx, const int nu, const int nr);
36
44 virtual void evaluate(const ConstVectorRef &x, const ConstVectorRef &u,
45 const ConstVectorRef &y, Data &data) const = 0;
46
61 virtual void computeJacobians(const ConstVectorRef &x,
62 const ConstVectorRef &u,
63 const ConstVectorRef &y, Data &data) const = 0;
64
73 virtual void computeVectorHessianProducts(const ConstVectorRef &x,
74 const ConstVectorRef &u,
75 const ConstVectorRef &y,
76 const ConstVectorRef &lbda,
77 Data &data) const;
78
79 virtual ~StageFunctionTpl() = default;
80
82 virtual shared_ptr<Data> createData() const;
83};
84
86template <typename _Scalar>
87struct StageFunctionDataTpl : Cloneable<StageFunctionDataTpl<_Scalar>> {
88 using Scalar = _Scalar;
90 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
91
92 const int ndx1;
93 const int nu;
94 const int ndx2;
95 const int nr;
97 const int nvar = ndx1 + nu + ndx2;
98
100 VectorXs value_;
101 VectorRef valref_;
103 MatrixXs jac_buffer_;
105 MatrixXs vhp_buffer_;
107 MatrixRef Jx_;
109 MatrixRef Ju_;
111 MatrixRef Jy_;
112
113 /* Vector-Hessian product buffers */
114
115 MatrixRef Hxx_;
116 MatrixRef Hxu_;
117 MatrixRef Hxy_;
118 MatrixRef Huu_;
119 MatrixRef Huy_;
120 MatrixRef Hyy_;
121
123 StageFunctionDataTpl(const int ndx1, const int nu, const int ndx2,
124 const int nr);
125 virtual ~StageFunctionDataTpl() = default;
126
127 template <typename T>
128 friend std::ostream &operator<<(std::ostream &oss,
129 const StageFunctionDataTpl<T> &self);
130
131protected:
133 return new StageFunctionDataTpl(*this);
134 }
135};
136
137} // namespace aligator
138
139#include "aligator/core/function-abstract.hxx"
140
141#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
142#include "aligator/core/function-abstract.txx"
143#endif
Forward declarations.
Main package namespace.
Mixin which makes a class/class hierarchy cloneable.
Definition clone.hpp:12
MatrixRef Jx_
Jacobian with respect to .
MatrixXs vhp_buffer_
Vector-Hessian product buffer.
StageFunctionDataTpl(const int ndx1, const int nu, const int ndx2, const int nr)
Default constructor.
const int nvar
Total number of variables.
friend std::ostream & operator<<(std::ostream &oss, const StageFunctionDataTpl< T > &self)
MatrixRef Ju_
Jacobian with respect to .
virtual StageFunctionDataTpl * clone_impl() const
MatrixRef Jy_
Jacobian with respect to .
virtual ~StageFunctionDataTpl()=default
Class representing ternary functions .
const int ndx2
Next state dimension.
virtual ~StageFunctionTpl()=default
const int nu
Control dimension.
virtual void computeJacobians(const ConstVectorRef &x, const ConstVectorRef &u, const ConstVectorRef &y, Data &data) const =0
Compute Jacobians of this function.
virtual void computeVectorHessianProducts(const ConstVectorRef &x, const ConstVectorRef &u, const ConstVectorRef &y, const ConstVectorRef &lbda, Data &data) const
Compute the vector-hessian products of this function.
virtual shared_ptr< Data > createData() const
Instantiate a Data object.
const int ndx1
Current state dimension.
virtual void evaluate(const ConstVectorRef &x, const ConstVectorRef &u, const ConstVectorRef &y, Data &data) const =0
Evaluate the function.
const int nr
Function codimension.
StageFunctionTpl(const int ndx, const int nu, const int nr)
Constructor where ndx2 = ndx1.
StageFunctionTpl(const int ndx1, const int nu, const int ndx2, const int nr)