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

Trajectory optimization problem. More...

#include <aligator/core/traj-opt-problem.hpp>

Collaboration diagram for aligator::TrajOptProblemTpl< _Scalar >:
[legend]

Public Types

using Self = TrajOptProblemTpl
 
using Scalar = _Scalar
 
using StageModel = StageModelTpl<Scalar>
 
using StageFunction = StageFunctionTpl<Scalar>
 
using UnaryFunction = UnaryFunctionTpl<Scalar>
 
using Data = TrajOptDataTpl<Scalar>
 
using Manifold = ManifoldAbstractTpl<Scalar>
 
using CostAbstract = CostAbstractTpl<Scalar>
 
using ConstraintSet = ConstraintSetTpl<Scalar>
 
using StateErrorResidual = StateErrorResidualTpl<Scalar>
 
using StageConstraint = StageConstraintTpl<Scalar>
 
using InitializationStrategy
 

Public Member Functions

 ALIGATOR_DYNAMIC_TYPEDEFS (Scalar)
 
bool initCondIsStateError () const
 
void addStage (const xyz::polymorphic< StageModel > &stage)
 Add a stage to the control problem.
 
ConstVectorRef getInitState () const
 Get initial state constraint.
 
void setInitState (const ConstVectorRef &x0)
 Set initial state constraint.
 
ALIGATOR_DEPRECATED void addTerminalConstraint (const StageConstraint &cstr)
 Add a terminal constraint for the model.
 
void addTerminalConstraint (const xyz::polymorphic< StageFunction > &func, const xyz::polymorphic< ConstraintSet > &set)
 Add a terminal constraint for the model.
 
void removeTerminalConstraints ()
 Remove all terminal constraints.
 
std::size_t numSteps () const
 
Scalar evaluate (const std::vector< VectorXs > &xs, const std::vector< VectorXs > &us, Data &prob_data, std::size_t num_threads=1) const
 Rollout the problem costs, constraints, dynamics, stage per stage.
 
void computeDerivatives (const std::vector< VectorXs > &xs, const std::vector< VectorXs > &us, Data &prob_data, std::size_t num_threads=1, bool compute_second_order=true) const
 Rollout the problem derivatives, stage per stage.
 
void replaceStageCircular (const xyz::polymorphic< StageModel > &model)
 Pop out the first StageModel and replace by the supplied one; updates the supplied problem data (TrajOptDataTpl) object.
 
bool checkIntegrity () const
 
template<typename Callable>
void setInitializationStrategy (Callable &&func)
 Set a function to initialize the state trajectory.
 
void initializeSolution (std::vector< VectorXs > &xs, std::vector< VectorXs > &us) const
 Execute the initialization strategy to generate an initial candidate solution to the problem.
 
void initializeSolution (std::vector< VectorXs > &xs, std::vector< VectorXs > &us, std::vector< VectorXs > &vs, std::vector< VectorXs > &lbdas) const
 Execute the initialization strategy to generate an initial candidate solution to the problem.
 
auto initializeSolution () const
 Execute the initialization strategy to generate an initial candidate solution to the problem.
 
Constructors with pre-allocated stages
 TrajOptProblemTpl (xyz::polymorphic< UnaryFunction > init_constraint, const std::vector< xyz::polymorphic< StageModel > > &stages, xyz::polymorphic< CostAbstract > term_cost)
 Constructor with a given constraint function of any given type.
 
 TrajOptProblemTpl (const ConstVectorRef &x0, const std::vector< xyz::polymorphic< StageModel > > &stages, xyz::polymorphic< CostAbstract > term_cost)
 Constructor for an initial value problem.
 
Constructors without pre-allocated stages
 TrajOptProblemTpl (xyz::polymorphic< UnaryFunction > init_constraint, xyz::polymorphic< CostAbstract > term_cost)
 Constructor with a given constraint function of any given type.
 
 TrajOptProblemTpl (const ConstVectorRef &x0, const int nu, xyz::polymorphic< Manifold > space, xyz::polymorphic< CostAbstract > term_cost)
 Constructor for an initial value problem.
 

