aligator  0.9.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
Loading...
Searching...
No Matches
aligator::CostStackTpl< _Scalar > Struct Template Reference

Weighted sum of multiple cost components. More...

#include <aligator/modelling/costs/sum-of-costs.hpp>

Inheritance diagram for aligator::CostStackTpl< _Scalar >:
[legend]
Collaboration diagram for aligator::CostStackTpl< _Scalar >:
[legend]

Public Types

using Scalar = _Scalar
 
using CostBase = CostAbstractTpl<Scalar>
 
using CostData = CostDataAbstractTpl<Scalar>
 
using PolyCost = xyz::polymorphic<CostBase>
 
using SumCostData = CostStackDataTpl<Scalar>
 
using Manifold = ManifoldAbstractTpl<Scalar>
 
using CostItem = std::pair<PolyCost, Scalar>
 
using CostKey = std::variant<std::size_t, std::string>
 
using CostMap = boost::unordered::unordered_map<CostKey, CostItem>
 
using CostIterator = typename CostMap::iterator
 
- Public Types inherited from aligator::CostAbstractTpl< _Scalar >
using Scalar
 
using CostData
 
using Manifold
 

Public Member Functions

 ALIGATOR_DYNAMIC_TYPEDEFS (Scalar)
 
bool checkDimension (const CostBase &comp) const
 Check the dimension of a component.
 
 CostStackTpl (xyz::polymorphic< Manifold > space, const int nu, const std::vector< PolyCost > &comps={}, const std::vector< Scalar > &weights={})
 Constructor with a specified dimension, and optional vector of components and weights.
 
 CostStackTpl (xyz::polymorphic< Manifold > space, const int nu, const CostMap &comps)
 
 CostStackTpl (const PolyCost &cost)
 Constructor from a single CostBase instance.
 
CostItemaddCost (const PolyCost &cost, const Scalar weight=1.)
 
CostItemaddCost (const CostKey &key, const PolyCost &cost, const Scalar weight=1.)
 
std::size_t size () const
 
template<typename Derived >
Derived * getComponent (const CostKey &key)
 Get component, cast down to the specified type.
 
template<typename Derived >
const Derived * getComponent (const CostKey &key) const
 
void evaluate (const ConstVectorRef &x, const ConstVectorRef &u, CostData &data) const
 
void computeGradients (const ConstVectorRef &x, const ConstVectorRef &u, CostData &data) const
 
void computeHessians (const ConstVectorRef &x, const ConstVectorRef &u, CostData &data) const
 
shared_ptr< CostDatacreateData () const
 
- Public Member Functions inherited from aligator::CostAbstractTpl< _Scalar >
 ALIGATOR_DYNAMIC_TYPEDEFS (_Scalar)
 
int nx () const
 
int ndx () const
 
 CostAbstractTpl (U &&space, const int nu)
 
virtual void evaluate (const ConstVectorRef &x, const ConstVectorRef &u, CostData &data) const
 Evaluate the cost function.
 
virtual void computeGradients (const ConstVectorRef &x, const ConstVectorRef &u, CostData &data) const
 Compute the cost gradients \((\ell_x, \ell_u)\).
 
virtual void computeHessians (const ConstVectorRef &x, const ConstVectorRef &u, CostData &data) const
 Compute the cost Hessians \((\ell_{ij})_{i,j \in \{x,u\}}\).
 
virtual ~CostAbstractTpl ()=default
 

Public Attributes

CostMap components_
 
- Public Attributes inherited from aligator::CostAbstractTpl< _Scalar >
xyz::polymorphic< Manifoldspace
 State dimension.
 
int nu
 Control dimension.
 

Detailed Description

template<typename _Scalar>
struct aligator::CostStackTpl< _Scalar >

Weighted sum of multiple cost components.

This is expressed as

\[ \ell(x, u) = \sum_{k=1}^{K} \ell^{(k)}(x, u). \]

Definition at line 19 of file sum-of-costs.hpp.

Member Typedef Documentation

◆ Scalar

template<typename _Scalar >
using aligator::CostStackTpl< _Scalar >::Scalar = _Scalar

Definition at line 20 of file sum-of-costs.hpp.

◆ CostBase

template<typename _Scalar >
using aligator::CostStackTpl< _Scalar >::CostBase = CostAbstractTpl<Scalar>

Definition at line 22 of file sum-of-costs.hpp.

◆ CostData

template<typename _Scalar >
using aligator::CostStackTpl< _Scalar >::CostData = CostDataAbstractTpl<Scalar>

Definition at line 23 of file sum-of-costs.hpp.

◆ PolyCost

template<typename _Scalar >
using aligator::CostStackTpl< _Scalar >::PolyCost = xyz::polymorphic<CostBase>

Definition at line 24 of file sum-of-costs.hpp.

◆ SumCostData

