UI /

Systems

UI.Systems History

Hide minor edits - Show changes to output

February 17, 2016, at 08:22 AM by 2001:67c:10ec:36c2::61 -
Changed line 123 from:
Here, @@S@@ must be a structure with following fields: @@A, B1, B2, B3, B5, C, D1, D2, D3, D5, E1, E2, E3, E4, E5, nx, nu, ny, nz, nd@@.
to:
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@@.
February 17, 2016, at 08:09 AM by 2001:67c:10ec:36c2::61 -
Added lines 118-124:

You can also import the MLD model from a structure generated by HYSDEL2 or HYSDEL3:
(:source lang=MATLAB -getcode:) [@
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, nx, nu, ny, nz, nd@@.

Added lines 86-88:
{$ 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
Deleted lines 89-94:
         { 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:) [@
Changed lines 99-110 from:
(: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.
to:
{$ \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.
Changed lines 105-114 from:
(: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.
to:
{$ \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.
Changed lines 54-55 from:
will create the system @@x(t+1) = A x(t) + f@@.
to:
will create the autonomous affine system {$ x(t+1) = A x(t) + f$}.
Changed lines 60-69 from:
(: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.
to:

{$ \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.
Changed lines 40-44 from:
(: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.
to:

{$ \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.
Added lines 13-18:

{$ \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:
Changed lines 20-21 from:
x(t+Ts) = A x(t) + B u(t)
   y(t) = C x(t) + D u(t)
to:
sys = LTISystem('A', A, 'B', B, 'C', C, 'D', D, 'Ts', Ts)
Changed lines 22-24 from:
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
:
to:

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
:
Changed line 27 from:
sys = LTISystem('A', A, 'B', B, 'C', C, 'D', D, 'Ts', Ts)
to:
sys = LTISystem('A', A, 'B', B)
Changed lines 30-37 from:
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
to:
Similarly, to define an autonomous system {$ x(t+\Delta t) = A x(t)$}, {$y(t) = C x(t)$}, just call
May 23, 2013, at 08:16 PM by Michal Kvasnica -
Added line 9:
[[#Linear-systems]]
Added line 37:
[[#Affine-systems]]
Added line 135:
[[#Mixed-Logical-Dynamical-MLD-systems]]
May 23, 2013, at 08:16 PM by Michal Kvasnica -
Added line 56:
[[#Piecewise-Affine-PWA-systems]]
Changed line 148 from:
@]
to:
@]
May 23, 2013, at 08:14 PM by Michal Kvasnica -
Changed lines 4-7 from:
# [[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.
to:
# [[#Linear-systems| Linear systems]], represented by the @@LTISystem@@ class,
# [[#Affine-systems| Affine systems]], represented by the @@LTISystem@@ class,
# [[#Piecewise-Affine-PWA-systems| Piecewise affine (PWA) systems]], represented by the @@PWASystem@@ class,
# [[#Mixed-Logical-Dynamical-MLD-systems| Mixed Logical Dynamical (MLD) systems]], represented by the @@MLDSystem@@ class.
May 23, 2013, at 08:13 PM by Michal Kvasnica -
Changed lines 4-8 from:
# [[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.
to:
# [[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.
Changed lines 16-18 from:
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:
to:
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:
Changed lines 23-24 from:
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.
to:
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.
Changed lines 30-31 from:
Similarly, to define an autonomous system @x(t+Ts) = A x(t)@, @y(t) = C x(t)@, just call
to:
Similarly, to define an autonomous system @@x(t+Ts) = A x(t)@@, @@y(t) = C x(t)@@, just call
Changed lines 43-45 from:
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:
to:
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:
Changed line 50 from:
Similarly as above, any parameter (except of the @A@ matrix) can be omitted, e.g.:
to:
Similarly as above, any parameter (except of the @@A@@ matrix) can be omitted, e.g.:
Changed lines 54-55 from:
will create the system @x(t+1) = A x(t) + f@.
to:
will create the system @@x(t+1) = A x(t) + f@@.
Changed lines 68-69 from:
where @R_1@, ..., @R_M@ are polyhedra and @M@ denotes the number of _modes_ of the PWA system.
to:
where @@R_1@@, ..., @@R_M@@ are polyhedra and @@M@@ denotes the number of _modes_ of the PWA system.
Changed lines 82-84 from:
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:
to:
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:
Changed lines 89-90 from:
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
to:
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
Changed lines 105-106 from:
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.,
to:
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.,
Changed lines 117-118 from:
Here, the only difference to the above procedure is that you should use @sys.setDomain('x', R)@ when defining the individual affine models.
to:
Here, the only difference to the above procedure is that you should use @@sys.setDomain('x', R)@@ when defining the individual affine models.
Changed lines 130-131 from:
This is achieved by calling @sys.setDomain('u', R)@ when defining the domain of each local affine model.
to:
This is achieved by calling @@sys.setDomain('u', R)@@ when defining the domain of each local affine model.
Changed line 136 from:
To generate an MLD form from a model described by its HYSDEL file, use the @MLDSystem@ constructor:
to:
To generate an MLD form from a model described by its HYSDEL file, use the @@MLDSystem@@ constructor:
Deleted lines 147-148:

Note that the HYSDEL compiler is already included in the MPT3 distribution package.
May 23, 2013, at 08:09 PM by Michal Kvasnica -
Added lines 1-149:
! 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.