Public Attributes

xyz::polymorphic< UnaryFunctioninit_constraint_
 Initial condition.
 
std::vector< xyz::polymorphic< StageModel > > stages_
 Stages of the control problem.
 
xyz::polymorphic< CostAbstractterm_cost_
 Terminal cost.
 
ConstraintStackTpl< Scalarterm_cstrs_
 Terminal constraints.
 
VectorXs unone_
 Dummy, "neutral" control value.
 

Detailed Description

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

Trajectory optimization problem.

Template Parameters
Scalarthe scalar type.

The problem can be written as a nonlinear program:

\[ \begin{aligned} \min_{\bmx,\bmu}~& \sum_{i=0}^{N-1} \ell_i(x_i, u_i) + \ell_N(x_N) \\ \subjectto & \varphi(x_i, u_i, x_{i+1}) = 0, \ 0 \leq i < N \\ & g(x_i, u_i) \in \calC_i \end{aligned} \]

Definition at line 78 of file traj-opt-problem.hpp.

Member Typedef Documentation

◆ Self

template<typename _Scalar>
using aligator::TrajOptProblemTpl< _Scalar >::Self = TrajOptProblemTpl

Definition at line 79 of file traj-opt-problem.hpp.

◆ Scalar

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

Definition at line 80 of file traj-opt-problem.hpp.

◆ StageModel

template<typename _Scalar>
using aligator::TrajOptProblemTpl< _Scalar >::StageModel = StageModelTpl<Scalar>

Definition at line 84 of file traj-opt-problem.hpp.

◆ StageFunction

template<typename _Scalar>
using aligator::TrajOptProblemTpl< _Scalar >::StageFunction = StageFunctionTpl<Scalar>

Definition at line 85 of file traj-opt-problem.hpp.

◆ UnaryFunction

template<typename _Scalar>
using aligator::TrajOptProblemTpl< _Scalar >::UnaryFunction = UnaryFunctionTpl<Scalar>

Definition at line 86 of file traj-opt-problem.hpp.

◆ Data

template<typename _Scalar>
using aligator::TrajOptProblemTpl< _Scalar >::Data = TrajOptDataTpl<Scalar>

Definition at line 87 of file traj-opt-problem.hpp.

◆ Manifold

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

Definition at line 88 of file traj-opt-problem.hpp.

◆ CostAbstract

template<typename _Scalar>
using aligator::TrajOptProblemTpl< _Scalar >::CostAbstract = CostAbstractTpl<Scalar>

Definition at line 89 of file traj-opt-problem.hpp.

◆ ConstraintSet

template<typename _Scalar>
using aligator::TrajOptProblemTpl< _Scalar >::ConstraintSet = ConstraintSetTpl<Scalar>

Definition at line 90 of file traj-opt-problem.hpp.

◆ StateErrorResidual

template<typename _Scalar>
using aligator::TrajOptProblemTpl< _Scalar >::StateErrorResidual = StateErrorResidualTpl<Scalar>

Definition at line 91 of file traj-opt-problem.hpp.

◆ StageConstraint

template<typename _Scalar>
using aligator::TrajOptProblemTpl< _Scalar >::StageConstraint = StageConstraintTpl<Scalar>

Definition at line 94 of file traj-opt-problem.hpp.

◆ InitializationStrategy

template<typename _Scalar>
using aligator::TrajOptProblemTpl< _Scalar >::InitializationStrategy
Initial value:
std::function<void(const Self &, std::vector<VectorXs> &)>

Definition at line 96 of file traj-opt-problem.hpp.

Constructor & Destructor Documentation

◆ TrajOptProblemTpl() [1/4]