template<typename _Scalar >
using aligator::CostStackTpl< _Scalar >::SumCostData = CostStackDataTpl<Scalar>

Definition at line 25 of file sum-of-costs.hpp.

◆ Manifold

template<typename _Scalar >
using aligator::CostStackTpl< _Scalar >::Manifold = ManifoldAbstractTpl<Scalar>

Definition at line 26 of file sum-of-costs.hpp.

◆ CostItem

template<typename _Scalar >
using aligator::CostStackTpl< _Scalar >::CostItem = std::pair<PolyCost, Scalar>

Definition at line 27 of file sum-of-costs.hpp.

◆ CostKey

template<typename _Scalar >
using aligator::CostStackTpl< _Scalar >::CostKey = std::variant<std::size_t, std::string>

Definition at line 28 of file sum-of-costs.hpp.

◆ CostMap

template<typename _Scalar >
using aligator::CostStackTpl< _Scalar >::CostMap = boost::unordered::unordered_map<CostKey, CostItem>

Definition at line 29 of file sum-of-costs.hpp.

◆ CostIterator

template<typename _Scalar >
using aligator::CostStackTpl< _Scalar >::CostIterator = typename CostMap::iterator

Definition at line 30 of file sum-of-costs.hpp.

Constructor & Destructor Documentation

◆ CostStackTpl() [1/3]

template<typename _Scalar >
aligator::CostStackTpl< _Scalar >::CostStackTpl ( xyz::polymorphic< Manifold > space,
const int nu,
const std::vector< PolyCost > & comps = {},
const std::vector< Scalar > & weights = {} )

Constructor with a specified dimension, and optional vector of components and weights.

◆ CostStackTpl() [2/3]

template<typename _Scalar >
aligator::CostStackTpl< _Scalar >::CostStackTpl ( xyz::polymorphic< Manifold > space,
const int nu,
const CostMap & comps )
inline

Definition at line 45 of file sum-of-costs.hpp.

◆ CostStackTpl() [3/3]

template<typename _Scalar >
aligator::CostStackTpl< _Scalar >::CostStackTpl ( const PolyCost & cost)

Constructor from a single CostBase instance.

Member Function Documentation

◆ ALIGATOR_DYNAMIC_TYPEDEFS()

template<typename _Scalar >
aligator::CostStackTpl< _Scalar >::ALIGATOR_DYNAMIC_TYPEDEFS ( Scalar )

◆ checkDimension()

template<typename _Scalar >
bool aligator::CostStackTpl< _Scalar >::checkDimension ( const CostBase & comp) const

Check the dimension of a component.

Returns
A bool value indicating whether the component is OK to be added to this instance.

◆ addCost() [1/2]

template<typename _Scalar >
CostItem & aligator::CostStackTpl< _Scalar >::addCost ( const PolyCost & cost,
const Scalar weight = 1. )
inline

Definition at line 62 of file sum-of-costs.hpp.

◆ addCost() [2/2]

template<typename _Scalar >
CostItem & aligator::CostStackTpl< _Scalar >::addCost ( const CostKey & key,
const PolyCost & cost,
const Scalar weight = 1. )

◆ size()

template<typename _Scalar >
std::size_t aligator::CostStackTpl< _Scalar >::size ( ) const
inline

Definition at line 70 of file sum-of-costs.hpp.

◆ getComponent() [1/2]

template<typename _Scalar >
template<typename Derived >
Derived * aligator::CostStackTpl< _Scalar >::getComponent ( const CostKey & key)
inline

Get component, cast down to the specified type.

Definition at line 73 of file sum-of-costs.hpp.

◆ getComponent() [2/2]

template<typename _Scalar >
template<typename Derived >
const Derived * aligator::CostStackTpl< _Scalar >::getComponent ( const CostKey & key) const
inline

Definition at line 79 of file sum-of-costs.hpp.

◆ evaluate()

template<typename _Scalar >
void aligator::CostStackTpl< _Scalar >::evaluate ( const ConstVectorRef & x,
const ConstVectorRef & u,
CostData & data ) const

◆ computeGradients()

template<typename _Scalar >
void aligator::CostStackTpl< _Scalar >::computeGradients ( const ConstVectorRef & x,
const ConstVectorRef & u,
CostData & data ) const

◆ computeHessians()

template<typename _Scalar >
void aligator::CostStackTpl< _Scalar >::computeHessians ( const ConstVectorRef & x,
const ConstVectorRef & u,
CostData & data ) const

◆ createData()

template<typename _Scalar >
shared_ptr< CostData > aligator::CostStackTpl< _Scalar >::createData ( ) const
virtual

Member Data Documentation

◆ components_

template<typename _Scalar >
CostMap aligator::CostStackTpl< _Scalar >::components_

Definition at line 32 of file sum-of-costs.hpp.


The documentation for this struct was generated from the following file: