autogenu-jupyter
An automatic code generator and the continuation/GMRES (C/GMRES) based numerical solvers for nonlinear MPC
Loading...
Searching...
No Matches
cgmres::OCP_pendubot Class Reference

Definition of the optimal control problem (OCP) of pendubot. More...

#include <ocp.hpp>

Public Member Functions

void disp (std::ostream &os) const
 
void synchronize ()
 Synchrozies the internal parameters of this OCP with the external references. This method is called at the beginning of each MPC update. More...
 
void eval_f (const double t, const double *x, const double *u, double *dx) const
 Computes the state equation dx = f(t, x, u). More...
 
void eval_phix (const double t, const double *x, double *phix) const
 Computes the partial derivative of terminal cost with respect to state, i.e., phix = dphi/dx(t, x). More...
 
void eval_hx (const double t, const double *x, const double *u, const double *lmd, double *hx) const
 Computes the partial derivative of the Hamiltonian with respect to state, i.e., hx = dH/dx(t, x, u, lmd). More...
 
void eval_hu (const double t, const double *x, const double *u, const double *lmd, double *hu) const
 Computes the partial derivative of the Hamiltonian with respect to control input and the equality constraints, i.e., hu = dH/du(t, x, u, lmd). More...
 
template<typename VectorType1 , typename VectorType2 , typename VectorType3 >
void eval_f (const double t, const MatrixBase< VectorType1 > &x, const MatrixBase< VectorType2 > &u, const MatrixBase< VectorType3 > &dx) const
 Computes the state equation dx = f(t, x, u). More...
 
template<typename VectorType1 , typename VectorType2 >
void eval_phix (const double t, const MatrixBase< VectorType1 > &x, const MatrixBase< VectorType2 > &phix) const
 Computes the partial derivative of terminal cost with respect to state, i.e., phix = dphi/dx(t, x). More...
 
template<typename VectorType1 , typename VectorType2 , typename VectorType3 , typename VectorType4 >
void eval_hx (const double t, const MatrixBase< VectorType1 > &x, const MatrixBase< VectorType2 > &uc, const MatrixBase< VectorType3 > &lmd, const MatrixBase< VectorType4 > &hx) const
 Computes the partial derivative of the Hamiltonian with respect to the state, i.e., hx = dH/dx(t, x, u, lmd). More...
 
template<typename VectorType1 , typename VectorType2 , typename VectorType3 , typename VectorType4 >
void eval_hu (const double t, const MatrixBase< VectorType1 > &x, const MatrixBase< VectorType2 > &uc, const MatrixBase< VectorType3 > &lmd, const MatrixBase< VectorType4 > &hu) const
 Computes the partial derivative of the Hamiltonian with respect to control input and the equality constraints, i.e., hu = dH/du(t, x, u, lmd). More...
 

Public Attributes

double m1 = 0.2
 
double m2 = 0.7
 
double l1 = 0.3
 
double l2 = 0.3
 
double d1 = 0.15
 
double d2 = 0.257
 
double J1 = 0.006
 
double J2 = 0.051
 
double g = 9.80665
 
std::array< double, 4 > q = {1, 1, 0.1, 0.1}
 
std::array< double, 4 > q_terminal = {1, 1, 0.1, 0.1}
 
std::array< double, 4 > x_ref = {M_PI, 0, 0, 0}
 
std::array< double, 1 > r = {0.1}
 
std::array< double, nubumin = {-5.0}
 
std::array< double, nubumax = {5.0}
 
std::array< double, nubdummy_weight = {0.1}
 

Static Public Attributes

static constexpr int nx = 4
 Dimension of the state. More...
 
static constexpr int nu = 1
 Dimension of the control input. More...
 
static constexpr int nc = 0
 Dimension of the equality constraints. More...
 
static constexpr int nh = 0
 Dimension of the Fischer-Burmeister function (already counded in nc). More...
 
static constexpr int nuc = nu + nc
 Dimension of the concatenation of the control input and equality constraints. More...
 
static constexpr int nub = 1
 Dimension of the bound constraints on the control input. More...
 
static constexpr std::array< int, nububound_indices = {0}
 

