YANE-Framework 1.1.0
Public Member Functions | Protected Member Functions | Protected Attributes

yane::Model::Model Class Reference

Abstract class to define the model of the process and the optimal control problem to be solved. More...

Collaboration diagram for yane::Model::Model:
[legend]

List of all members.

Public Member Functions

virtual double continuousCostfunction (double t, double *x, double *u)=0
 Function to implement the integral part of the cost function

\[ L \left( t, x_{u}(t, x_0), u(t, x_0) \right) \]

.

virtual void costfunctionDerivativeT (double t, double *x, double *u, double *dot)
 Function to implement the derivative with respect to time of the cost function of the control system.
virtual void costfunctionGradient (double t, double *x, double *u, double *dobj)
 Function to implement the gradient of the cost function of the control system.
virtual int dimensionControl ()
 Function to obtain the dimension of the control.
virtual int dimensionState ()
 Function to obtain the dimension of the state.
virtual double discreteCostfunction (int length, int horizont, double *t, double *x, double *u)=0
 Function to implement the discrete running cost as well as the terminal cost term of the cost function of the control system

\[ l \left( t_k, x_{u}(t_k, x_0), u(t_k, x_0) \right) \qquad \mbox{and} \qquad F(t_N, x_{u}(t_N, x_0)) \]

.

virtual double doubleParameter (int paramid)
 Function to obtain the value of a double parameter.
virtual int doubleParameterSize ()
 Function to obtain the number of double parameters.
virtual void dynamicDerivativeT (double t, double *x, double *u, double *dft)
 Function to implement the derivative with respect to time of the dynamic of the control system.
virtual void eventBeforeMPC (int horizon, double *timesteps, double *x, double *sdatavalues)
 Function to implement the internal resets for the yane::MPC::MPC class object at each iterate of the MPC process.
virtual void getControlBounds (double *lb, double *ub)
 Function to obtain the box constraints of the control.
virtual void getDefaultControl (double *u)=0
 Function to get the default values of the control defined for the control system under consideration.
virtual void getDefaultState (double *x)=0
 Function to get the default values defined for the control system under consideration.
virtual void getModelBounds (double *lb, double *ub)
 Function to get the box constraints of the state.
virtual void getObjectiveWeight (double &obj_weight, double &pointcost_weight)=0
 Function to put different weights on the integral and discrete time parts of the cost functional.
virtual int intParameter (int paramid)
 Function to obtain the value of a integer parameter.
virtual int intParameterSize ()
 Function to obtain the number of integer parameters.
virtual void jacobiMatrix (double t, double *x, double *u, double *dy)
 Function to implement the Jacobian of the constraints of the control system.
virtual void massMatrix (double *mass)
 Function to implement the mass matrix of the control system.
virtual double networkCostfunction (int length, int horizont, double *t, double *x, double *u, double *x_neighbour, double *u_neighbour, double *multiplier)
 Function to implement the discrete running cost as well as the terminal cost term of the cost function of the control system in a networked context.
virtual void networkRestrictionFunction (double t, double *x, double *u, double *x_neighbour, double *u_neighbour, double *fx)
 Function to implement the nonlinear constraints of the decentralized control system with are induced by neighbouring systems.
virtual int networkRestrictionSize ()
 Function to obtain the number of restrictions due to the network context.
virtual yane::OdeSolve::OdeConfigodeConfig ()
 Function to obtain the pointer of the yane::OdeSolve::OdeConfig object which is suitable for the yane::OdeSolve::OdeSolve object defined in the considered class yane::Model::Model object.
virtual void odeFunction (double t, double *x, double *u, double *dx)=0
 Function to implement the dynamic of the system

\[ \dot{x}_{u}(t) = f(t, x_{u}(t, x_0), u(t, x_0)) \]

.

virtual
yane::OdeSolve::OdeSolveFirst
odeSolver ()
 Function to obtain the pointer of the yane::OdeSolve::OdeSolve object which is suitable for the considered class yane::Model::Model object.
