YANE-Framework 1.1.0
Public Member Functions | Static Public Member Functions

yane::MPC::Discretization Class Reference

Class for discretizing optimal control problem. More...

Collaboration diagram for yane::MPC::Discretization:
[legend]

List of all members.

Public Member Functions

double abortSuboptimalityDegree ()
 Function to return the current value of the suboptimality bound used within the suboptimality based stopping criterion.
void calc (double *x, int realtimesteps=0, double aborttimeoffset=0.0)
 Function to solve the discretized optimal control problem.
Discretizationclone (int horizon=-1)
 Function to create a cloned object using identical odemanager and minimizer from classes yane::MPC:OdeManager and yane::MinProg::NLP respectively.
double * currentx ()
 Function to return the pointer of the internal copy of the state vector.
int dimension_restr ()
 Function to return the number of restrictions of the optimal control problem before discretization.
int dimension_u ()
 Function to return the dimension of the conrol.
int dimension_x ()
 Function to return the dimension of the state variable.
 Discretization (OdeManager *odemanager, yane::MinProg::NLP *minimizer, yane::Model::Model *model, int horizon, ModelShootingData *shootingdata, double INFTY=1E19)
 Constructor.
int horizon ()
 Function to return the current horizon length.
double infty ()
 Function to return the number associated with infinity.
void initCalc (double *t, double *u0)
 Function to initialize the discretized optimal control problem.
double * lbound_u ()
 Function to return the pointer of the lower bounds of the control.
double * lbound_x ()
 Function to return the pointer of the lower bounds of the states.
yane::MinProg::NLPminimizer ()
 Function to return the pointer of the used class yane::MinProg::NLP object.
yane::Model::Modelmodel ()
 Function to return the pointer of the model.
OdeManagerodemanager ()
 Function to return the pointer of the differential equation manager.
OdeManagerodeManager ()
 unction to return the pointer of the used class yane::MPC::OdeManager object
T_SHOOTINGDATAsdata ()
 Function to return the structure of the shooting nodes.
int sdatalength ()
 Function to return the number of shooting nodes.
void setAbortSuboptimalityCriterionValues (double abortSuboptimalityDegree, double previousCostfunctionValue=0.0, double previousRunningcostValue=0.0)
 Function to set the data used for the suboptimality based stopping criterion.
bool suboptimalityCheck (double currentCostfunctionValue)
 Function to check whether the suboptimality based stopping criterion is satisfied.
double * timesteps ()
 Function to return the pointer of the internal copy of the time grid.
int totalRestrictionNumber ()
 Function to return the total number of restrictions of the discretized optimal control problem.
double * u_zero ()
 Function to return the pointer of a zero control vector.
double * ubound_u ()
 Function to return the pointer of the upper bounds of the control.
double * ubound_x ()
 Function to return the pointer of the upper bounds of the states.
 ~Discretization ()
 Destructor.

Static Public Member Functions

static void min_func (const double *x, double *fx, void *params)
 Function to evaluate the cost function.
static void min_func_grad (const double *x, double *fx, void *params)
 Function to evaluate the gradient of the cost function.
static void min_restr (const double *x, double *fx, void *params)
 Function to evaluate the restrictions.
static void min_restr_grad (const double *x, double *fx, void *params)
 Function to evaluate the Jacobian of the restrictions.

Detailed Description

This class can be used to define and solve an optimal control problem of the form

\begin{eqnarray*} \mbox{Minimize} \; J_N(x, u) & = & \sum\limits_{i = 0}^{N - 1} \int\limits_{t_i}^{t_{i+1}} l(x, u) dt + F(x(t_N)) \\ \mbox{subject to} & \\ \dot{x}(t) & = & f(x(t), u(t_i)) \qquad \forall t \in [t_i, t_{i + 1}) \\ g_l(t) & \leq & g(x(t), u(t)) \leq g_u(t) \qquad \forall t \in [t_0, t_N] \\ x(\cdot) & \in & X \\ u(\cdot) & \in & U \end{eqnarray*}