Friends

std::ostream & operator<< (std::ostream &os, const OCP_pendubot &ocp)
 

Detailed Description

Definition of the optimal control problem (OCP) of pendubot.

Member Function Documentation

◆ disp()

void cgmres::OCP_pendubot::disp ( std::ostream &  os) const
inline

◆ eval_f() [1/2]

void cgmres::OCP_pendubot::eval_f ( const double  t,
const double *  x,
const double *  u,
double *  dx 
) const
inline

Computes the state equation dx = f(t, x, u).

Parameters
[in]tTime.
[in]xState.
[in]uControl input.
[out]dxEvaluated value of the state equation.
Remarks
This method is intended to be used inside of the cgmres solvers and does not check size of each argument. Use the overloaded method if you call this outside of the cgmres solvers.

◆ eval_f() [2/2]

template<typename VectorType1 , typename VectorType2 , typename VectorType3 >
void cgmres::OCP_pendubot::eval_f ( const double  t,
const MatrixBase< VectorType1 > &  x,
const MatrixBase< VectorType2 > &  u,
const MatrixBase< VectorType3 > &  dx 
) const
inline

Computes the state equation dx = f(t, x, u).

Parameters
[in]tTime.
[in]xState. Size must be nx.
[in]uControl input. Size must be nu.
[out]dxEvaluated value of the state equation. Size must be nx.

◆ eval_hu() [1/2]

void cgmres::OCP_pendubot::eval_hu ( const double  t,
const double *  x,
const double *  u,
const double *  lmd,
double *  hu 
) const
inline

Computes the partial derivative of the Hamiltonian with respect to control input and the equality constraints, i.e., hu = dH/du(t, x, u, lmd).

Parameters
[in]tTime.
[in]xState.
[in]uConcatenatin of the control input and Lagrange multiplier with respect to the equality constraints.
[in]lmdCostate.
[out]huEvaluated value of the partial derivative of the Hamiltonian.
Remarks
This method is intended to be used inside of the cgmres solvers and does not check size of each argument. Use the overloaded method if you call this outside of the cgmres solvers.

◆ eval_hu() [2/2]

template<typename VectorType1 , typename VectorType2 , typename VectorType3 , typename VectorType4 >
void cgmres::OCP_pendubot::eval_hu ( const double  t,
const MatrixBase< VectorType1 > &  x,
const MatrixBase< VectorType2 > &  uc,
const MatrixBase< VectorType3 > &  lmd,
const MatrixBase< VectorType4 > &  hu 
) const
inline

Computes the partial derivative of the Hamiltonian with respect to control input and the equality constraints, i.e., hu = dH/du(t, x, u, lmd).

Parameters
[in]tTime.
[in]xState. Size must be nx.
[in]ucConcatenatin of the control input and Lagrange multiplier with respect to the equality constraints. Size must be nuc.
[in]lmdCostate. Size must be nx.
[out]huEvaluated value of the partial derivative of the Hamiltonian. Size must be nuc.

◆ eval_hx() [1/2]

void cgmres::OCP_pendubot::eval_hx ( const double  t,
const double *  x,
const double *  u,
const double *  lmd,
double *  hx 
) const
inline

Computes the partial derivative of the Hamiltonian with respect to state, i.e., hx = dH/dx(t, x, u, lmd).

Parameters
[in]tTime.
[in]xState.
[in]uConcatenatin of the control input and Lagrange multiplier with respect to the equality constraints.
[in]lmdCostate.
[out]hxEvaluated value of the partial derivative of the Hamiltonian.
Remarks
This method is intended to be used inside of the cgmres solvers and does not check size of each argument. Use the overloaded method if you call this outside of the cgmres solvers.

◆ eval_hx() [2/2]

template<typename VectorType1 , typename VectorType2 , typename VectorType3 , typename VectorType4 >
void cgmres::OCP_pendubot::eval_hx ( const double  t,
const MatrixBase< VectorType1 > &  x,
const MatrixBase< VectorType2 > &  uc,
const MatrixBase< VectorType3 > &  lmd,
const MatrixBase< VectorType4 > &  hx 
) const
inline

