aligator  0.6.1
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
expose-composite-costs.cpp
Go to the documentation of this file.
3
6
7namespace aligator {
8namespace python {
9using context::ConstMatrixRef;
10using context::ConstVectorRef;
14using context::MatrixXs;
15using context::Scalar;
17using FunctionPtr = shared_ptr<StageFunction>;
18using ManifoldPtr = shared_ptr<Manifold>;
19
21
22 using CompositeData = CompositeCostDataTpl<Scalar>;
23 using QuadResCost = QuadraticResidualCostTpl<Scalar>;
24 using QuadStateCost = QuadraticStateCostTpl<Scalar>;
25 using QuadControlCost = QuadraticControlCostTpl<Scalar>;
26 using LogResCost = LogResidualCostTpl<Scalar>;
27
28 bp::class_<QuadResCost, bp::bases<CostAbstract>>(
29 "QuadraticResidualCost", "Weighted 2-norm of a given residual function.",
30 bp::init<ManifoldPtr, FunctionPtr, const ConstMatrixRef &>(
31 bp::args("self", "space", "function", "weights")))
32 .def_readwrite("residual", &QuadResCost::residual_)
33 .def_readwrite("weights", &QuadResCost::weights_)
34 .def(CopyableVisitor<QuadResCost>());
35
36 bp::class_<LogResCost, bp::bases<CostAbstract>>(
37 "LogResidualCost", "Weighted log-cost composite cost.",
38 bp::init<ManifoldPtr, FunctionPtr, const ConstVectorRef &>(
39 bp::args("self", "space", "function", "barrier_weights")))
40 .def(bp::init<ManifoldPtr, FunctionPtr, Scalar>(
41 bp::args("self", "function", "scale")))
42 .def_readwrite("residual", &LogResCost::residual_)
43 .def_readwrite("weights", &LogResCost::barrier_weights_)
44 .def(CopyableVisitor<LogResCost>());
45
46 bp::class_<CompositeData, bp::bases<CostData>>(
47 "CompositeCostData",
48 bp::init<int, int, shared_ptr<context::StageFunctionData>>(
49 bp::args("self", "ndx", "nu", "rdata")))
50 .def_readwrite("residual_data", &CompositeData::residual_data);
51
52 bp::class_<QuadStateCost, bp::bases<QuadResCost>>(
53 "QuadraticStateCost",
54 "Quadratic distance over the state manifold. This is a shortcut to "
55 "create a `QuadraticResidualCost` over a state error residual.",
56 bp::no_init)
57 .def(bp::init<shared_ptr<QuadStateCost::StateError>, const MatrixXs &>(
58 bp::args("self", "resdl", "weights")))
59 .def(bp::init<ManifoldPtr, const int, const ConstVectorRef &,
60 const MatrixXs &>(
61 bp::args("self", "space", "nu", "target", "weights")))
62 .add_property("target", &QuadStateCost::getTarget,
63 &QuadStateCost::setTarget,
64 "Target of the quadratic distance.");
65
66 bp::class_<QuadControlCost, bp::bases<QuadResCost>>(
67 "QuadraticControlCost", "Quadratic control cost.", bp::no_init)
68 .def(bp::init<ManifoldPtr, ConstVectorRef, const MatrixXs &>(
69 bp::args("space", "target", "weights")))
70 .def(bp::init<ManifoldPtr, shared_ptr<QuadControlCost::Error>,
71 const MatrixXs &>(
72 bp::args("self", "space", "resdl", "weights")))
73 .def(bp::init<ManifoldPtr, int, const MatrixXs &>(
74 bp::args("space", "nu", "weights")))
75 .add_property("target", &QuadControlCost::getTarget,
76 &QuadControlCost::setTarget,
77 "Reference of the control cost.");
78}
79} // namespace python
80} // namespace aligator
CostAbstractTpl< Scalar > CostAbstract
Definition context.hpp:26
ManifoldAbstractTpl< Scalar > Manifold
Definition context.hpp:14
StageFunctionTpl< Scalar > StageFunction
Definition context.hpp:17
CostDataAbstractTpl< Scalar > CostData
Definition context.hpp:27
void exposeComposites()
Composite cost functions.
shared_ptr< StageFunction > FunctionPtr
shared_ptr< Manifold > ManifoldPtr
Main package namespace.