template<typename _Scalar>
aligator::TrajOptProblemTpl< _Scalar >::TrajOptProblemTpl ( xyz::polymorphic< UnaryFunction > init_constraint,
const std::vector< xyz::polymorphic< StageModel > > & stages,
xyz::polymorphic< CostAbstract > term_cost )

Constructor with a given constraint function of any given type.

◆ TrajOptProblemTpl() [2/4]

template<typename _Scalar>
aligator::TrajOptProblemTpl< _Scalar >::TrajOptProblemTpl ( const ConstVectorRef & x0,
const std::vector< xyz::polymorphic< StageModel > > & stages,
xyz::polymorphic< CostAbstract > term_cost )

Constructor for an initial value problem.

◆ TrajOptProblemTpl() [3/4]

template<typename _Scalar>
aligator::TrajOptProblemTpl< _Scalar >::TrajOptProblemTpl ( xyz::polymorphic< UnaryFunction > init_constraint,
xyz::polymorphic< CostAbstract > term_cost )

Constructor with a given constraint function of any given type.

◆ TrajOptProblemTpl() [4/4]

template<typename _Scalar>
aligator::TrajOptProblemTpl< _Scalar >::TrajOptProblemTpl ( const ConstVectorRef & x0,
const int nu,
xyz::polymorphic< Manifold > space,
xyz::polymorphic< CostAbstract > term_cost )

Constructor for an initial value problem.

Member Function Documentation

◆ ALIGATOR_DYNAMIC_TYPEDEFS()

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

◆ initCondIsStateError()

template<typename _Scalar>
bool aligator::TrajOptProblemTpl< _Scalar >::initCondIsStateError ( ) const
inline

Definition at line 137 of file traj-opt-problem.hpp.

◆ addStage()

template<typename _Scalar>
void aligator::TrajOptProblemTpl< _Scalar >::addStage ( const xyz::polymorphic< StageModel > & stage)

Add a stage to the control problem.

◆ getInitState()

template<typename _Scalar>
ConstVectorRef aligator::TrajOptProblemTpl< _Scalar >::getInitState ( ) const
inline

Get initial state constraint.

Definition at line 146 of file traj-opt-problem.hpp.

◆ setInitState()

template<typename _Scalar>
void aligator::TrajOptProblemTpl< _Scalar >::setInitState ( const ConstVectorRef & x0)
inline

Set initial state constraint.

Definition at line 155 of file traj-opt-problem.hpp.

◆ addTerminalConstraint() [1/2]

template<typename _Scalar>
ALIGATOR_DEPRECATED void aligator::TrajOptProblemTpl< _Scalar >::addTerminalConstraint ( const StageConstraint & cstr)

Add a terminal constraint for the model.

◆ addTerminalConstraint() [2/2]

template<typename _Scalar>
void aligator::TrajOptProblemTpl< _Scalar >::addTerminalConstraint ( const xyz::polymorphic< StageFunction > & func,
const xyz::polymorphic< ConstraintSet > & set )
inline

Add a terminal constraint for the model.

Definition at line 166 of file traj-opt-problem.hpp.

◆ removeTerminalConstraints()

template<typename _Scalar>
void aligator::TrajOptProblemTpl< _Scalar >::removeTerminalConstraints ( )
inline

Remove all terminal constraints.

Definition at line 171 of file traj-opt-problem.hpp.

◆ numSteps()

template<typename _Scalar>
std::size_t aligator::TrajOptProblemTpl< _Scalar >::numSteps ( ) const
nodiscard

◆ evaluate()

template<typename _Scalar>
Scalar aligator::TrajOptProblemTpl< _Scalar >::evaluate ( const std::vector< VectorXs > & xs,
const std::vector< VectorXs > & us,
Data & prob_data,
std::size_t num_threads = 1 ) const

Rollout the problem costs, constraints, dynamics, stage per stage.

◆ computeDerivatives()

