34 register_polymorphic_to_python<PolyFunction>();
35 bp::class_<PyStageFunction<>, boost::noncopyable>(
37 "Base class for ternary functions f(x,u,x') on a stage of the problem.",
39 .def(bp::init<const int, const int, const int>(
40 (
"self"_a,
"ndx",
"nu",
"nr")))
41 .def(
"evaluate", bp::pure_virtual(&StageFunction::evaluate),
42 (
"self"_a,
"x",
"u",
"data"))
43 .def(
"computeJacobians",
44 bp::pure_virtual(&StageFunction::computeJacobians),
45 (
"self"_a,
"x",
"u",
"data"))
46 .def(
"computeVectorHessianProducts",
47 &StageFunction::computeVectorHessianProducts,
48 (
"self"_a,
"x",
"u",
"lbda",
"data"))
49 .def_readonly(
"ndx1", &StageFunction::ndx1,
"Current state space.")
50 .def_readonly(
"nu", &StageFunction::nu,
"Control dimension.")
51 .def_readonly(
"nr", &StageFunction::nr,
"Function codimension.")
56 .enable_pickling_(
true);
58 bp::register_ptr_to_python<shared_ptr<StageFunctionData>>();
60 bp::class_<FunctionDataWrapper, boost::noncopyable>(
61 "StageFunctionData",
"Data struct for holding data about functions.",
63 .def(bp::init<const StageFunction &>((
"self"_a,
"model")))
64 .def(bp::init<int, int, int>(bp::args(
"self",
"ndx",
"nu",
"nr")))
67 bp::make_getter(&StageFunctionData::valref_,
68 bp::return_value_policy<bp::return_by_value>()),
70 .add_property(
"jac_buffer",
72 "Buffer of the full function Jacobian wrt (x,u,y).")
76 "Buffer of the full function vector-Hessian product wrt (x,u,y).")
79 bp::make_getter(&StageFunctionData::Jx_,
80 bp::return_value_policy<bp::return_by_value>()),
81 "Jacobian with respect to $x$.")
84 bp::make_getter(&StageFunctionData::Ju_,
85 bp::return_value_policy<bp::return_by_value>()),
86 "Jacobian with respect to $u$.")
89 bp::make_getter(&StageFunctionData::Hxx_,
90 bp::return_value_policy<bp::return_by_value>()),
91 "Hessian with respect to $(x, x)$.")
94 bp::make_getter(&StageFunctionData::Hxu_,
95 bp::return_value_policy<bp::return_by_value>()),
96 "Hessian with respect to $(x, u)$.")
99 bp::make_getter(&StageFunctionData::Huu_,
100 bp::return_value_policy<bp::return_by_value>()),
101 "Hessian with respect to $(u, u)$.")
105 StdVectorPythonVisitor<std::vector<PolyFunction>,
true>::expose(
106 "StdVec_StageFunction",
107 eigenpy::details::overload_base_get_item_for_std_vector<
108 std::vector<PolyFunction>>{});
109 StdVectorPythonVisitor<std::vector<shared_ptr<StageFunctionData>>,
110 true>::expose(
"StdVec_StageFunctionData");
124 bp::class_<StateErrorResidual, bp::bases<UnaryFunction>>(
125 "StateErrorResidual",
126 bp::init<const xyz::polymorphic<context::Manifold> &,
const int,
127 const context::VectorXs &>((
"self"_a,
"space",
"nu",
"target")))
132 bp::class_<ControlErrorResidual, bp::bases<StageFunction>>(
133 "ControlErrorResidual",
134 bp::init<const int, const xyz::polymorphic<context::Manifold> &,
135 const context::VectorXs &>(
136 (
"self"_a,
"ndx",
"uspace",
"target")))
137 .def(bp::init<const int, const context::VectorXs &>(
138 (
"self"_a,
"ndx",
"target")))
139 .def(bp::init<int, int>((
"self"_a,
"ndx",
"nu")))
145 bp::class_<LinearFunction, bp::bases<StageFunction>>(
147 bp::init<const int, const int, const int>((
"self"_a,
"ndx",
"nu",
"nr")))
148 .def(bp::init<
const ConstMatrixRef &,
const ConstMatrixRef &,
149 const ConstVectorRef &>(
"Constructor with C=0.",
150 (
"self"_a,
"A",
"B",
"d")))
151 .def_readonly(
"A", &LinearFunction::A_)
152 .def_readonly(
"B", &LinearFunction::B_)
153 .def_readonly(
"d", &LinearFunction::d_)
156 bp::class_<ControlBoxFunctionTpl<Scalar>, bp::bases<StageFunction>>(
157 "ControlBoxFunction",
158 bp::init<const int, const VectorXs &, const VectorXs &>(
159 bp::args(
"self",
"ndx",
"umin",
"umax")))
160 .def(bp::init<const int, const int, const Scalar, const Scalar>(
161 bp::args(
"self",
"ndx",
"nu",
"umin",
"umax")))
DynamicsModelTpl< Scalar > DynamicsModel
StageFunctionTpl< Scalar > StageFunction
UnaryFunctionTpl< Scalar > UnaryFunction
StageFunctionDataTpl< Scalar > StageFunctionData