virtual void restrictionFunction (double t, double *x, double *u, double *fx)=0
 Function to implement the nonlinear constraints

\begin{eqnarray*} x_{u}(t, x_0) & \in & X \qquad \forall t \in [t_0, t_N] \\ u(t, x_0) & \in & U \qquad \forall t \in [t_k, t_k) \end{eqnarray*}

.

virtual int restrictionSize ()
 Function to obtain the number of restrictions.
virtual void setControlBounds (double *lb, double *ub)
 Function to set the box constraints of the control.
virtual void setDimensionControl (int ctrl_dimension)
 Function to set the dimension of the control.
virtual void setDimensionState (int dimension)
 Function to set the dimension of the state.
virtual void setDoubleParameter (int paramid, double value)
 Function to set the value of a double parameter.
virtual void setIntParameter (int paramid, int value)
 Function to set the value of a integer parameter.
virtual void setModelBounds (double *lb, double *ub)
 Function to set the box constraints of the state.
virtual void setNetworkRestrictionSize (int networkrestrsize)
 Function to set the number of restrictions due to the network context.
virtual int setRestrictionSize (int restrsize)
 Function to set the number of restrictions.

Protected Member Functions

 Model (yane::OdeSolve::OdeSolveFirst *ode, yane::OdeSolve::OdeConfig *odeconf, int dimension, int ctrl_dimension, int restrsize, int paramsize=0, int iparamsize=0, int networkrestrsize=0)
 Constructor.

Protected Attributes

double * _control_lb
 Array of lower bounds on the control.
double * _control_ub
 Array of upper bounds on the control.
int _ctrl_dimension
 Dimension of the control variable.
int _dimension
 Dimension of the state variable.
int * _iparams
 Array of integer parameters.
int _iparamsize
 Number of integer parameters.
int _network_restrsize
 Number of nonlinear constraints due to the network context.
yane::OdeSolve::OdeSolveFirst_ode
 Pointer to the used yane::OdeSolve::OdeSolveFirst object.
yane::OdeSolve::OdeConfig_odeconfig
 Pointer to the used yane::OdeSolve::OdeConfig object.
double * _params
 Array of double parameters.
int _paramsize
 Number of double parameters.
int _restrsize
 Number of nonlinear constraints.
double * _state_lb
 Array of lower bounds on the state.
double * _state_ub
 Array of upper bounds on the state.

Detailed Description

This class gives an abstract definition of the model and the optimal control problem which shall be considered. The model itself is defined via its dynamic

\[ \dot{x}_{u}(t) = f(x_{u}(t, x_0), u(t, x_0)) \]

on the optimization horizon $ [t_0, t_N] $ with initial value $ x_{u}(t_0, x_0) = x_0 $. Moreover, the solution of the control system shall satisfy given constraints

\begin{eqnarray*} x_{u}(t, x_0) & \in & X \qquad \forall t \in [t_0, t_N] \\ u(t, x_0) & \in & U \qquad \forall t \in [t_k, t_k) \end{eqnarray*}

Since we suppose at least control law $ u(\cdot) $ to exist which satisfies all these constraints, i.e. is feasible, an optimization critierion

\begin{eqnarray*} J_N (x_0, u) & = & \sum\limits_{k=0}^{N - 1} \int\limits_{t_k}^{t_{k + 1}} L \left( \tau, x_{u}(\tau, x_0), u(\tau, x_0) \right) d \tau \\ && + \sum\limits_{k=0}^{N - 1} l \left( t_k, x_{u}(t_k, x_0), u(t_k, x_0) \right) + F(t_N, x_{u}(t_N, x_0)) \end{eqnarray*}

is added to measure the quality of feasible solutions.


Constructor & Destructor Documentation

LIB_EXPORT yane::Model::Model::Model ( yane::OdeSolve::OdeSolveFirst ode,
yane::OdeSolve::OdeConfig odeconf,
int  dimension,
int  ctrl_dimension,
int  restrsize,
int  paramsize = 0,
int  iparamsize = 0,
int  networkrestrsize = 0 
) [protected]

