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.MPCanddo_mpc.estimator.Estimator. TheModelclass is created with setting themodel_type(continuous or discrete). Acontinousmodel 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
discretemodel 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
Modelinvolves 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 state-feedback is assumed. - 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. - 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
discreteorcontinuous.Raises: - assertion – model_type must be string
- assertion – model_type must be either discrete or continuous
-
__getitem__(ind)[source]¶ The
Modelclass 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.auxAuxiliary expressions. Model.pStatic parameters. Model.tvpTime-varying parameters. Model.uInputs. Model.vMeasurement noise. Model.wProcess noise. Model.xDynamic states. Model.yMeasurements. Model.zAlgebraic states. Methods
Model.set_algIntroduce new algebraic equation to model. Model.set_expressionIntroduce new expression to the model class. Model.set_measIntroduce new measurable output to the model class. Model.set_rhsFormulate the right hand side (rhs) of the ODE: Model.set_variableIntroduce new variables to the model class. Model.setupSetup method must be called to finalize the modelling process. - Use
This page is auto-generated. Page source is not available on Github.