aligator  0.10.0
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 {
10struct PyCostFunction final
12 proxsuite::nlp::python::PolymorphicWrapper<PyCostFunction,
13 context::CostAbstract> {
19
20 void evaluate(const ConstVectorRef &x, const ConstVectorRef &u,
21 CostData &data) const override {
22 ALIGATOR_PYTHON_OVERRIDE_PURE(void, "evaluate", x, u, boost::ref(data));
23 }
24
25 void computeGradients(const ConstVectorRef &x, const ConstVectorRef &u,
26 CostData &data) const override {
27 ALIGATOR_PYTHON_OVERRIDE_PURE(void, "computeGradients", x, u,
28 boost::ref(data));
29 }
30
31 void computeHessians(const ConstVectorRef &x, const ConstVectorRef &u,
32 CostData &data) const override {
33 ALIGATOR_PYTHON_OVERRIDE_PURE(void, "computeHessians", x, u,
34 boost::ref(data));
35 }
36
37 shared_ptr<CostData> createData() const override {
38 ALIGATOR_PYTHON_OVERRIDE(shared_ptr<CostData>, T, createData, );
39 }
40
41 shared_ptr<CostData> default_createData() const { return T::createData(); }
42};
43} // namespace python
44} // namespace aligator
45
47
48template <>
49struct value_holder<aligator::python::PyCostFunction>
50 : proxsuite::nlp::python::OwningNonOwningHolder<
51 aligator::python::PyCostFunction> {
52 using OwningNonOwningHolder::OwningNonOwningHolder;
53};
54
55} // namespace boost::python::objects
#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:45
#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:37
CostAbstractTpl< Scalar > CostAbstract
Definition context.hpp:25
Main package namespace.
Stage costs for control problems.
Definition fwd.hpp:62
CostAbstractTpl(U &&space, const int nu)
virtual shared_ptr< CostData > createData() const
Data struct for CostAbstractTpl.
Definition fwd.hpp:65
Wrapper for the CostDataAbstractTpl class and its children.
Definition costs.hpp:13
shared_ptr< CostData > createData() const override
Definition costs.hpp:37
shared_ptr< CostData > default_createData() const
Definition costs.hpp:41
void computeGradients(const ConstVectorRef &x, const ConstVectorRef &u, CostData &data) const override
Compute the cost gradients .
Definition costs.hpp:25
void evaluate(const ConstVectorRef &x, const ConstVectorRef &u, CostData &data) const override
Evaluate the cost function.
Definition costs.hpp:20
void computeHessians(const ConstVectorRef &x, const ConstVectorRef &u, CostData &data) const override
Compute the cost Hessians .
Definition costs.hpp:31