aligator  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
cost-finite-difference.hpp
Go to the documentation of this file.
1#pragma once
3#include <proxsuite-nlp/manifold-base.hpp>
4
5namespace aligator {
6namespace autodiff {
7
8template <typename Scalar>
10 using Manifold = ManifoldAbstractTpl<Scalar>;
13
14 using CostBase::space;
15
17
18 struct Data;
19
20 CostFiniteDifferenceHelper(xyz::polymorphic<CostBase> cost,
21 const Scalar fd_eps);
22
23 void evaluate(const ConstVectorRef &x, const ConstVectorRef &u,
24 CostData &data_) const override;
25
26 void computeGradients(const ConstVectorRef &x, const ConstVectorRef &u,
27 CostData &data_) const override;
28
30 void computeHessians(const ConstVectorRef &, const ConstVectorRef &,
31 CostData &) const override {}
32
33 auto createData() const -> shared_ptr<CostData> override;
34
35 xyz::polymorphic<CostBase> cost_;
37};
38
39template <typename Scalar>
41
42 shared_ptr<CostData> c1, c2;
43 VectorXs dx, du;
44 VectorXs xp, up;
45
47 : CostData(obj), dx(obj.ndx()), du(obj.nu), xp(obj.nx()), up(obj.nu) {
48 c1 = obj.cost_->createData();
49 c2 = obj.cost_->createData();
50 }
51};
52
53#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
55#endif
56
57} // namespace autodiff
58} // namespace aligator
Main package namespace.
Stage costs for control problems.
Definition fwd.hpp:62
int nu
Control dimension.
xyz::polymorphic< Manifold > space
State dimension.
Data struct for CostAbstractTpl.
Definition fwd.hpp:65
CostFiniteDifferenceHelper(xyz::polymorphic< CostBase > cost, const Scalar fd_eps)
void computeGradients(const ConstVectorRef &x, const ConstVectorRef &u, CostData &data_) const override
Compute the cost gradients .
void evaluate(const ConstVectorRef &x, const ConstVectorRef &u, CostData &data_) const override
Evaluate the cost function.
void computeHessians(const ConstVectorRef &, const ConstVectorRef &, CostData &) const override
Compute the cost Hessians .
auto createData() const -> shared_ptr< CostData > override