Constructor

Parameters:
odePointer to the used yane::OdeSolve::OdeSolveFirst object
odeconfPointer to the used yane::OdeSolve::OdeConfig object
dimensionDimension of the state variable
ctrl_dimensionDimension of the control variable
restrsizeNumber of nonlinear constraints
paramsizeNumber of double parameters
iparamsizeNumber of integer parameters
networkrestrsizeNumber of restrictions per model arising from the network context
Exceptions:
yane::Utils::MemoryExceptionIs thrown if the memory allocation failed

Member Function Documentation

virtual double yane::Model::Model::continuousCostfunction ( double  t,
double *  x,
double *  u 
) [pure virtual]

This function implements the integral function of the cost function

\[ L \left( x_{u}(\cdot, x_0), u(\cdot, x_0) \right) \]

Parameters:
tTime instant
xState vector
uControl vector
Returns:
Value of the integral function
LIB_EXPORT void yane::Model::Model::costfunctionDerivativeT ( double  t,
double *  x,
double *  u,
double *  dot 
) [virtual]

This function implements the derivative with respect to time of the cost function of the control system.

Parameters:
tTime instant
xState vector
uControl vector
dotTime derivative of the cost function of the control system
Exceptions:
UndefinedExceptionIs thrown if time derivative of the cost function is undefined
LIB_EXPORT void yane::Model::Model::costfunctionGradient ( double  t,
double *  x,
double *  u,
double *  dobj 
) [virtual]

This function implements the gradient of the cost function of the control system.

Parameters:
tTime instant
xState vector
uControl vector
dobjGradient of the cost function of the control system
Exceptions:
UndefinedExceptionIs thrown if gradient of the cost function is undefined
LIB_EXPORT int yane::Model::Model::dimensionControl ( ) [virtual]

This function gives back the dimension of the control.

Returns:
Dimension of the control
LIB_EXPORT int yane::Model::Model::dimensionState ( ) [virtual]

This function gives back the dimension of the state.

Returns:
Dimension of the state
virtual double yane::Model::Model::discreteCostfunction ( int  length,
int  horizont,
double *  t,
double *  x,
double *  u 
) [pure virtual]

This function implements the discrete running cost as well as the terminal cost term of the cost function of the control system

\[ l \left( t_k, x_{u}(t_k, x_0), u(t_k, x_0) \right) \qquad \mbox{and} \qquad F(t_N, x_{u}(t_N, x_0)) \]

Parameters:
lengthLength of the sum
horizontLength of the optimization horizon
tTime grid
xOpen loop state trajectory on the time grid
uOpen loop control trajectory on the time grid
Returns:
Value of the discrete running cost
LIB_EXPORT double yane::Model::Model::doubleParameter ( int  paramid) [virtual]

This function gives back the value of a double parameter.

Parameters:
paramidIndex of the parameter
Exceptions:
IndexExceptionIs throw if an invalid index is submitted
Returns:
Value of the parameter
LIB_EXPORT int yane::Model::Model::doubleParameterSize ( ) [virtual]

This funciton gives back the number of double parameters.

Returns:
Number of double parameters
LIB_EXPORT void yane::Model::Model::dynamicDerivativeT ( double  t,
double *  x,
double *  u,
double *  dft 
) [virtual]

This function implements the derivative with respect to time of the dynamic of the control system.

Parameters:
tTime instant
xState vector
uControl vector
dftTime derivative of the dynamic of the control system
Exceptions:
UndefinedExceptionIs thrown if time derivative of the dynamic is undefined
LIB_EXPORT void yane::Model::Model::eventBeforeMPC ( int  horizon,
double *  timesteps,
double *  x,
double *  sdatavalues 
) [virtual]

This function implements the internal resets for the yane::MPC::MPC class object at each iterate of the MPC process. This function allows, e.g., to switch between cost functions, right hand sides of the dynamic, restrictions and allows to set values for shooting nodes.

