autogenu-jupyter
An automatic code generator and the continuation/GMRES (C/GMRES) based numerical solvers for nonlinear MPC
Loading...
Searching...
No Matches
cgmres::ZeroHorizonOCPSolver< OCP, kmax > Class Template Reference

Zero-horizon OCP solver to initialize the solution of the MPC solvers. More...

#include <zero_horizon_ocp_solver.hpp>

Public Types

using ZeroHorizonNLP_ = detail::ZeroHorizonNLP< OCP >
 
using NewtonGMRES_ = detail::NewtonGMRES< ZeroHorizonNLP_ >
 
using MatrixFreeGMRES_ = detail::MatrixFreeGMRES< NewtonGMRES_, kmax >
 

Public Member Functions

 ZeroHorizonOCPSolver (const OCP &ocp, const SolverSettings &settings)
 Constructs the zero-horizon OCP solver. More...
 
 ZeroHorizonOCPSolver ()=default
 Default constructor. More...
 
 ~ZeroHorizonOCPSolver ()=default
 Default destructor. More...
 
template<typename VectorType >
void set_u (const VectorType &u)
 Sets the control input vector. More...
 
template<typename VectorType >
void set_uc (const VectorType &uc)
 Sets the control input vector and Lagrange multiplier with respect to the equality constraints. More...
 
template<typename VectorType >
void set_dummy (const MatrixBase< VectorType > &dummy)
 Sets the dummy input vector with respect to the control input bounds constraint. More...
 
template<typename VectorType >
void set_mu (const MatrixBase< VectorType > &mu)
 Sets the Lagrange multiplier with respect to the control input bounds constraint. More...
 
void init_dummy_mu ()
 Initializes the dummy input vectors and Lagrange multipliers with respect to the control input bounds constraint. More...
 
const Vector< nu > & uopt () const
 Getter of the optimal solution. More...
 
const Vector< nuc > & ucopt () const
 Getter of the optimal solution. More...
 
const Vector< nub > & dummyopt () const
 Getter of the optimal solution. More...
 
const Vector< nub > & muopt () const
 Getter of the optimal solution. More...
 
const Vector< nx > & lmdopt () const
 Getter of the optimal solution. More...
 
Scalar optError () const
 Gets the l2-norm of the current optimality errors. More...
 
template<typename VectorType >
Scalar optError (const Scalar t, const MatrixBase< VectorType > &x)
 Computes and gets the l2-norm of the current optimality errors. More...
 
template<typename VectorType >
void solve (const Scalar t, const MatrixBase< VectorType > &x)
 Solves the zero-horizon optimal control problem by Newton-GMRES method. More...
 
TimingProfile getProfile () const
 Get timing result as TimingProfile. More...
 
void disp (std::ostream &os) const
 

Static Public Attributes

static constexpr int nx = OCP::nx
 Dimension of the state. More...
 
static constexpr int nu = OCP::nu
 Dimension of the control input. More...
 
static constexpr int nc = OCP::nc
 Dimension of the equality constraints. More...
 
static constexpr int nuc = nu + nc
 Dimension of the concatenation of the control input and equality constraints. More...
 
static constexpr int nub = OCP::nub
 Dimension of the bound constraints on the control input. More...
 
static constexpr int dim = nuc + 2 * nub
 Dimension of the linear problem solved by the GMRES solver. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const ZeroHorizonOCPSolver &solver)
 

Detailed Description

template<class OCP, int kmax>
class cgmres::ZeroHorizonOCPSolver< OCP, kmax >

Zero-horizon OCP solver to initialize the solution of the MPC solvers.

Template Parameters
OCPA definition of the optimal control problem (OCP).
kmaxMaximum number of the GMRES iterations. Must be positive.

Member Typedef Documentation

◆ MatrixFreeGMRES_

template<class OCP , int kmax>
using cgmres::ZeroHorizonOCPSolver< OCP, kmax >::MatrixFreeGMRES_ = detail::MatrixFreeGMRES<NewtonGMRES_, kmax>

