autogenu-jupyter
An automatic code generator and the continuation/GMRES (C/GMRES) based numerical solvers for nonlinear MPC
|
Multiple-shooting C/GMRES solver for nonlinear MPC. More...
#include <multiple_shooting_cgmres_solver.hpp>
Public Types | |
using | MultipleShootingNLP_ = detail::MultipleShootingNLP< OCP, N > |
using | ContinuationGMRES_ = detail::ContinuationGMRESCondensing< MultipleShootingNLP_ > |
using | MatrixFreeGMRES_ = detail::MatrixFreeGMRES< ContinuationGMRES_, kmax > |
Public Member Functions | |
MultipleShootingCGMRESSolver (const OCP &ocp, const Horizon &horizon, const SolverSettings &settings) | |
Constructs the multiple-shooting C/GMRES solver. More... | |
MultipleShootingCGMRESSolver ()=default | |
Default constructor. More... | |
~MultipleShootingCGMRESSolver ()=default | |
Default destructor. More... | |
template<typename VectorType > | |
void | set_u (const MatrixBase< VectorType > &u) |
Sets the control input vector. More... | |
template<typename VectorType > | |
void | set_uc (const MatrixBase< VectorType > &uc) |
Sets the control input vector and Lagrange multiplier with respect to the equality constraints. More... | |
template<typename VectorType > | |
void | set_x (const MatrixBase< VectorType > &x) |
Sets the state vector. More... | |
template<typename VectorType > | |
void | set_lmd (const MatrixBase< VectorType > &lmd) |
Sets the costate vector. 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... | |
template<typename T > | |
void | set_u_array (const T &u_array) |
Sets the array of control input vector. More... | |
template<typename T > | |
void | set_uc_array (const T &uc_array) |
Sets the array of control input vector and Lagrange multiplier with respect to the equality constraints. More... | |
template<typename T > | |
void | set_x_array (const T &x_array) |
Sets the array of state vector. More... | |
template<typename T > | |
void | set_lmd_array (const T &lmd_array) |
Sets the array of costate vector. More... | |
template<typename T > | |
void | set_dummy_array (const T &dummy_array) |
Sets the array of the dummy input vector with respect to the control input bounds constraint. More... | |
template<typename T > | |
void | set_mu_array (const T &mu_array) |
Sets the array of the Lagrange multiplier with respect to the control input bounds constraint. More... | |
template<typename VectorType > | |
void | init_x (const Scalar t, const MatrixBase< VectorType > &x) |
Initializes the state vectors by simulating the system dynamics over the horizon. More... | |
template<typename VectorType > | |
void | init_lmd (const Scalar t, const MatrixBase< VectorType > &x) |
Initializes the costate vectors by simulating the system costate dynamics over the horizon. More... | |
template<typename VectorType > | |
void | init_x_lmd (const Scalar t, const MatrixBase< VectorType > &x) |
Initializes the state vectors and costate vectors by simulating the system dynamics and system costate dynamcis over the horizon. More... | |
void | init_dummy_mu () |
Initializes the dummy input vectors and Lagrange multipliers with respect to the control input bounds constraint. More... | |
const std::array< Vector< nu >, N > & | uopt () const |
Getter of the optimal solution. More... | |
const std::array< Vector< nuc >, N > & | ucopt () const |
Getter of the optimal solution. More... | |
const std::array< Vector< nx >, N+1 > & | xopt () const |
Getter of the optimal solution. More... | |
const std::array< Vector< nx >, N+1 > & | lmdopt () const |
Getter of the optimal solution. More... | |
const std::array< Vector< nub >, N > & | dummyopt () const |
Getter of the optimal solution. More... | |
const std::array< Vector< nub >, N > & | muopt () 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 | update (const Scalar t, const MatrixBase< VectorType > &x) |
Updates the solution by performing C/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 * N |
Dimension of the linear problem solved by the GMRES solver. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const MultipleShootingCGMRESSolver &solver) |
Multiple-shooting C/GMRES solver for nonlinear MPC.
OCP | A definition of the optimal control problem (OCP). |
N | Number of discretizationn grids of the horizon. Must be positive. |
kmax | Maximum number of the GMRES iterations. Must be positive. |
using cgmres::MultipleShootingCGMRESSolver< OCP, N, kmax >::ContinuationGMRES_ = detail::ContinuationGMRESCondensing<MultipleShootingNLP_> |
using cgmres::MultipleShootingCGMRESSolver< OCP, N, kmax >::MatrixFreeGMRES_ = detail::MatrixFreeGMRES<ContinuationGMRES_, kmax> |
using cgmres::MultipleShootingCGMRESSolver< OCP, N, kmax >::MultipleShootingNLP_ = detail::MultipleShootingNLP<OCP, N> |
|
inline |
Constructs the multiple-shooting C/GMRES solver.
[in] | ocp | A definition of the optimal control problem (OCP). |
[in] | horizon | Prediction horizon of MPC. |
[in] | settings | Solver settings. |
|
default |
Default constructor.
|
default |
Default destructor.
|
inline |
|
inline |
Getter of the optimal solution.
|
inline |
Get timing result as TimingProfile.
|
inline |
Initializes the dummy input vectors and Lagrange multipliers with respect to the control input bounds constraint.
|
inline |
Initializes the costate vectors by simulating the system costate dynamics over the horizon.
[in] | t | Initial time of the horizon. |
[in] | x | Initial state of the horizon. Size must be MultipleShootingCGMRESSolver::nx. |
|
inline |
Initializes the state vectors by simulating the system dynamics over the horizon.
[in] | t | Initial time of the horizon. |
[in] | x | Initial state of the horizon. Size must be MultipleShootingCGMRESSolver::nx. |
|
inline |
Initializes the state vectors and costate vectors by simulating the system dynamics and system costate dynamcis over the horizon.
[in] | t | Initial time of the horizon. |
[in] | x | Initial state of the horizon. Size must be MultipleShootingCGMRESSolver::nx. |
|
inline |
Getter of the optimal solution.
|
inline |
Getter of the optimal solution.
|
inline |
Gets the l2-norm of the current optimality errors.
|
inline |
Computes and gets the l2-norm of the current optimality errors.
[in] | t | Initial time of the horizon. |
[in] | x | Initial state of the horizon. Size must be MultipleShootingCGMRESSolver::nx. |
|
inline |
Sets the dummy input vector with respect to the control input bounds constraint.
[in] | dummy | The dummy input vector. Size must be MultipleShootingCGMRESSolver::nub. |
|
inline |
Sets the array of the dummy input vector with respect to the control input bounds constraint.
[in] | dummy_array | A container (std::vector, std::array, etc.) of the dummy input vector. Size must be N and size of each element must be MultipleShootingCGMRESSolver::nub. |
|
inline |
Sets the costate vector.
[in] | lmd | The costate vector. Size must be MultipleShootingCGMRESSolver::nx. |
|
inline |
Sets the array of costate vector.
[in] | lmd_array | A container (std::vector, std::array, etc.) of the costate vector. Size must be N+1 and size of each element must be MultipleShootingCGMRESSolver::nx. |
|
inline |
Sets the Lagrange multiplier with respect to the control input bounds constraint.
[in] | mu | The Lagrange multiplier. Size must be MultipleShootingCGMRESSolver::nub. |
|
inline |
Sets the array of the Lagrange multiplier with respect to the control input bounds constraint.
[in] | mu_array | A container (std::vector, std::array, etc.) of the Lagrange multiplier. Size must be N and size of each element must be MultipleShootingCGMRESSolver::nub. |
|
inline |
Sets the control input vector.
[in] | u | The control input vector. Size must be MultipleShootingCGMRESSolver::nu. |
|
inline |
Sets the array of control input vector.
[in] | u_array | A container (std::vector, std::array, etc.) of the control input vector. Size must be N and size of each element must be MultipleShootingCGMRESSolver::nu. |
|
inline |
Sets the control input vector and Lagrange multiplier with respect to the equality constraints.
[in] | uc | Concatenatin of the control input vector and Lagrange multiplier with respect to the equality constraints. Size must be MultipleShootingCGMRESSolver::nuc. |
|
inline |
Sets the array of control input vector and Lagrange multiplier with respect to the equality constraints.
[in] | uc_array | A container (std::vector, std::array, etc.) of the concatenatin of the control input vector and Lagrange multiplier with respect to the equality constraints. Size must be N and size of each element must be MultipleShootingCGMRESSolver::nuc. |
|
inline |
Sets the state vector.
[in] | x | The state vector. Size must be MultipleShootingCGMRESSolver::nx. |
|
inline |
Sets the array of state vector.
[in] | x_array | A container (std::vector, std::array, etc.) of the state vector. Size must be N+1 and size of each element must be MultipleShootingCGMRESSolver::nx. |
|
inline |
Getter of the optimal solution.
|
inline |
Getter of the optimal solution.
|
inline |
Updates the solution by performing C/GMRES method.
[in] | t | Initial time of the horizon. |
[in] | x | Initial state of the horizon. Size must be MultipleShootingCGMRESSolver::nx. |
|
inline |
Getter of the optimal solution.
|
friend |
|
staticconstexpr |
Dimension of the linear problem solved by the GMRES solver.
|
staticconstexpr |
Dimension of the equality constraints.
|
staticconstexpr |
Dimension of the control input.
|
staticconstexpr |
Dimension of the bound constraints on the control input.
|
staticconstexpr |
Dimension of the concatenation of the control input and equality constraints.
|
staticconstexpr |
Dimension of the state.