aligator  0.6.1
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
costs.hpp
Go to the documentation of this file.
1
2#pragma once
3
6
7namespace aligator {
8namespace python {
9namespace internal {
11template <typename T = context::CostAbstract>
12struct PyCostFunction : T, bp::wrapper<T> {
13 using Scalar = context::Scalar;
14 using bp::wrapper<T>::get_override;
15 using CostData = CostDataAbstractTpl<Scalar>;
17
19 template <typename... Args>
20 PyCostFunction(Args &&...args) : T(std::forward<Args>(args)...) {}
21
22 virtual void evaluate(const ConstVectorRef &x, const ConstVectorRef &u,
23 CostData &data) const override {
24 ALIGATOR_PYTHON_OVERRIDE_PURE(void, "evaluate", x, u, boost::ref(data));
25 }
26
27 virtual void computeGradients(const ConstVectorRef &x,
28 const ConstVectorRef &u,
29 CostData &data) const override {
30 ALIGATOR_PYTHON_OVERRIDE_PURE(void, "computeGradients", x, u,
31 boost::ref(data));
32 }
33
34 virtual void computeHessians(const ConstVectorRef &x, const ConstVectorRef &u,
35 CostData &data) const override {
36 ALIGATOR_PYTHON_OVERRIDE_PURE(void, "computeHessians", x, u,
37 boost::ref(data));
38 }
39
40 virtual shared_ptr<CostData> createData() const override {
41 ALIGATOR_PYTHON_OVERRIDE(shared_ptr<CostData>, T, createData, );
42 }
43};
44} // namespace internal
45
46} // namespace python
47} // namespace aligator
#define ALIGATOR_PYTHON_OVERRIDE(ret_type, cname, fname,...)
Define the body of a virtual function override. This is meant to reduce boilerplate code when exposin...
Definition macros.hpp:50
#define ALIGATOR_PYTHON_OVERRIDE_PURE(ret_type, pyname,...)
Define the body of a virtual function override. This is meant to reduce boilerplate code when exposin...
Definition macros.hpp:41
#define ALIGATOR_DYNAMIC_TYPEDEFS(Scalar)
Definition math.hpp:18
Main package namespace.
virtual shared_ptr< CostData > createData() const
virtual void evaluate(const ConstVectorRef &x, const ConstVectorRef &u, CostData &data) const=0
Evaluate the cost function.
virtual void computeHessians(const ConstVectorRef &x, const ConstVectorRef &u, CostData &data) const=0
Compute the cost Hessians .
virtual void computeGradients(const ConstVectorRef &x, const ConstVectorRef &u, CostData &data) const=0
Compute the cost gradients .