aligator  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
expose-stage.cpp
Go to the documentation of this file.
1
5
9
10#include <eigenpy/deprecation-policy.hpp>
11
12namespace aligator {
13namespace python {
14using proxsuite::nlp::python::PolymorphicVisitor;
15using proxsuite::nlp::python::register_polymorphic_to_python;
16
17// fwd
18void exposeStageData();
19
23 using context::Scalar;
25
26 using PolyCost = xyz::polymorphic<context::CostAbstract>;
27 using PolyDynamics = xyz::polymorphic<context::DynamicsModel>;
28 using PolyFunction = xyz::polymorphic<context::StageFunction>;
29 using PolyCstrSet = xyz::polymorphic<ConstraintSet>;
30 using PolyStage = xyz::polymorphic<StageModel>;
31
32 register_polymorphic_to_python<PolyStage>();
33
34 using StageVec = std::vector<PolyStage>;
35 StdVectorPythonVisitor<StageVec, true>::expose(
36 "StdVec_StageModel",
37 eigenpy::details::overload_base_get_item_for_std_vector<StageVec>());
38
39#pragma GCC diagnostic push
40#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
41 bp::class_<StageModel>(
42 "StageModel",
43 "A stage of the control problem. Holds costs, dynamics, and constraints.",
44 bp::no_init)
45 .def(bp::init<const PolyCost &, const PolyDynamics &>(
46 ("self"_a, "cost", "dynamics")))
47 .def<void (StageModel::*)(const context::StageConstraint &)>(
48 "addConstraint", &StageModel::addConstraint,
49 eigenpy::deprecated_member<>("This method has been deprecated since "
50 "StageConstraint is deprecated."),
51 ("self"_a, "constraint"), "Add an existing constraint to the stage.")
52 .def<void (StageModel::*)(const PolyFunction &, const PolyCstrSet &)>(
53 "addConstraint", &StageModel::addConstraint,
54 ("self"_a, "func", "cstr_set"),
55 "Constructs a new constraint (from the underlying function and set) "
56 "and adds it to the stage.")
57 .def_readonly("constraints", &StageModel::constraints_,
58 "Get the set of constraints.")
59 .def_readonly("dynamics", &StageModel::dynamics_, "Stage dynamics.")
60 .add_property("xspace",
61 bp::make_getter(&StageModel::xspace_,
62 bp::return_internal_reference<>()),
63 "State space for the current state :math:`x_k`.")
64 .add_property("xspace_next",
65 bp::make_getter(&StageModel::xspace_next_,
66 bp::return_internal_reference<>()),
67 "State space corresponding to next state :math:`x_{k+1}`.")
68 .add_property("uspace",
69 bp::make_getter(&StageModel::uspace_,
70 bp::return_internal_reference<>()),
71 "Control space.")
72 .add_property("cost",
73 bp::make_getter(&StageModel::cost_,
74 bp::return_internal_reference<>()),
75 "Stage cost.")
76 .def("evaluate", &StageModel::evaluate, ("self"_a, "x", "u", "y", "data"),
77 "Evaluate the stage cost, dynamics, constraints.")
78 .def("computeFirstOrderDerivatives",
79 &StageModel::computeFirstOrderDerivatives,
80 ("self"_a, "x", "u", "y", "data"),
81 "Compute gradients of the stage cost and jacobians of the dynamics "
82 "and "
83 "constraints.")
84 .def("computeSecondOrderDerivatives",
85 &StageModel::computeSecondOrderDerivatives,
86 ("self"_a, "x", "u", "data"), "Compute Hessians of the stage cost.")
87 .add_property("ndx1", &StageModel::ndx1)
88 .add_property("ndx2", &StageModel::ndx2)
89 .add_property("nu", &StageModel::nu, "Control space dimension.")
90 .add_property("num_primal", &StageModel::numPrimal,
91 "Number of primal variables.")
92 .add_property("num_dual", &StageModel::numDual,
93 "Number of dual variables.")
97 .def(PolymorphicVisitor<PolyStage>());
98#pragma GCC diagnostic pop
99
101}
102
103} // namespace python
104} // namespace aligator
ManifoldAbstractTpl< Scalar > Manifold
Definition context.hpp:14
ConstraintSetTpl< Scalar > ConstraintSet
Definition context.hpp:21
xyz::polymorphic< StageFunction > PolyFunction
void exposeStage()
Expose StageModel and StageData.
xyz::polymorphic< CostAbstract > PolyCost
Main package namespace.
A stage in the control problem.
Definition fwd.hpp:90