To this end a (not necessarily equidistant) time grid is defined and the control problem is discretized with respect to this time grid. The resulting optimization problem is then handed over to a class yane::MinProg::NLP object.


Constructor & Destructor Documentation

yane::MPC::Discretization::Discretization ( OdeManager odemanager,
yane::MinProg::NLP minimizer,
yane::Model::Model model,
int  horizon,
ModelShootingData shootingdata,
double  INFTY = 1E19 
)

Constructor

Parameters:
odemanagerPointer of the odemanager object of class yane::MPC::OdeManager
minimizerPointer of the minimizer object of class yane::MinProg::NLP
modelPointer of the model object of class yane::Model::Model
horizonLength of the optimization horizon in sampling instances
INFTYValue for infinity
Exceptions:
yane::Utils::ValueExceptionIs thrown if input values are incorrect
yane::Utils::MemoryExceptionIs thrown if memory allocation failed
yane::MinProg::MinProgExceptionIs thrown if the discretized optimization problem or the prediction or the odemanager cannot be initialized
yane::Utils::ExceptionIs thrown if the odemanager cannot be initialized

Member Function Documentation

double yane::MPC::Discretization::abortSuboptimalityDegree ( void  )

Function to return the current value of the suboptimality bound used within the suboptimality based stopping criterion

Returns:
Current value of the suboptimality bound
void yane::MPC::Discretization::calc ( double *  x,
int  realtimesteps = 0,
double  aborttimeoffset = 0.0 
)

Function to solve the discretized optimal control problem

Parameters:
xEstimate of the initial value of the state
realtimestepsNumber of time steps on the time grid after which the computation shall be terminated (0 = no limit)
aborttimeoffsetTime offset after which the computation shall be terminated (negative values shorten the time interval available for optimization)
Exceptions:
yane::Utils::ValueExceptionIs thrown if a null pointer is submitted
yane::MinProg::SolverWarningIs thrown if the yane::MinProg::NLP object terminates with a warning
yane::Utils::ExceptionIs thrown if any other error occurs
yane::MPC::Discretization * yane::MPC::Discretization::clone ( int  horizon = -1)

Function to create a cloned object using identical odemanager and minimizer from classes yane::MPC:OdeManager and yane::MinProg::NLP respectively. The clone can be initialized with a different horizon length.
Note that local modifications of the odemanager and the minimizer objects are not cloned and have to be redone. This object must be destructed by the user and its destruction automatically destructs the corresponding odemanager and minimizer objects.

Parameters:
horizonLength of the horizon for the cloned object
Exceptions:
yane::MPC::MPCExceptionIs thrown if the underlying yane::MPC::MPC object terminates with an error
yane::Utils::MemoryExceptionIs thrown if memory allocation fails
yane::Utils::ExceptionIs thrown if any other error occurs
double * yane::MPC::Discretization::currentx ( )

Function to return the pointer of the internal copy of the state vector

Returns:
Pointer of the internal copy of the state vector
int yane::MPC::Discretization::dimension_restr ( )

Function to return the number of restrictions of the optimal control problem before discretization

Returns:
Number of restrictions of the optimal control problem before discretization
int yane::MPC::Discretization::dimension_u ( )

Function to return the dimension of the control

Returns:
Dimension of the control
int yane::MPC::Discretization::dimension_x ( )

Function to return the dimension of the state variable

Returns:
Dimension of the state variable
int yane::MPC::Discretization::horizon ( )

Function to return the current horizon length

Returns:
Current horizon length
double yane::MPC::Discretization::infty ( )

Function to return the number associated with infinity

Returns:
Number associated with infinity
void yane::MPC::Discretization::initCalc ( double *  t,
double *  u0 
)

Function to initialize the discretized optimal control problem

Parameters:
tTime grid
u0Initial guess of the control
double * yane::MPC::Discretization::lbound_u ( )

