Model¶

class
do_mpc.model.
Model
(model_type=None)[source]¶ The dompc model class. This class holds the full model description and is at the core of
do_mpc.simulator.Simulator
,do_mpc.controller.MPC
anddo_mpc.estimator.Estimator
. TheModel
class is created with setting themodel_type
(continuous or discrete). Acontinous
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: Use
set_variable()
to introduce new variables to the model.  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.  Optionally introduce measurement equations with
set_meas()
. The syntax is identical toset_expression()
. By default statefeedback is assumed.  Define the righthandside 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.  Call
setup()
to finalize theModel
. 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
orcontinuous
.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
Timevarying 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.  Use
This page is autogenerated. Page source is not available on Github.