◆ NewtonGMRES_

template<class OCP , int kmax>
using cgmres::ZeroHorizonOCPSolver< OCP, kmax >::NewtonGMRES_ = detail::NewtonGMRES<ZeroHorizonNLP_>

◆ ZeroHorizonNLP_

template<class OCP , int kmax>
using cgmres::ZeroHorizonOCPSolver< OCP, kmax >::ZeroHorizonNLP_ = detail::ZeroHorizonNLP<OCP>

Constructor & Destructor Documentation

◆ ZeroHorizonOCPSolver() [1/2]

template<class OCP , int kmax>
cgmres::ZeroHorizonOCPSolver< OCP, kmax >::ZeroHorizonOCPSolver ( const OCP &  ocp,
const SolverSettings settings 
)
inline

Constructs the zero-horizon OCP solver.

Parameters
[in]ocpA definition of the optimal control problem (OCP).
[in]settingsSolver settings.

◆ ZeroHorizonOCPSolver() [2/2]

template<class OCP , int kmax>
cgmres::ZeroHorizonOCPSolver< OCP, kmax >::ZeroHorizonOCPSolver ( )
default

Default constructor.

◆ ~ZeroHorizonOCPSolver()

template<class OCP , int kmax>
cgmres::ZeroHorizonOCPSolver< OCP, kmax >::~ZeroHorizonOCPSolver ( )
default

Default destructor.

Member Function Documentation

◆ disp()

template<class OCP , int kmax>
void cgmres::ZeroHorizonOCPSolver< OCP, kmax >::disp ( std::ostream &  os) const
inline

◆ dummyopt()

template<class OCP , int kmax>
const Vector< nub > & cgmres::ZeroHorizonOCPSolver< OCP, kmax >::dummyopt ( ) const
inline

Getter of the optimal solution.

Returns
const reference to the optimal dummy input vectors with respect to the control input bounds constraint.

◆ getProfile()

template<class OCP , int kmax>
TimingProfile cgmres::ZeroHorizonOCPSolver< OCP, kmax >::getProfile ( ) const
inline

Get timing result as TimingProfile.

Returns
Timing profile.

◆ init_dummy_mu()

template<class OCP , int kmax>
void cgmres::ZeroHorizonOCPSolver< OCP, kmax >::init_dummy_mu ( )
inline

Initializes the dummy input vectors and Lagrange multipliers with respect to the control input bounds constraint.

◆ lmdopt()

template<class OCP , int kmax>
const Vector< nx > & cgmres::ZeroHorizonOCPSolver< OCP, kmax >::lmdopt ( ) const
inline

Getter of the optimal solution.

Returns
const reference to the optimal costate vector.

◆ muopt()

template<class OCP , int kmax>
const Vector< nub > & cgmres::ZeroHorizonOCPSolver< OCP, kmax >::muopt ( ) const
inline

Getter of the optimal solution.

Returns
const reference to the Lagrange multipliers with respect to the control input bounds constraint.

◆ optError() [1/2]

template<class OCP , int kmax>
Scalar cgmres::ZeroHorizonOCPSolver< OCP, kmax >::optError ( ) const
inline

Gets the l2-norm of the current optimality errors.

Returns
The l2-norm of the current optimality errors.

◆ optError() [2/2]

template<class OCP , int kmax>
template<typename VectorType >
Scalar cgmres::ZeroHorizonOCPSolver< OCP, kmax >::optError ( const Scalar  t,
const MatrixBase< VectorType > &  x 
)
inline

Computes and gets the l2-norm of the current optimality errors.

Parameters
[in]tTime.
[in]xState. Size must be ZeroHorizonOCPSolver::nx.
Returns
The l2-norm of the current optimality errors.

◆ set_dummy()

template<class OCP , int kmax>
template<typename VectorType >
void cgmres::ZeroHorizonOCPSolver< OCP, kmax >::set_dummy ( const MatrixBase< VectorType > &  dummy)
inline

