Model

class do_mpc.model.Model(model_type=None)[source]

The do-mpc model class. This class holds the full model description and is at the core of do_mpc.simulator.Simulator, do_mpc.controller.MPC and do_mpc.estimator.Estimator. The Model class is created with setting the model_type (continuous or discrete). A continous model consists of an underlying ordinary differential equation (ODE) or differential algebraic equation (DAE):

\[\begin{split}\dot{x}(t) &= f(x(t),u(t),z(t),p(t),p_{\text{tv}}(t)) + w(t),\\ 0 &= g(x(t),u(t),z(t),p(t),p_{\text{tv}}(t))\\ y &= h(x(t),u(t),z(t),p(t),p_{\text{tv}}(t)) + v(t)\end{split}\]

whereas a discrete model consists of a difference equation:

\[\begin{split}x_{k+1} &= f(x_k,u_k,z_k,p_k,p_{\text{tv},k}) + w_k,\\ 0 &= g(x_k,u_k,z_k,p_k,p_{\text{tv},k})\\ y_k &= h(x_k,u_k,z_k,p_k,p_{\text{tv},k}) + v_k\end{split}\]

Configuration and setup:

Configuring and setting up the Model involves the following steps:

  1. Use set_variable() to introduce new variables to the model.
  2. Optionally introduce “auxiliary” expressions as functions of the previously defined variables with set_expression(). The expressions can be used for monitoring or be reused as constraints, the cost function etc.
  3. Optionally introduce measurement equations with set_meas(). The syntax is identical to set_expression(). By default state-feedback is assumed.
  4. Define the right-hand-side of the discrete or continuous model as a function of the previously defined variables with set_rhs(). This method must be called once for each introduced state.
  5. Call setup() to finalize the Model. No further changes are possible afterwards.

Note

All introduced model variables are accessible as Attributes of the Model. Use these attributes to query to variables, e.g. to form the cost function in a seperate file for the MPC configuration.

Parameters:

model_type – Set if the model is discrete or continuous.

Raises:
  • assertion – model_type must be string
  • assertion – model_type must be either discrete or continuous
__getitem__(ind)[source]

The Model class supports the __getitem__ method, which can be used to retrieve the model variables (see attribute list).

# Query the states like this:
x = model.x
# or like this:
x = model['x']

This also allows to retrieve multiple variables simultaneously:

x, u, z = model['x','u','z']

Attributes

Model.aux Auxiliary expressions.
Model.p Static parameters.
Model.tvp Time-varying parameters.
Model.u Inputs.
Model.v Measurement noise.
Model.w Process noise.
Model.x Dynamic states.
Model.y Measurements.
Model.z Algebraic states.

Methods

Model.set_alg Introduce new algebraic equation to model.
Model.set_expression Introduce new expression to the model class.
Model.set_meas Introduce new measurable output to the model class.
Model.set_rhs Formulate the right hand side (rhs) of the ODE:
Model.set_variable Introduce new variables to the model class.
Model.setup Setup method must be called to finalize the modelling process.

This page is auto-generated. Page source is not available on Github.