! Modeling of dynamical systems in MPT3
MPT3 support four classes of dynamical systems:
# [[UISystems#Linear-systems| Linear systems]], represented by the @LTISystem@ class,
# [[UISystems#Affine-systems| Affine systems]], represented by the @LTISystem@ class,
# [[UISystems#Piecewise-Affine-PWA-systems| Piecewise affine (PWA) systems]], represented by the @PWASystem@ class,
# [[UISystems#Mixed-Logical-Dynamical-MLD-systems| 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
(:source lang=MATLAB -getcode:) [@
x(t+Ts) = A x(t) + B u(t)
y(t) = C x(t) + D u(t)
@]
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 @Ts@ represents the sampling time.
To define an LTI system, use the @LTISystem@ command and provide a list of system's parameters:
(:source lang=MATLAB -getcode:) [@
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:
(:source lang=MATLAB -getcode:) [@
sys = LTISystem('A', A, 'B', B)
@]
Similarly, to define an autonomous system @x(t+Ts) = A x(t)@, @y(t) = C x(t)@, just call
(:source lang=MATLAB -getcode:) [@
sys = LTISystem('A', A, 'C', C, 'Ts', Ts)
@]
!! Affine systems
Affine systems are represented by
(:source lang=MATLAB -getcode:) [@
x(t+Ts) = A x(t) + B u(t) + f
y(t) = C x(t) + D u(t) + g
@]
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:
(:source lang=MATLAB -getcode:) [@
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.:
(:source lang=MATLAB -getcode:) [@
sys = LTISystem('A', A, 'f', f)
@]
will create the 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.,
(:source lang=MATLAB -getcode:) [@
{ A_1 x(t) + B_1 u(t) + f_1 if [x(t); u(t)] \in R_1
x(t+Ts) = {
{ A_M x(t) + B_M u(t) + f_M if [x(t); u(t)] \in R_M
{ C_1 x(t) + D_1 u(t) + g_1 if [x(t); u(t)] \in R_1
y(t) = {
{ C_M x(t) + D_M u(t) + g_M if [x(t); u(t)] \in R_M
@]
where @R_1@, ..., @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:
(:source lang=MATLAB -getcode:) [@
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:
(:source lang=MATLAB -getcode:) [@
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:
(:source lang=MATLAB -getcode:) [@
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
(:source lang=MATLAB -getcode:) [@
{ A_1 x(t) + f_1 if [x(t); u(t)] \in R_1
x(t+Ts) = {
{ A_2 x(t) + f_2 if [x(t); u(t)] \in R_2
@]
one would call
(:source lang=MATLAB -getcode:) [@
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.,
(:source lang=MATLAB -getcode:) [@
{ A_1 x(t) + B_1 u(t) + f_1 if x(t) \in R_1
x(t+Ts) = {
{ A_M x(t) + B_M u(t) + f_M if x(t \in R_M
{ C_1 x(t) + D_1 u(t) + g_1 if x(t) \in R_1
y(t) = {
{ C_M x(t) + D_M u(t) + g_M if x(t) \in R_M
@]
Here, the only difference to the above procedure is that you should use @sys.setDomain('x', R)@ 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:
(:source lang=MATLAB -getcode:) [@
{ A_1 x(t) + B_1 u(t) + f_1 if u(t) \in R_1
x(t+Ts) = {
{ A_M x(t) + B_M u(t) + f_M if u(t \in R_M
{ C_1 x(t) + D_1 u(t) + g_1 if u(t) \in R_1
y(t) = {
{ C_M x(t) + D_M u(t) + g_M if u(t) \in R_M
@]
This is achieved by calling @sys.setDomain('u', R)@ when defining the domain of each local affine model.
!! Mixed Logical Dynamical (MLD) systems
MLD models represent hybrid systems that can be generated using [[http://control.ee.ethz.ch/~hybrid/hysdel/hysdel.php|HYSDEL]]
To generate an MLD form from a model described by its HYSDEL file, use the @MLDSystem@ constructor:
(:source lang=MATLAB -getcode:) [@
mld = MLDSystem('my_file.hys')
@]
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:
(:source lang=MATLAB -getcode:) [@
parameters.first_symbolic_parameter = 1;
parameters.second_symbolic_parameter = 1.2;
...
mld = MLDSystem('my_file.hys', parameters)
@]
Note that the HYSDEL compiler is already included in the MPT3 distribution package.