Sets the dummy input vector with respect to the control input bounds constraint.

Parameters
[in]dummyThe dummy input vector. Size must be ZeroHorizonOCPSolver::nub.

◆ set_mu()

template<class OCP , int kmax>
template<typename VectorType >
void cgmres::ZeroHorizonOCPSolver< OCP, kmax >::set_mu ( const MatrixBase< VectorType > &  mu)
inline

Sets the Lagrange multiplier with respect to the control input bounds constraint.

Parameters
[in]muThe Lagrange multiplier. Size must be ZeroHorizonOCPSolver::nub.

◆ set_u()

template<class OCP , int kmax>
template<typename VectorType >
void cgmres::ZeroHorizonOCPSolver< OCP, kmax >::set_u ( const VectorType &  u)
inline

Sets the control input vector.

Parameters
[in]uThe control input vector. Size must be ZeroHorizonOCPSolver::nu.

◆ set_uc()

template<class OCP , int kmax>
template<typename VectorType >
void cgmres::ZeroHorizonOCPSolver< OCP, kmax >::set_uc ( const VectorType &  uc)
inline

Sets the control input vector and Lagrange multiplier with respect to the equality constraints.

Parameters
[in]ucConcatenatin of the control input vector and Lagrange multiplier with respect to the equality constraints. Size must be ZeroHorizonOCPSolver::nuc.

◆ solve()

template<class OCP , int kmax>
template<typename VectorType >
void cgmres::ZeroHorizonOCPSolver< OCP, kmax >::solve ( const Scalar  t,
const MatrixBase< VectorType > &  x 
)
inline

Solves the zero-horizon optimal control problem by Newton-GMRES method.

Parameters
[in]tTime.
[in]xState. Size must be ZeroHorizonOCPSolver::nx.

◆ ucopt()

template<class OCP , int kmax>
const Vector< nuc > & cgmres::ZeroHorizonOCPSolver< OCP, kmax >::ucopt ( ) const
inline

Getter of the optimal solution.

Returns
const reference to the optimal concatenatins of the control input vector and Lagrange multiplier with respect to the equality constraints.

◆ uopt()

template<class OCP , int kmax>
const Vector< nu > & cgmres::ZeroHorizonOCPSolver< OCP, kmax >::uopt ( ) const
inline

Getter of the optimal solution.

Returns
const reference to the optimal control input vector.

Friends And Related Function Documentation

◆ operator<<

template<class OCP , int kmax>
std::ostream & operator<< ( std::ostream &  os,
const ZeroHorizonOCPSolver< OCP, kmax > &  solver 
)
friend

Member Data Documentation

◆ dim

template<class OCP , int kmax>
constexpr int cgmres::ZeroHorizonOCPSolver< OCP, kmax >::dim = nuc + 2 * nub
staticconstexpr

Dimension of the linear problem solved by the GMRES solver.

◆ nc

template<class OCP , int kmax>
constexpr int cgmres::ZeroHorizonOCPSolver< OCP, kmax >::nc = OCP::nc
staticconstexpr

Dimension of the equality constraints.

◆ nu

template<class OCP , int kmax>
constexpr int cgmres::ZeroHorizonOCPSolver< OCP, kmax >::nu = OCP::nu
staticconstexpr

Dimension of the control input.

◆ nub

template<class OCP , int kmax>
constexpr int cgmres::ZeroHorizonOCPSolver< OCP, kmax >::nub = OCP::nub
staticconstexpr

Dimension of the bound constraints on the control input.

◆ nuc

template<class OCP , int kmax>
constexpr int cgmres::ZeroHorizonOCPSolver< OCP, kmax >::nuc = nu + nc
staticconstexpr

Dimension of the concatenation of the control input and equality constraints.

◆ nx

template<class OCP , int kmax>
constexpr int cgmres::ZeroHorizonOCPSolver< OCP, kmax >::nx = OCP::nx
staticconstexpr

Dimension of the state.


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