autogenu-jupyter
An automatic code generator and the continuation/GMRES (C/GMRES) based numerical solvers for nonlinear MPC
|
Single-shooting C/GMRES solver for nonlinear MPC. More...
#include <single_shooting_cgmres_solver.hpp>
Public Types | |
using | SingleShootingNLP_ = detail::SingleShootingNLP< OCP, N > |
using | ContinuationGMRES_ = detail::ContinuationGMRES< SingleShootingNLP_ > |
using | MatrixFreeGMRES_ = detail::MatrixFreeGMRES< ContinuationGMRES_, kmax > |
Public Member Functions | |
SingleShootingCGMRESSolver (const OCP &ocp, const Horizon &horizon, const SolverSettings &settings) | |
Constructs the single-shooting C/GMRES solver. More... | |
SingleShootingCGMRESSolver ()=default | |
Default constructor. More... | |
~SingleShootingCGMRESSolver ()=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_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_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... | |
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 + 2 * N * nub |
Dimension of the linear problem solved by the GMRES solver. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const SingleShootingCGMRESSolver &solver) |
Single-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::SingleShootingCGMRESSolver< OCP, N, kmax >::ContinuationGMRES_ = detail::ContinuationGMRES<SingleShootingNLP_> |
using cgmres::SingleShootingCGMRESSolver< OCP, N, kmax >::MatrixFreeGMRES_ = detail::MatrixFreeGMRES<ContinuationGMRES_, kmax> |
using cgmres::SingleShootingCGMRESSolver< OCP, N, kmax >::SingleShootingNLP_ = detail::SingleShootingNLP<OCP, N> |
|
inline |
Constructs the single-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 |
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 SingleShootingCGMRESSolver::nx. |
|
inline |
Sets the dummy input vector with respect to the control input bounds constraint.
[in] | dummy | The dummy input vector. Size must be SingleShootingCGMRESSolver::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 SingleShootingCGMRESSolver::nub. |
|
inline |
Sets the Lagrange multiplier with respect to the control input bounds constraint.
[in] | mu | The Lagrange multiplier. Size must be SingleShootingCGMRESSolver::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 SingleShootingCGMRESSolver::nub. |
|
inline |
Sets the control input vector.
[in] | u | The control input vector. Size must be SingleShootingCGMRESSolver::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 SingleShootingCGMRESSolver::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 SingleShootingCGMRESSolver::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 SingleShootingCGMRESSolver::nuc. |
|
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 SingleShootingCGMRESSolver::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.