Parameters:
horizonOptimization horizon
timestepsTime grid
xState vector
sdatavaluesShooting node values
LIB_EXPORT void yane::Model::Model::getControlBounds ( double *  lb,
double *  ub 
) [virtual]

This function gives back the box constraints of the control.

Parameters:
lbPointer on lower bounds of the control
ubPointer on upper bounds of the control
See also:
getDimensionControl
virtual void yane::Model::Model::getDefaultControl ( double *  u) [pure virtual]

This function gives back the default values of the control defined for the control system under consideration.

Parameters:
uPointer for the default control
virtual void yane::Model::Model::getDefaultState ( double *  x) [pure virtual]

This function gives back the default values of the state defined for the control system under consideration.

Parameters:
xPointer for the default state
LIB_EXPORT void yane::Model::Model::getModelBounds ( double *  lb,
double *  ub 
) [virtual]

This function gives back the box constraints of the state

Parameters:
lbPointer on lower bounds of the state
ubPointer on upper bounds of the state
See also:
getDimension
virtual void yane::Model::Model::getObjectiveWeight ( double &  obj_weight,
double &  pointcost_weight 
) [pure virtual]

This function allows the user to put different weights on the integral and discrete time parts of the cost functional.

Parameters:
obj_weightWeighting factor of the integral part of the cost function
pointcost_weightWeighting factor of the discrete time part of the cost function
LIB_EXPORT int yane::Model::Model::intParameter ( int  paramid) [virtual]

This function gives back the value of a integer parameter.

Parameters:
paramidIndex of the parameter
Exceptions:
IndexExceptionIs throw if an invalid index is submitted
Returns:
Value of the parameter
LIB_EXPORT int yane::Model::Model::intParameterSize ( ) [virtual]

This funciton gives back the number of integer parameters.

Returns:
Number of inteter parameters
LIB_EXPORT void yane::Model::Model::jacobiMatrix ( double  t,
double *  x,
double *  u,
double *  dy 
) [virtual]

This function implements the Jacobian of the constraints of the control system.

Parameters:
tTime instant
xState vector
uControl vector
dyValues of the Jacobian
Exceptions:
UndefinedExceptionIs thrown if Jacobian of the constraints is undefined
LIB_EXPORT void yane::Model::Model::massMatrix ( double *  mass) [virtual]

This function implements the mass matrix of the control system.

Parameters:
massMass matrix
Exceptions:
UndefinedExceptionIs thrown if mass matrix is undefined
LIB_EXPORT double yane::Model::Model::networkCostfunction ( int  length,
int  horizont,
double *  t,
double *  x,
double *  u,
double *  x_neighbour,
double *  u_neighbour,
double *  multiplier 
) [virtual]

This function implements the discrete running cost as well as the terminal cost term of the cost function of the control system in a networked context

Parameters:
lengthLength of the sum
horizontLength of the optimization horizon
tTime grid
xOpen loop state trajectory on the time grid
uOpen loop control trajectory on the time grid
x_neighbourState vector of the neighbouring system
u_neighbourControl vector of the neighbouring system
Returns:
Value of the discrete running cost
LIB_EXPORT void yane::Model::Model::networkRestrictionFunction ( double  t,
double *  x,
double *  u,
double *  x_neighbour,
double *  u_neighbour,
double *  fx 
) [virtual]

This function implements the nonlinear constraints of the decentralized control system with are induced by neighbouring systems. By definition, these constraints have to be of the form

\[ r(t, x(t), u(t)) >= 0 \]

Parameters:
tTime instant
xState vector
uControl vector
x_neighbourState vector of the neighbouring system
u_neighbourControl vector of the neighbouring system
fxValues of the constraints
See also:
getRestrictionSize
LIB_EXPORT int yane::Model::Model::networkRestrictionSize ( ) [virtual]

This function gives back the number of restrictions due to the network context.

Returns:
Number of restrictions due to the network context
LIB_EXPORT yane::OdeSolve::OdeConfig * yane::Model::Model::odeConfig ( ) [virtual]

This function gives back the pointer of the yane::OdeSolve::OdeConfig object which is suitable for the yane::OdeSolve::OdeSolve object defined in the considered class yane::Model::Model object

