aligator  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
linear-ode.hpp
Go to the documentation of this file.
1
2#pragma once
3
5#include <proxsuite-nlp/modelling/spaces/vector-space.hpp>
6
7namespace aligator {
8namespace dynamics {
14template <typename _Scalar> struct LinearODETpl : ODEAbstractTpl<_Scalar> {
15 using Scalar = _Scalar;
19 using Manifold = ManifoldAbstractTpl<Scalar>;
20 using ManifoldPtr = xyz::polymorphic<Manifold>;
21
22 MatrixXs A_, B_;
23 VectorXs c_;
24
27 LinearODETpl(const ManifoldPtr &space, const MatrixXs &A, const MatrixXs &B,
28 const VectorXs &c)
29 : Base(space, (int)B.cols()), A_(A), B_(B), c_(c) {
30 if (A.cols() != space->ndx()) {
31 ALIGATOR_DOMAIN_ERROR(fmt::format(
32 "A.cols() should be equal to space.ndx()! (got {:d} and {:d})",
33 A.cols(), space->ndx()));
34 }
35 bool rows_ok = (A.rows() == space->ndx()) && (B.rows() == space->ndx()) &&
36 (c.rows() == space->ndx());
37 if (!rows_ok) {
38 ALIGATOR_DOMAIN_ERROR("Input matrices have wrong number of rows.");
39 }
40 }
41
46 LinearODETpl(const MatrixXs &A, const MatrixXs &B, const VectorXs &c)
47 : LinearODETpl(xyz::polymorphic<Manifold>(
48 proxsuite::nlp::VectorSpaceTpl<Scalar>((int)A.rows())),
49 A, B, c) {}
50
51 void forward(const ConstVectorRef &x, const ConstVectorRef &u,
52 ODEData &data) const;
53 void dForward(const ConstVectorRef &x, const ConstVectorRef &u,
54 ODEData &data) const;
55 virtual shared_ptr<ContinuousDynamicsDataTpl<Scalar>> createData() const {
56 auto data = Base::createData();
57 data->Jx_ = A_;
58 data->Ju_ = B_;
59 return data;
60 }
61};
62
63} // namespace dynamics
64} // namespace aligator
65
66#include "aligator/modelling/dynamics/linear-ode.hxx"
67
68#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
69#include "aligator/modelling/dynamics/linear-ode.txx"
70#endif
#define ALIGATOR_DOMAIN_ERROR(msg)
Main package namespace.
Defines a class representing ODEs.
Data struct for ContinuousDynamicsAbstractTpl.
Definition fwd.hpp:15
Linear ordinary differential equation .
ManifoldAbstractTpl< Scalar > Manifold
xyz::polymorphic< Manifold > ManifoldPtr
LinearODETpl(const MatrixXs &A, const MatrixXs &B, const VectorXs &c)
void forward(const ConstVectorRef &x, const ConstVectorRef &u, ODEData &data) const
Evaluate the ODE vector field: this returns the value of .
virtual shared_ptr< ContinuousDynamicsDataTpl< Scalar > > createData() const
Create a data holder instance.
void dForward(const ConstVectorRef &x, const ConstVectorRef &u, ODEData &data) const
Evaluate the vector field Jacobians.
LinearODETpl(const ManifoldPtr &space, const MatrixXs &A, const MatrixXs &B, const VectorXs &c)
Standard constructor with state space, matrices and constant term .
Base class for ODE dynamics .