Function to return the pointer of the lower bounds of the control

Returns:
Pointer of the lower bounds of the control
double * yane::MPC::Discretization::lbound_x ( )

Function to return the pointer of the lower bounds of the states

Returns:
Pointer of the lower bounds of the states
void yane::MPC::Discretization::min_func ( const double *  x,
double *  fx,
void *  params 
) [static]

Function to evaluate the cost function

Parameters:
xEstimate of the initial value of the state
fxValue of the cost function
paramsParameter vector of the optimal control problem
void yane::MPC::Discretization::min_func_grad ( const double *  x,
double *  fx,
void *  params 
) [static]

Function to evaluate the gradient of the cost function

Parameters:
xEstimate of the initial value of the state
fxGradient of the cost function
paramsParameter vector of the optimal control problem
void yane::MPC::Discretization::min_restr ( const double *  x,
double *  fx,
void *  params 
) [static]

Function to evaluate the restrictions

Parameters:
xEstimate of the initial value of the state
fxVector of values of the restrictions
paramsParameter vector of the optimal control problem
void yane::MPC::Discretization::min_restr_grad ( const double *  x,
double *  fx,
void *  params 
) [static]

Function to evaluate the Jacobian of the restrictions

Parameters:
xEstimate of the initial value of the state
fxJacobian of the constraints
paramsParameter vector of the optimal control problem
yane::MinProg::NLP * yane::MPC::Discretization::minimizer ( )

Function to return the pointer of the used class yane::MinProg::NLP object

Returns:
Pointer of the used class yane::MinProg::NLP object
yane::Model::Model * yane::MPC::Discretization::model ( )

Function to return the pointer of the model

Returns:
Pointer of the model
yane::MPC::OdeManager * yane::MPC::Discretization::odeManager ( )

Function to return the pointer of the used class yane::MPC::OdeManager object

Returns:
Pointer of the used class yane::MPC::OdeManager object
yane::MPC::OdeManager * yane::MPC::Discretization::odemanager ( )

Function to return the pointer of the differential equation manager

Returns:
Pointer of the differential equation manager
yane::MPC::T_SHOOTINGDATA * yane::MPC::Discretization::sdata ( )

Function to return the structure of shooting nodes

Returns:
Structure of the shooting nodes
int yane::MPC::Discretization::sdatalength ( )

Function to return the number of shooting nodes

Returns:
Number of shooting nodes
void yane::MPC::Discretization::setAbortSuboptimalityCriterionValues ( double  abortSuboptimalityDegree,
double  previousCostfunctionValue = 0.0,
double  previousRunningcostValue = 0.0 
)

Function to set the data used for the suboptimality based stopping criterion

Parameters:
abortSuboptimalityDegreeBound of the suboptimality degree
previousCostfunctionValueValue of the cost function in the previous MPC step
previousRunningcostValueValue of the running cost in the previous MPC step
bool yane::MPC::Discretization::suboptimalityCheck ( double  currentCostfunctionValue)

Function to check whether the suboptimality based stopping criterion is satisfied

Parameters:
currentCostfunctionValueValue of the cost function for the current control vector
Returns:
Decision variable
double * yane::MPC::Discretization::timesteps ( )

Function to return the pointer of the internal copy of the time grid

Returns:
Pointer of the internal copy of the time grid
int yane::MPC::Discretization::totalRestrictionNumber ( )

Function to return the total number of restrictions of the discretized optimal control problem

Returns:
Total number of restrictions of the discretized optimal control problem
double * yane::MPC::Discretization::u_zero ( )

Function to return the pointer of zero control vector

Returns:
Pointer of a zero control vector
double * yane::MPC::Discretization::ubound_u ( )

Function to return the pointer of the upper bounds of the control

Returns:
Pointer of the upper bounds of the control
double * yane::MPC::Discretization::ubound_x ( )

Function to return the pointer of the upper bounds of the states

Returns:
Pointer of the upper bounds of the states