aligator  0.9.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
expose-dynamics.cpp
Go to the documentation of this file.
1
6#include <proxsuite-nlp/manifold-base.hpp>
7
8namespace aligator {
9namespace python {
10
11// fwd declaration
13// fwd declaration, see expose-explicit-dynamics.cpp
15
20
23using PolyManifold = xyz::polymorphic<context::Manifold>;
24
26
27 using PyDynamicsModel = PyDynamics<DynamicsModel>;
28 using PolyDynamicsModel = xyz::polymorphic<DynamicsModel>;
29
30 register_polymorphic_to_python<PolyDynamicsModel>();
31 StdVectorPythonVisitor<std::vector<PolyDynamicsModel>, true>::expose(
32 "StdVec_Dynamics",
33 eigenpy::details::overload_base_get_item_for_std_vector<
34 std::vector<PolyDynamicsModel>>{});
35 bp::class_<PyDynamicsModel, boost::noncopyable>(
36 "DynamicsModel",
37 "Dynamics models are specific ternary functions f(x,u,x') which map "
38 "to the tangent bundle of the next state variable x'.",
39 bp::init<PolyManifold, int>(("self"_a, "space", "nu")))
40 .def(bp::init<PolyManifold, int, PolyManifold>(
41 bp::args("self", "space", "nu", "space_next")))
42 .def_readonly("space", &DynamicsModel::space_)
43 .def_readonly("space_next", &DynamicsModel::space_next_)
44 .add_property("nx1", &DynamicsModel::nx1)
45 .add_property("nx2", &DynamicsModel::nx2)
46 .def_readonly("ndx1", &DynamicsModel::ndx1)
47 .def_readonly("nu", &DynamicsModel::nu)
48 .def_readonly("ndx2", &DynamicsModel::ndx2)
49 .add_property("isExplicit", &DynamicsModel::isExplicit,
50 "Return whether the current model is explicit.")
51 .def("evaluate", &DynamicsModel::evaluate,
52 ("self"_a, "x", "u", "y", "data"))
53 .def("computeJacobians", &DynamicsModel::computeJacobians,
54 ("self"_a, "x", "u", "y", "data"))
55 .def("computeVectorHessianProducts",
56 &DynamicsModel::computeVectorHessianProducts,
57 ("self"_a, "x", "u", "y", "lbda", "data"))
60 .enable_pickling_(true);
61
62 bp::register_ptr_to_python<shared_ptr<DynamicsData>>();
63 bp::class_<DynamicsData, boost::noncopyable>("DynamicsData", bp::no_init)
64 .def(bp::init<const DynamicsModel &>(("self"_a, "model")))
65 .add_property(
66 "value",
67 bp::make_getter(&DynamicsData::valref_,
68 bp::return_value_policy<bp::return_by_value>()),
69 "Function value.")
70 .add_property("jac_buffer",
71 make_getter_eigen_matrix(&DynamicsData::jac_buffer_),
72 "Buffer of the full function Jacobian wrt (x,u,y).")
73 .add_property(
74 "Jx",
75 bp::make_getter(&DynamicsData::Jx_,
76 bp::return_value_policy<bp::return_by_value>()),
77 "Jacobian with respect to $x$.")
78 .add_property(
79 "Ju",
80 bp::make_getter(&DynamicsData::Ju_,
81 bp::return_value_policy<bp::return_by_value>()),
82 "Jacobian with respect to $u$.")
83 .add_property(
84 "Jy",
85 bp::make_getter(&DynamicsData::Jy_,
86 bp::return_value_policy<bp::return_by_value>()),
87 "Jacobian with respect to $y$.")
88 .add_property("Hxx", make_getter_eigen_matrix(&DynamicsData::Hxx_),
89 "Hessian with respect to $(x, x)$.")
90 .add_property("Hxu", make_getter_eigen_matrix(&DynamicsData::Hxu_),
91 "Hessian with respect to $(x, u)$.")
92 .add_property("Hxy", make_getter_eigen_matrix(&DynamicsData::Hxy_),
93 "Hessian with respect to $(x, y)$.")
94 .add_property("Huu", make_getter_eigen_matrix(&DynamicsData::Huu_),
95 "Hessian with respect to $(u, u)$.")
96 .add_property("Huy", make_getter_eigen_matrix(&DynamicsData::Huy_),
97 "Hessian with respect to $(x, y)$.")
98 .add_property("Hyy", make_getter_eigen_matrix(&DynamicsData::Hyy_),
99 "Hessian with respect to $(y, y)$.")
100 // .def(PrintableVisitor<DynamicsData>())
102}
103
104} // namespace python
105} // namespace aligator
void exposeDynamics()
Expose discrete dynamics.
bp::object make_getter_eigen_matrix(MatrixType C::*v)
Create a getter for Eigen::Matrix type objects which returns an Eigen::Ref.
xyz::polymorphic< Manifold > PolyManifold
Main package namespace.
Dynamics model: describes system dynamics through an implicit relation .
Definition fwd.hpp:71