template<typename _Scalar>
void aligator::TrajOptProblemTpl< _Scalar >::computeDerivatives ( const std::vector< VectorXs > & xs,
const std::vector< VectorXs > & us,
Data & prob_data,
std::size_t num_threads = 1,
bool compute_second_order = true ) const

Rollout the problem derivatives, stage per stage.

Parameters
xsState sequence
usControl sequence
prob_dataProblem data
num_threadsNumber of threads to use
compute_second_orderWhether to compute second-order derivatives

◆ replaceStageCircular()

template<typename _Scalar>
void aligator::TrajOptProblemTpl< _Scalar >::replaceStageCircular ( const xyz::polymorphic< StageModel > & model)

Pop out the first StageModel and replace by the supplied one; updates the supplied problem data (TrajOptDataTpl) object.

◆ checkIntegrity()

template<typename _Scalar>
bool aligator::TrajOptProblemTpl< _Scalar >::checkIntegrity ( ) const

◆ setInitializationStrategy()

template<typename _Scalar>
template<typename Callable>
void aligator::TrajOptProblemTpl< _Scalar >::setInitializationStrategy ( Callable && func)
inline

Set a function to initialize the state trajectory.

The class constructor defaults the strategy function to xs_default_init.

Warning
Call this set before the solver's setup().
Template Parameters
CallableFunctional type convertible to InitializationStrategy.
See also
initializeSolution()

Definition at line 207 of file traj-opt-problem.hpp.

◆ initializeSolution() [1/3]

template<typename _Scalar>
void aligator::TrajOptProblemTpl< _Scalar >::initializeSolution ( std::vector< VectorXs > & xs,
std::vector< VectorXs > & us ) const
inline

Execute the initialization strategy to generate an initial candidate solution to the problem.

See also
setInitializationStrategy()

Definition at line 216 of file traj-opt-problem.hpp.

◆ initializeSolution() [2/3]

template<typename _Scalar>
void aligator::TrajOptProblemTpl< _Scalar >::initializeSolution ( std::vector< VectorXs > & xs,
std::vector< VectorXs > & us,
std::vector< VectorXs > & vs,
std::vector< VectorXs > & lbdas ) const
inline

Execute the initialization strategy to generate an initial candidate solution to the problem.

See also
setInitializationStrategy()

Definition at line 223 of file traj-opt-problem.hpp.

◆ initializeSolution() [3/3]

template<typename _Scalar>
auto aligator::TrajOptProblemTpl< _Scalar >::initializeSolution ( ) const
inlinenodiscard

Execute the initialization strategy to generate an initial candidate solution to the problem.

See also
setInitializationStrategy()

Definition at line 244 of file traj-opt-problem.hpp.

Member Data Documentation

◆ init_constraint_

template<typename _Scalar>
xyz::polymorphic<UnaryFunction> aligator::TrajOptProblemTpl< _Scalar >::init_constraint_

Initial condition.

Definition at line 100 of file traj-opt-problem.hpp.

◆ stages_

template<typename _Scalar>
std::vector<xyz::polymorphic<StageModel> > aligator::TrajOptProblemTpl< _Scalar >::stages_

Stages of the control problem.

Definition at line 102 of file traj-opt-problem.hpp.

◆ term_cost_

template<typename _Scalar>
xyz::polymorphic<CostAbstract> aligator::TrajOptProblemTpl< _Scalar >::term_cost_

Terminal cost.

Definition at line 104 of file traj-opt-problem.hpp.

◆ term_cstrs_

template<typename _Scalar>
ConstraintStackTpl<Scalar> aligator::TrajOptProblemTpl< _Scalar >::term_cstrs_

Terminal constraints.

Definition at line 106 of file traj-opt-problem.hpp.

◆ unone_

template<typename _Scalar>
VectorXs aligator::TrajOptProblemTpl< _Scalar >::unone_

Dummy, "neutral" control value.

Definition at line 108 of file traj-opt-problem.hpp.


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