UI /

Systems

Modeling of dynamical systems in MPT3

MPT3 support four classes of dynamical systems:

  1. Linear systems, represented by the LTISystem class,
  2. Affine systems, represented by the LTISystem class,
  3. Piecewise affine (PWA) systems, represented by the PWASystem class,
  4. Mixed Logical Dynamical (MLD) systems, represented by the MLDSystem class.

Linear systems

MPT3 allows to create models of linear time-invariant (LTI) models of the form

{$ \begin{align} x(t+\Delta t) = A x(t) + B u(t) \\ y(t) = Cx(t) + Du(t) \end{align}$}

where {$ x(t) $} is the state vector at time {$t$}, {$u(t)$} is the vector of control inputs, {$y(t)$} are the system's outputs, and {$\Delta t$} represents the sampling time.

To define an LTI system, use the LTISystem command and provide a list of system's parameters:

sys = LTISystem('A', A, 'B', B, 'C', C, 'D', D, 'Ts', Ts)

All parameters, except of the A matrix, are optional and can be omitted. If the sampling time is not given, Ts=1 will be assumed.

You can easily define an LTI system with zero outputs as follows:

sys = LTISystem('A', A, 'B', B)

Similarly, to define an autonomous system {$ x(t+\Delta t) = A x(t)$}, {$y(t) = C x(t)$}, just call

sys = LTISystem('A', A, 'C', C, 'Ts', Ts)

Affine systems

Affine systems are represented by

{$ \begin{align} x(t+\Delta t) = A x(t) + B u(t) + f\\ y(t) = Cx(t) + Du(t) + g \end{align}$}

where, in addition to LTI systems, we can also define the {$f$} and {$g$} affine terms in the state-update and output equations, respectively.

Affine systems are created by the LTISystem command:

sys = LTISystem('A', A, 'B', B, 'f', f, 'C', C, 'D', D, 'g', g, 'Ts', Ts)

Similarly as above, any parameter (except of the A matrix) can be omitted, e.g.:

sys = LTISystem('A', A, 'f', f)

will create the autonomous affine system {$ x(t+1) = A x(t) + f$}.

Piecewise Affine (PWA) systems

PWA systems are represented by a set of state-update and output equations, each valid in a polyhedral region of the state-input space, i.e.,

{$ \begin{align} x(t+\Delta t) & = \begin{cases} A_1 x(t) + B_1 u(t) + f_1 ~\text{if}~(x(t), u(t)) \in \mathcal{R}_1\\ \vdots \\ A_M x(t) + B_M u(t) + f_M ~\text{if}~(x(t), u(t)) \in \mathcal{R}_M \end{cases}\\ y(t) &= \begin{cases} C_1 x(t) + D_1 u(t) + g_1 ~\text{if}~(x(t), u(t)) \in \mathcal{R}_1\\ \vdots \\ C_M x(t) + D_M u(t) + g_M ~\text{if}~(x(t), u(t)) \in \mathcal{R}_M \end{cases} \end{align} $}

where {$\mathcal{R}_1, \ldots, \mathcal{R}_M $} are polyhedra and {$M$} denotes the number of modes of the PWA system.

The easiest way to define PWA systems in MPT3 is to first describe each local dynamics as an affine system:

sys1 = LTISystem('A', A_1, 'B', B_1, 'C', C_1, 'D', D_1, 'f', f_1, 'g', g_1, 'Ts', Ts);
...
sysM = LTISystem('A', A_M, 'B', B_M, 'C', C_M, 'D', D_M, 'f', f_M, 'g', g_M, 'Ts', Ts);

Then assign the region of validity of each local model:

sys1.setDomain('xu', R_1)
...
sysM.setDomain('xu', R_M)

where R_1, ..., R_M must be polyhedra created by the Polyhedron command.

Finally, we can create the PWA system by providing the list of local linear models to the PWASystem constructor:

pwa = PWASystem([sys1, ..., sysM])

Note that you can omit all parameters except of the A matrix when defining the local linear models. For instance, to define an autonomous system of the form

{$ x(t+\Delta t) = \begin{cases} A_1 x(t) + f_1 ~\text{if}~(x(t), u(t)) \in \mathcal{R}_1\\ A_2 x(t) + f_2 ~\text{if}~(x(t), u(t)) \in \mathcal{R}_2 \end{cases} $}

one would call

sys1 = LTISystem('A', A_1, 'f', f_1, 'Ts', Ts)
sys1.setDomain('xu', R_1)
sys2 = LTISystem('A', A_2, 'f', f_2, 'Ts', Ts)
sys2.setDomain('xu', R_2)
pwa = PWASystem([sys1, sys2])

By default, MPT3 expects that the regions of validity of corresponding local affine models (i.e., regions R_1, R_2) are polyhedra in the state-input space. It is also possible to define PWA systems whose regions are only given in the state-space, i.e.,

{$ \begin{align} x(t+\Delta t) & = \begin{cases} A_1 x(t) + B_1 u(t) + f_1 ~\text{if}~x(t) \in \mathcal{R}_1\\ \vdots \\ A_M x(t) + B_M u(t) + f_M ~\text{if}~x(t) \in \mathcal{R}_M \end{cases}\\ y(t) &= \begin{cases} C_1 x(t) + D_1 u(t) + g_1 ~\text{if}~x(t) \in \mathcal{R}_1\\ \vdots \\ C_M x(t) + D_M u(t) + g_M ~\text{if}~x(t) \in \mathcal{R}_M \end{cases} \end{align} $}

Here, the only difference to the above procedure is that you should use sys.setDomain('x', Ri) when defining the individual affine models.

Similarly, it is also possible to define PWA systems where switching of local models depends only on the value of the control vector:

{$ \begin{align} x(t+\Delta t) & = \begin{cases} A_1 x(t) + B_1 u(t) + f_1 ~\text{if}~u(t) \in \mathcal{R}_1\\ \vdots \\ A_M x(t) + B_M u(t) + f_M ~\text{if}~u(t) \in \mathcal{R}_M \end{cases}\\ y(t) &= \begin{cases} C_1 x(t) + D_1 u(t) + g_1 ~\text{if}~u(t) \in \mathcal{R}_1\\ \vdots \\ C_M x(t) + D_M u(t) + g_M ~\text{if}~u(t) \in \mathcal{R}_M \end{cases} \end{align} $}

This is achieved by calling sys.setDomain('u', Ri) when defining the domain of each local affine model.

Mixed Logical Dynamical (MLD) systems

MLD models represent hybrid systems that can be generated using HYSDEL

To generate an MLD form from a model described by its HYSDEL file, use the MLDSystem constructor:

mld = MLDSystem('my_file.hys')

You can also import the MLD model from a structure generated by HYSDEL2 or HYSDEL3:

mld = MLDSystem(S)

Here, S must be a structure with following fields: A, B1, B2, B3, B5, C, D1, D2, D3, D5, E1, E2, E3, E4, E5, xl, xu, ul, uu, yl, yu, dl, du, zl, zu, nx, nu, ny, nz, nd, nxb, nxr, nub, nur, nyb, nyr.

If the source file contains symbolic parameters, it is necessary to provide values of such parameters, stored in a structure, as the second input argument:

parameters.first_symbolic_parameter = 1;
parameters.second_symbolic_parameter = 1.2;
...
mld = MLDSystem('my_file.hys', parameters)