Computes the partial derivative of the Hamiltonian with respect to the state, i.e., hx = dH/dx(t, x, u, lmd).

Parameters
[in]tTime.
[in]xState. Size must be nx.
[in]ucConcatenatin of the control input and Lagrange multiplier with respect to the equality constraints. Size must be nuc.
[in]lmdCostate. Size must be nx.
[out]hxEvaluated value of the partial derivative of the Hamiltonian. Size must be nx.

◆ eval_phix() [1/2]

void cgmres::OCP_pendubot::eval_phix ( const double  t,
const double *  x,
double *  phix 
) const
inline

Computes the partial derivative of terminal cost with respect to state, i.e., phix = dphi/dx(t, x).

Parameters
[in]tTime.
[in]xState.
[out]phixEvaluated value of the partial derivative of terminal cost.
Remarks
This method is intended to be used inside of the cgmres solvers and does not check size of each argument. Use the overloaded method if you call this outside of the cgmres solvers.

◆ eval_phix() [2/2]

template<typename VectorType1 , typename VectorType2 >
void cgmres::OCP_pendubot::eval_phix ( const double  t,
const MatrixBase< VectorType1 > &  x,
const MatrixBase< VectorType2 > &  phix 
) const
inline

Computes the partial derivative of terminal cost with respect to state, i.e., phix = dphi/dx(t, x).

Parameters
[in]tTime.
[in]xState. Size must be nx.
[out]phixEvaluated value of the partial derivative of terminal cost. Size must be nx.

◆ synchronize()

void cgmres::OCP_pendubot::synchronize ( )
inline

Synchrozies the internal parameters of this OCP with the external references. This method is called at the beginning of each MPC update.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const OCP_pendubot ocp 
)
friend

Member Data Documentation

◆ d1

double cgmres::OCP_pendubot::d1 = 0.15

◆ d2

double cgmres::OCP_pendubot::d2 = 0.257

◆ dummy_weight

std::array<double, nub> cgmres::OCP_pendubot::dummy_weight = {0.1}

◆ g

double cgmres::OCP_pendubot::g = 9.80665

◆ J1

double cgmres::OCP_pendubot::J1 = 0.006

◆ J2

double cgmres::OCP_pendubot::J2 = 0.051

◆ l1

double cgmres::OCP_pendubot::l1 = 0.3

◆ l2

double cgmres::OCP_pendubot::l2 = 0.3

◆ m1

double cgmres::OCP_pendubot::m1 = 0.2

◆ m2

double cgmres::OCP_pendubot::m2 = 0.7

◆ nc

constexpr int cgmres::OCP_pendubot::nc = 0
staticconstexpr

Dimension of the equality constraints.

◆ nh

constexpr int cgmres::OCP_pendubot::nh = 0
staticconstexpr

Dimension of the Fischer-Burmeister function (already counded in nc).

◆ nu

constexpr int cgmres::OCP_pendubot::nu = 1
staticconstexpr

Dimension of the control input.

◆ nub

constexpr int cgmres::OCP_pendubot::nub = 1
staticconstexpr

Dimension of the bound constraints on the control input.

◆ nuc

constexpr int cgmres::OCP_pendubot::nuc = nu + nc
staticconstexpr

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

◆ nx

constexpr int cgmres::OCP_pendubot::nx = 4
staticconstexpr

Dimension of the state.

◆ q

std::array<double, 4> cgmres::OCP_pendubot::q = {1, 1, 0.1, 0.1}

◆ q_terminal

std::array<double, 4> cgmres::OCP_pendubot::q_terminal = {1, 1, 0.1, 0.1}

◆ r

std::array<double, 1> cgmres::OCP_pendubot::r = {0.1}

◆ ubound_indices

constexpr std::array<int, nub> cgmres::OCP_pendubot::ubound_indices = {0}
staticconstexpr

◆ umax

std::array<double, nub> cgmres::OCP_pendubot::umax = {5.0}

◆ umin

std::array<double, nub> cgmres::OCP_pendubot::umin = {-5.0}

◆ x_ref

std::array<double, 4> cgmres::OCP_pendubot::x_ref = {M_PI, 0, 0, 0}

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