aligator  0.10.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 : Base(ndx, nu, nr), A_(nr, ndx), B_(nr, nu), d_(nr) {
21 A_.setZero();
22 B_.setZero();
23 d_.setZero();
24 }
25
26 LinearFunctionTpl(const ConstMatrixRef A, const ConstMatrixRef B,
27 const ConstVectorRef d)
28 : Base((int)A.cols(), (int)B.cols(), (int)d.rows()), A_(A), B_(B), d_(d) {
29 assert((A_.rows() == d_.rows()) && (B_.rows() == d_.rows()) &&
30 "Number of rows not consistent.");
31 }
32
33 void evaluate(const ConstVectorRef &x, const ConstVectorRef &u,
34 Data &data) const override {
35 data.value_ = d_;
36 data.value_.noalias() += A_ * x;
37 data.value_.noalias() += B_ * u;
38 }
39
45 void computeJacobians(const ConstVectorRef &, const ConstVectorRef &,
46 Data &data) const override {
47 data.Jx_ = A_;
48 data.Ju_ = B_;
49 }
50
53 virtual shared_ptr<Data> createData() const override {
54 auto data = std::make_shared<Data>(this->ndx1, this->nu, this->nr);
55 data->Jx_ = A_;
56 data->Ju_ = B_;
57 return data;
58 }
59};
60
61} // 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.
LinearFunctionTpl(const ConstMatrixRef A, const ConstMatrixRef B, const ConstVectorRef d)
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)
Base struct for function data.
Definition fwd.hpp:59
Class representing ternary functions .
Definition fwd.hpp:53
const int nu
Control dimension.
const int nr
Function codimension.
const int ndx1
Current state dimension.