Returns:
Pointer of the tmb::OdeSolve::OdeConfig object
virtual void yane::Model::Model::odeFunction ( double  t,
double *  x,
double *  u,
double *  dx 
) [pure virtual]

This function implements the dynamic of the system

\[ \dot{x}_{u}(t) = f(t, x_{u}(t, x_0), u(t, x_0)) \]

Note that the right hand side $ f( \cdot, \cdot, \cdot ) $ can be stated as a difference equation as well.

Parameters:
tTime instant
xState vector
uControl vector
dxValues of the derivatives
LIB_EXPORT yane::OdeSolve::OdeSolveFirst * yane::Model::Model::odeSolver ( ) [virtual]

This function gives back the pointer of the yane::OdeSolve::OdeSolve object which is suitable for the considered class yane::Model::Model object

Returns:
Pointer of the yane::OdeSolve::OdeSolve object
virtual void yane::Model::Model::restrictionFunction ( double  t,
double *  x,
double *  u,
double *  fx 
) [pure virtual]

This function implements the nonlinear constraints

\begin{eqnarray*} x_{u}(t, x_0) & \in & X \qquad \forall t \in [t_0, t_N] \\ u(t, x_0) & \in & U \qquad \forall t \in [t_k, t_k) \end{eqnarray*}

of the control system. By definition, these constraints have to be of the form

\[ r(t, x(t), u(t)) >= 0 \]

Parameters:
tTime instant
xState vector
uControl vector
fxValues of the constraints
See also:
getRestrictionSize
LIB_EXPORT int yane::Model::Model::restrictionSize ( ) [virtual]

This function gives back the number of restrictions.

Returns:
Number of restrictions
LIB_EXPORT void yane::Model::Model::setControlBounds ( double *  lb,
double *  ub 
) [virtual]

This function sets the box constraints of the control.

Parameters:
lbPointer on lower bounds of the control
ubPointer on upper bounds of the control
LIB_EXPORT void yane::Model::Model::setDimensionControl ( int  ctrl_dimension) [virtual]

This function sets the dimension of the control.
Note that after each change of the dimension of the state the yane::MPC::MPC class object must be reset using the method yane::MPC::MPC::reset.

Parameters:
crtl_dimensionNew dimension of the control
Exceptions:
valueExceptionIs thrown if the new dimension is less than 1
LIB_EXPORT void yane::Model::Model::setDimensionState ( int  dimension) [virtual]

This function sets the dimension of the state.
Note that after each change of the dimension of the state the yane::MPC::MPC class object must be reset using the method yane::MPC::MPC::reset.

Parameters:
dimensionNew dimension of the state
Exceptions:
yane::Utils::ValueExceptionIs thrown if the new dimension is less than 1
LIB_EXPORT void yane::Model::Model::setDoubleParameter ( int  paramid,
double  value 
) [virtual]

This function sets the value of a double parameter.

Parameters:
paramidIndex of the parameter
valueValue of the parameter
Exceptions:
IndexExceptionIs throw if an invalid index is submitted
LIB_EXPORT void yane::Model::Model::setIntParameter ( int  paramid,
int  value 
) [virtual]

This function sets the values of integer parameters.

Parameters:
paramidIndex of the parameter
valueValue of the parameter
Exceptions:
IndexExceptionIs throw if an invalid index is submitted
LIB_EXPORT void yane::Model::Model::setModelBounds ( double *  lb,
double *  ub 
) [virtual]

This function sets the box constraints of the state.

Parameters:
lbPointer on lower bounds of the state
ubPointer on upper bounds of the state
LIB_EXPORT void yane::Model::Model::setNetworkRestrictionSize ( int  networkrestrsize) [virtual]

This function sets the number of the restrictions due to the network context.

Returns:
Number of restrictions due to the network context
LIB_EXPORT int yane::Model::Model::setRestrictionSize ( int  restrsize) [virtual]

This function sets the number of the restrictions.

Returns:
Number of restrictions