aligator  0.14.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
linear-function.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace aligator {
9template <typename Scalar> struct LinearFunctionTpl : StageFunctionTpl<Scalar> {
10 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
14
15 MatrixXs A_;
16 MatrixXs B_;
17 VectorXs d_;
18
19 LinearFunctionTpl(const int ndx, const int nu, const int nr);
20
21 LinearFunctionTpl(const ConstMatrixRef A, const ConstMatrixRef B,
22 const ConstVectorRef d);
23
24 void evaluate(const ConstVectorRef &x, const ConstVectorRef &u,
25 Data &data) const override {
26 data.value_ = d_;
27 data.value_.noalias() += A_ * x;
28 data.value_.noalias() += B_ * u;
29 }
30
36 void computeJacobians(const ConstVectorRef &, const ConstVectorRef &,
37 Data &data) const override {
38 data.Jx_ = A_;
39 data.Ju_ = B_;
40 }
41
44 virtual shared_ptr<Data> createData() const override {
45 auto data = std::make_shared<Data>(this->ndx1, this->nu, this->nr);
46 data->Jx_ = A_;
47 data->Ju_ = B_;
48 return data;
49 }
50};
51
52template <typename Scalar>
54 const int nr)
55 : Base(ndx, nu, nr)
56 , A_(nr, ndx)
57 , B_(nr, nu)
58 , d_(nr) {
59 A_.setZero();
60 B_.setZero();
61 d_.setZero();
62}
63
64template <typename Scalar>
66 const ConstMatrixRef B,
67 const ConstVectorRef d)
68 : Base((int)A.cols(), (int)B.cols(), (int)d.rows())
69 , A_(A)
70 , B_(B)
71 , d_(d) {
72 assert((A_.rows() == d_.rows()) && (B_.rows() == d_.rows()) &&
73 "Number of rows not consistent.");
74}
75
76} // namespace aligator
Base definitions for ternary functions.
Main package namespace.
void computeJacobians(const ConstVectorRef &, const ConstVectorRef &, Data &data) const override
Compute Jacobians of this function.
StageFunctionTpl< Scalar > Base
virtual shared_ptr< Data > createData() const override
Instantiate a Data object.
void evaluate(const ConstVectorRef &x, const ConstVectorRef &u, Data &data) const override
Evaluate the function.
LinearFunctionTpl(const int ndx, const int nu, const int nr)
StageFunctionDataTpl< Scalar > Data
Base struct for function data.
StageFunctionTpl(const int ndx, const int nu, const int nr)