diff --git a/.nojekyll b/.nojekyll index 757759f..e8a2b5e 100644 --- a/.nojekyll +++ b/.nojekyll @@ -1 +1 @@ -f8ddded3 \ No newline at end of file +15793d7e \ No newline at end of file diff --git a/classes_PWA.html b/classes_PWA.html index f9d3807..d67fec1 100644 --- a/classes_PWA.html +++ b/classes_PWA.html @@ -2,7 +2,7 @@ - + @@ -37,10 +37,10 @@ - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Software

+
+ + + +
+ + + + +
+ + + +
+ + +

Reset systems, switched systems, and piecewise affine (PWA) systems can all be viewed as special classes of hybrid systems, and as such can be modelled and simulated using software for hybrid systems (or even general purpose modelling and simulation software).

+

However, there are also some dedicated software tools/packages/libraries for PWA systems:

+ +

Although some more free and open-source software packages for PWA systems can be found on the internet, none of them (at as far as we know) is actively developed or at least maintained anymore:

+ +

Overall, besides the MPT toolbox that is still being actively developed (by our colleagues at STU Bratislava), not much is currently available within the open-source software domain… :-(

+ + + + + Back to top

References

+
+Johansson, Mikael K.-J. 2003. Piecewise Linear Control Systems: A Computational Approach. Lecture Notes in Control and Information Sciences. Berlin, Heidelberg: Springer. https://doi.org/10.1007/3-540-36801-9. +
+
+Rodrigues, Luis, Behzad Samadi, and Miad Moarref. 2019. Piecewise Affine Control: Continuous-Time, Sampled-Data, and Networked Systems. Advances in Design and Control. Philadelphia: Society for Industrial and Applied Mathematics. https://doi.org/10.1137/1.9781611975901. +
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/classes_software.html b/classes_software.html index 23a5c56..811e9f5 100644 --- a/classes_software.html +++ b/classes_software.html @@ -2,7 +2,7 @@ - + @@ -57,10 +57,10 @@ - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Literature

+
+ + + +
+ + + + +
+ + + +
+ + +

Concise (short and yet sufficient for our purposes) introduction to (linear) complementarity problems and systems is in [1]. Besides describing the idea of complementarity in dynamical systems, it also shows how it is related to other modeling frameworks for hybrid dynamical systems. More detailed and yet very accessible introduction is in the thesis [2]. Condensed treatment is in the papers [3] and [4].

+

A readable introduction to the Extended Linear Complementarity Problem is in [5] (it is also freely available as a technical report).

+

The topics of complementarity constraints in dynamical systems and optimization is still being actively researched. A recent publication on QP optimization with complementarity constraints (LCQP) is [6].

+

Numerical methods for nonsmooth dynamical systems that are based on complementary constraints (and implemented in SICONOS software) are comprehensively presented in [7].

+ + + + + Back to top

References

+
+
[1]
W. P. M. H. Heemels, B. De Schutter, and A. Bemporad, “Equivalence of hybrid dynamical models,” Automatica, vol. 37, no. 7, pp. 1085–1091, Jul. 2001, doi: 10.1016/S0005-1098(01)00059-0.
+
+
+
[2]
M. Heemels, Linear complementarity systems: a study in hybrid dynamics,” PhD thesis, Technische Universiteit Eindhoven, Eindhoven, NL, 1999. Available: https://heemels.tue.nl/content/papers/Hee_TUE99a.pdf
+
+
+
[3]
W. P. M. H. Heemels, J. M. Schumacher, and S. Weiland, “Linear Complementarity Systems,” SIAM Journal on Applied Mathematics, vol. 60, no. 4, pp. 1234–1269, Jan. 2000, doi: 10.1137/S0036139997325199.
+
+
+
[4]
A. J. van der Schaft and J. M. Schumacher, “Complementarity modeling of hybrid systems,” IEEE Transactions on Automatic Control, vol. 43, no. 4, pp. 483–490, Apr. 1998, doi: 10.1109/9.664151.
+
+
+
[5]
B. De Schutter and B. De Moor, “The Extended Linear Complementarity Problem and the Modeling and Analysis of Hybrid Systems,” in Hybrid Systems V, P. Antsaklis, M. Lemmon, W. Kohn, A. Nerode, and S. Sastry, Eds., in Lecture Notes in Computer Science. Berlin, Heidelberg: Springer, 1999, pp. 70–85. doi: 10.1007/3-540-49163-5_4.
+
+
+
[6]
J. Hall, A. Nurkanovic, F. Messerer, and M. Diehl, LCQPowA Solver for Linear Complementarity Quadratic Programs.” arXiv, Nov. 2022. Accessed: Dec. 03, 2022. [Online]. Available: http://arxiv.org/abs/2211.16341
+
+
+
[7]
V. Acary and B. Brogliato, Numerical Methods for Nonsmooth Dynamical Systems: Applications in Mechanics and Electronics. in Lecture Notes in Applied and Computational Mechanics, no. 35. Berlin Heidelberg: Springer, 2008. Available: https://doi.org/10.1007/978-3-540-75392-6
+
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/complementarity_references.html b/complementarity_references.html index 134a94e..99ac8cc 100644 --- a/complementarity_references.html +++ b/complementarity_references.html @@ -2,7 +2,7 @@ - + @@ -57,10 +57,10 @@ - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

State automata

+
+ + + +
+ + + + +
+ + + +
+ + +

Having just discussed the concept of a discrete-event system, we now introduce the most popular modeling framework for such systems: a state automaton, or just an automaton (plural automata). It is also known as a state machine or a (discrete) transition system.

+
+

Definition 1 (Automaton) Automaton is a tuple \boxed{ +G = \{\mathcal X,\mathcal X_0,\mathcal E,\mathcal F\},} +
+where

+
    +
  • \mathcal X is the set of states (also called modes or locations).
  • +
  • \mathcal X_0 \subseteq \mathcal X is the set of initial states.
  • +
  • \mathcal E is the set of events (also actions, transition labels, symbols). It is also called alphabet.
  • +
  • \mathcal F\subseteq \mathcal X \times \mathcal E \times \mathcal X is the set of transitions. In the deterministic case it can also be narrowed down to a transition function f:\mathcal X \times \mathcal E \rightarrow \mathcal X. Note that f is then is a partial function, it is not necessarily defined for all combinations of states and events. Sometimes f is used even for multivalued functions: f:\mathcal X \times \mathcal E \rightarrow 2^\mathcal{X}, where 2^\mathcal{X} is a power set (a set of all subsets of X).
  • +
+
+
+
+
+ +
+
+Some comments on the notation +
+
+
+
    +
  • The set of states is often denoted by \mathcal Q to spare the letter \mathcal X for the continuous valued state space of hybrid systems.
  • +
  • The set of events is often denoted by \mathcal A to spare the letter \mathcal E for the set of transitions (edges in the corresponding graph), because F and f may also need to be spared for the continuous-valued transitions. But then the letter \mathcal A actually fits this purpose nicely because the event set is also called the alphabet.
  • +
+
+
+
+

Marked states

+

In some literature, the definition of the automaton also includes a set \mathcal X_\mathrm{m} \subseteq \mathcal X of marked or accepting states, in which case the definition of an automaton now includes three (sub)sets of states: \mathcal X, \mathcal X_0 and \mathcal X_\mathrm{m}. \boxed{ +G = \{\mathcal X,\mathcal X_0,\mathcal E,\mathcal F, \mathcal X_\mathrm{m}\}.} +

+

The marked states are just some states with special roles in the system. Namely, these are the states into which the system should be controlled. I do not particularly like this idea of mixing the model of the system with the requirements, but some part of the community likes it this way.

+
+
+

Automaton as a (di)graph (also a state transition diagram)

+

So far the definition of an automaton was not particularly visual. This can be changes by viewing the automaton as a directed graph (digraph) with. These are the basic rules

+
    +
  • State is represented as a node of the graph.
  • +
  • Transition from a given state to another state is represented as an edge connecting the two nodes.
  • +
  • Events (actions) are the labels attached to the edges. It is not necessary that each edge has its unique label.
  • +
+
+

Example 1 (Automaton as a digraph) Consider an automaton defined by these sets: \mathcal X = \{x_1,x_2,x_3\}, \mathcal X_0 = \{x_1\}, \mathcal E = \{e_1,e_2,e_3\}, \mathcal F = \{(x_1,e_1,x_2),(x_2,e_2,x_1),(x_1,e_3,x_3),(x_2,e_2,x_3)\}.

+

The corresponding digraph is in Fig 1.

+
+
+
+
+
+
+ + +G + + +init +init + + + +x₁ + +x₁ + + + +init->x₁ + + + + + +x₂ + +x₂ + + + +x₁->x₂ + + +e₁ + + + +x₃ + +x₃ + + + +x₁->x₃ + + +e₂ + + + +x₂->x₁ + + +e₂ + + + +x₂->x₃ + + +e₃ + + + +
+
+
+Figure 1: An example automaton as a digraph +
+
+
+
+
+
+

We may also encounter the following term.

+
+

Definition 2 (Active event function and set) Active event function (actually a multivalued function) \Gamma: \mathcal X \rightarrow 2^\mathcal{E} assigns to each state a set of active events. Active event set \Gamma(x) is the set of active events in a particular state x.

+
+
+
+

Finite state automaton (FSA)

+

This may be regarded as a rather superfluous definition – a finite state automaton (FSA) is a state automaton with a finite set \mathcal X of states. It is also known as a finite state machine (FSM).

+
+
+

Execution of an automaton

+
    +
  • x_1\xrightarrow{e_1} x_2\xrightarrow{e_2} x_1 \xrightarrow{e_1} x_2 \xrightarrow{e_4} x_3\ldots
  • +
  • Sometimes also written as x_1,e_1,x_2,e_2,\ldots
  • +
+
+
+
+
+ +
+
+Notational confusion +
+
+
+

Here x_k for some k is the name of a particular state. It is not the name of a (yet to be introduced) state variable; In fact, it can be viewed as its value (also valuation).

+
+
+
    +
  • Some authors strictly distinguish between the state variable and the state (variable valuation), +
      +
    • similarly as in probability theory random variable X vs its value x, as in F(x) = P(X\leq x);
    • +
  • +
  • some do not, but then it may lead to confusion;
  • +
  • yet some others avoid the problem by not introducing state variables and only working with enumerated states.
  • +
+
+
+
+
+ +
+
+Notational confusion 2 +
+
+
+

Even worse, it is also tempting to interpret the lower index k as (discrete) time, but nope, in the previous k is not the time index.

+

Again, some authors do not distinguish…

+
+
+
+
+

Path of an automaton

+

Corresponding to the execution

+

x_1\xrightarrow{e_1} x_2\xrightarrow{e_2} x_1 \xrightarrow{e_1} x_2 \xrightarrow{e_4} x_3\ldots

+

the path is just the sequence of visited states:

+

x_1,x_2,x_1,x_2,x_3,\ldots

+
+

In continuous-valued dynamical systems, we have a state trajectory, but then time stamps are attached to each visited state.

+
+
+

Example 2 (Beverage vending machine)  

+
+
+
+
+
+
+ + +G + + +init +init + + + +waiting + +waiting + + + +init->waiting + + + + + +swiped + +swiped + + + +waiting->swiped + + +swipe card + + + +swiped->waiting + + +reject payment + + + +paid + +paid + + + +swiped->paid + + +accept payment + + + +coke_dispensed + +coke_dispensed + + + +paid->coke_dispensed + + +choose coke + + + +fanta_dispensed + +fanta_dispensed + + + +paid->fanta_dispensed + + +choose fanta + + + +coke_dispensed->waiting + + +take coke + + + +fanta_dispensed->waiting + + +take fanta + + + +
+
+
+Figure 2: Example of a digraph representation of the automaton for a beverage vending machine +
+
+
+
+
+
    +
  • State sequence (path): waiting, swiped, paid, coke_dispensed, waiting

  • +
  • Events sequence: swipe card, accept payment, choose coke, take coke

  • +
  • Indeed, the two states coke_dispensed and fanta_dispensed can be merged into just beverage_dispensed.

  • +
  • How about other paths? Longer? Shorter?

  • +
+
+
+
+
+
+
+ + +G + + +init +init + + + +waiting + + +waiting + + + +init->waiting + + + + + +swiped + +swiped + + + +waiting->swiped + + +swipe card + + + +swiped->waiting + + +reject payment + + + +paid + +paid + + + +swiped->paid + + +accept payment + + + +coke_dispensed + +coke_dispensed + + + +paid->coke_dispensed + + +choose coke + + + +fanta_dispensed + +fanta_dispensed + + + +paid->fanta_dispensed + + +choose fanta + + + +coke_dispensed->waiting + + +take coke + + + +fanta_dispensed->waiting + + +take fanta + + + +
+
+
+Figure 3: Example of a digraph representation of the automaton for a beverage vending machine with a marked state +
+
+
+
+
+

The waiting state can be marked (is accepting).

+
+
+

Example 3 (Longitudinal control of a ground vehicle)  

+
+
+
+
+
+
+ + +G + + +init +init + + + +still + +still + + + +init->still + + + + + +accelerating + +accelerating + + + +still->accelerating + + +push acc + + + +cruising + +cruising + + + +accelerating->cruising + + +cruise ON + + + +coasting + +coasting + + + +accelerating->coasting + + +rel acc + + + +cruising->accelerating + + +push acc + + + +cruising->coasting + + +rel acc + + + +braking + +braking + + + +cruising->braking + + +push brake + + + +coasting->braking + + +push brake + + + +braking->still + + +zero vel + + + +braking->cruising + + +cruise ON + + + +braking->coasting + + +rel brake + + + +
+
+
+Figure 4: Example of a digraph representation of the automaton for a longitudinal control of a ground vehicle +
+
+
+
+
+
+
+
    +
  • By cruise on I mean switching on some kind of a cruise control system, which keeps the velocity constant.
  • +
  • It turns out the optimal control strategy for trains (under some circumstances).
  • +
  • Note that some of the events are indeed actions started by the driver, but some are just coming from the physics of the vehicle (transition from braking to zero velocity).
  • +
+
+
+

Example 4 (Corridor switch)  

+
+
+
+
+
+
+ + +G + + +init +init + + + +OFF + +OFF + + + +init->OFF + + + + + +ON + +ON + + + +OFF->ON + + +switch₁,switch₂ + + + +ON->OFF + + +switch₁,switch₂ + + + +
+
+
+Figure 5: Example of a digraph representation of the automaton for a corridor switch +
+
+
+
+
+

Two events associated with one transitions can be seen as two transitions, each with a single event, both sharing the starting and ending states.

+
+
+

Example 5 (JK flip-flop) We now consider the classical JK flip-flop logical circuit. It symbol is in Fig 7 and the truth table follows. Our goal is to represent its functionality using a state automaton.

+
+
+
+ +
+
+Figure 6: Symbol for a JK flip-flop logical circuit +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
JKQ_kQ_{k+1}Description
0000No change
0011No change
0100Reset
0110Reset
1001Set
1011Set
1101Toggle
1110Toggle
+
+
+
+
+
+
+ + +G + + +init +init + + + +Low + +Low + + + +init->Low + + + + + +Low->Low + + +¬J ∧ ¬K ∧ clk + + + +High + +High + + + +Low->High + + +J ∧ clk + + + +High->Low + + +K ∧ clk + + + +High->High + + +¬J ∧ ¬K ∧ clk + + + +
+
+
+Figure 7: JK flip-flop as an automaton +
+
+
+
+
+
+
+

Example 6 (Double intensity switching)  

+
+
+
+
+
+
+ + +G + + +init +init + + + +OFF + +OFF + + + +init->OFF + + + + + +ON + +ON + + + +OFF->ON + + +push + + + +ON->OFF + + +push + + + +ON2 + +ON2 + + + +ON->ON2 + + +push + + + +ON2->OFF + + +push + + + +
+
+
+Figure 8: Example of a digraph representation of the automaton for double intensity switching +
+
+
+
+
+

Obviously we need to introduce time into the automaton…

+
+
+
+

State as the value of a state variable

+

Definition of the state space by enumeration (such as \mathcal X = \{0,1,2,3,4,5\}) doesn’t scale well. As an alternative, a state can be characterized by the value (sometimes also valuation) of a state variable. A state variable is then given by

+
    +
  • the name (for example, x),
  • +
  • the “type” (boolean, integer, vector, …).
  • +
+
+

Example 7 (Examples of state variables)  

+
    +
  • Corridor switch: x \in \{\mathrm{false},\mathrm{true}\} (possibly also \{0,1\}).
  • +
  • Double intensity switching: +
      +
    • x \in \{0,1,2\} \subset \mathbb Z,
    • +
    • or \bm x = \begin{bmatrix}x_1\\ x_2 \end{bmatrix}, where x_1,x_2 \in \{0,1\}.
    • +
  • +
+
+
+
+

State (transition) equation

+

Denoting a new state after a transition as x^+, the state equation reads \boxed{x^+ = f(x,e)}

+

Upon introduction of discrete-time (index) k, it can also be rewritten as x_{k+1} = f(x_k,e_k) or also x[k+1] = f(x[k],e[k]).

+
+
+
+ +
+
+Note +
+
+
+
    +
  • The function f can be defined by a computer code rather than a clean mathematical formula.
  • +
  • The discrete-time index of the event is sometimes considered shifted, that is x_{k+1} = f(x_k,e_{k+1}). You should be aware of this.
  • +
+
+
+
+
+

Extensions

+

The concept of an automaton can be extended in several ways. In particular, the following two extensions introduce the concept of an output to an automaton.

+
+

Moore machine

+

One extension of an automaton with outputs is Moore machine. The outputs assigned to the states by the output function y = g(x).

+

The output is produced (emitted) when the (new) state is entered.

+

Note, in particular, that the output does not depend on the input. This has a major advantage when a feedback loop is closed around this system, since no algebraic loop is created.

+

Graphically, we make a conventions that outputs are the labels of the states.

+
+

Example 8 (Moore machine) The following automaton has just three states, but just two outputs (FLOW and NO FLOW).

+
+
+
+
+
+
+ + +G + + +init +init + + + +closed + +NO FLOW +Valve +closed + + + +init->closed + + + + + +partial + +FLOW +Valve +partially +open + + + +closed->partial + + +open valve one turn + + + +partial->closed + + +close valve one turn + + + +full + +FLOW +Valve +fully open + + + +partial->full + + +open valve one turn + + + +full->closed + + +emergency shut off + + + +full->partial + + +close valve one turn + + + +
+
+
+Figure 9: Example of a digraph representation of the Moore machine for a valve control +
+
+
+
+
+
+
+
+

Mealy machine

+

Mealy machine is another extension of an automaton. Here the outputs are associated with the transitions rather than the states.

+

Since the events already associated with the states can be viewed as the inputs, we now have input/output transition labels. The transition label e_\mathrm{i}/e_\mathrm{o} on the transion from x_1 to x_2 reads as “the input event e_\mathrm{i} at state x_1 activates the transition to x_2, which outputs the event e_\mathrm{o}” and can be written as x_1\xrightarrow{e_\mathrm{i}/e_\mathrm{o}} x_2.

+

It can be viewed as if the output function also considers the input and not only the state y = e_\mathrm{o} = g(x,e_\mathrm{i}).

+

In contrast with the Moore machine, here the output is produced (emitted) during the transition (before the new state is entered).

+
+

Example 9 (Mealy machine) Coffee machine: coffee for 30 CZK, machine accepting 10 and 20 CZK coins, no change.

+
+
+
+
+
+
+ + +G + + +init +init + + + +0 + +No coin + + + +init->0 + + + + + +10 + +10 CZK + + + +0->10 + + +insert 10 CZK / no coffee + + + +20 + +20 CZK + + + +0->20 + + +insert 20 CZK / no coffee + + + +10->0 + + +insert 20 CZK / coffee + + + +10->20 + + +insert 10 CZK / no coffee + + + +20->0 + + +insert 10 CZK / coffee + + + +20->10 + + +insert 20 CZK / coffee + + + +
+
+
+Figure 10: Example of a digraph representation of the Mealy machine for a coffee machine +
+
+
+
+
+
+
+

Example 10 (Reformulate the previous example as a Moore machine) Two more states wrt Mealy

+
+
+
+
+
+
+ + +G + + +init +init + + + +0 + +NO COFFEE +No +coin + + + +init->0 + + + + + +10 + +NO COFFEE +10 +CZK + + + +0->10 + + +insert 10 CZK + + + +20 + +NO COFFEE +20 +CZK + + + +0->20 + + +insert 20 CZK + + + +10->20 + + +insert 10 CZK + + + +30 + +COFFEE +10+20 +CZK + + + +10->30 + + +insert 20 CZK + + + +20->30 + + +insert 10 CZK + + + +40 + +COFFEE +20+20 +CZK + + + +20->40 + + +insert 20 CZK + + + +30->0 + + + + + +30->10 + + +insert 10 CZK + + + +30->20 + + +insert 20 CZK + + + +40->10 + + + + + +40->20 + + +insert 10 CZK + + + +40->30 + + +insert 20 CZK + + + +
+
+
+Figure 11: Example of a digraph representation of the Moore machine for a coffee machine +
+
+
+
+
+
+
+
+
+ +
+
+Note +
+
+
+

There are transitions from 30 and 40 back to 0 that are not labelled by any event. This does not seem to follow the general rule that transitions are always triggered by events. Not what? It can be resolved upon introducing time as the timeout transitions.

+
+
+
+

Example 11 (Dijkstra’s token passing) The motivation for this example is to show that it is perhaps not always productive to insist on visual description of the automaton using a graph. The four components of our formal definition of an automaton are just enough, and they translate directly to a code.

+

The example comes from the field of distributed computing systems. It considers several computers that are connected in ring topology, and the communication is just one-directional as Fig 12 shows. The task is to use the communication to determine in – a distributed way – which of the computers carries a (single) token at a given time. And to realize passing of the token to a neighbour. We assume a synchronous case, in which all the computers are sending simultaneously, say, with some fixed sending period.

+
+
+
+
+
+
+ + +G + + +0 + +0 + + + +1 + +1 + + + +0->1 + + + + + +2 + +2 + + + +1->2 + + + + + +3 + +3 + + + +2->3 + + + + + +3->0 + + + + + +
+
+
+Figure 12: Example of a ring topology for Dijkstra’s token passing in a distributed system +
+
+
+
+
+

One popular method for this is called Dijkstra’s token passing. Each computer keeps a single integer value as its state variable. And it forwards this integer value to the neighbour (in the clockwise direction in our setting). Upon receiving the value from the other neighbour (in the counter-clockwise direction), it updates its own value according to the rule displayed in the code below. At every clock tick, the state vector (composed of the individual state variables) is updated according to the function update!() in the code. Based on the value of the state vector, an output is computed, which decodes the informovation about the location of the token from the state vector. Again, the details are in the output() function.

+
+
+Show the code +
struct DijkstraTokenRing
+    number_of_nodes::Int64
+    max_value_of_state_variable::Int64
+    state_vector::Vector{Int64}
+end
+
+function update!(dtr::DijkstraTokenRing)                        
+    n = dtr.number_of_nodes
+    k = dtr.max_value_of_state_variable
+    x = dtr.state_vector
+    xnext = copy(x)
+    for i in eachindex(x)   # Mind the +1 shift. x[2] corresponds to x₁ in the literature.
+        if i == 1                                              
+            xnext[i] = (x[i] == x[n]) ? mod(x[i] + 1,k) : x[i]  # Increment if the left neighbour is identical.
+        else                                                    
+            xnext[i] = (x[i] != x[i-1]) ? x[i-1] : x[i]         # Update by the differing left neighbour.
+        end
+    end
+    dtr.state_vector .= xnext                                              
+end
+
+function output(dtr::DijkstraTokenRing)     # Token = 1, no token = 0 at the given position. 
+    x = dtr.state_vector
+    y = similar(x)
+    y[1] = iszero(x[1]-x[end])
+    y[2:end] .= .!iszero.(diff(x))
+    return y
+end
+
+
+
output (generic function with 1 method)
+
+
+

We now rund the code for a given number of computers and some initial state vector that does not necessarily comply with the requirement that there is only one token in the ring.

+
+
+Show the code +
n = 4                           # Concrete number of nodes.
+k = n                           # Concrete max value of a state variable (>= n).
+@show x_initial = rand(0:k,n)   # Initial state vector, not necessarily acceptable (>1 token in the ring).
+dtr = DijkstraTokenRing(n,k,x_initial)
+@show output(dtr)               # Show where the token is (are).
+
+@show update!(dtr), output(dtr) # Perform the update, show the state vector and show where the token is.
+@show update!(dtr), output(dtr) # Repeat a few times to see the stabilization.    
+@show update!(dtr), output(dtr)
+@show update!(dtr), output(dtr)
+@show update!(dtr), output(dtr)
+
+
+
x_initial = rand(0:k, n) = [1, 0, 2, 3]
+output(dtr) = [0, 1, 1, 1]
+(update!(dtr), output(dtr)) = ([1, 1, 0, 2], [0, 0, 1, 1])
+(update!(dtr), output(dtr)) = ([1, 1, 1, 0], [0, 0, 0, 1])
+(update!(dtr), output(dtr)) = ([1, 1, 1, 1], [1, 0, 0, 0])
+(update!(dtr), output(dtr)) = ([2, 1, 1, 1], [0, 1, 0, 0])
+(update!(dtr), output(dtr)) = ([2, 2, 1, 1], [0, 0, 1, 0])
+
+
+
([2, 2, 1, 1], [0, 0, 1, 0])
+
+
+

We can see that although initially the there can be more tokens, after a few iterations the algorithm achieves the goal of having just one token in the ring.

+
+
+
+

Extended-state automaton

+

Yet another extension of an automaton is the extended-state automaton. And indeed, the hyphen is there on purpose as we extend the state space.

+

In particular, we augment the state variable(s) that define the states/modes/locations (the nodes in the graph) by additional (typed) state variables: Int, Enum, Bool, …

+

Transitions from one mode to another are then guarded by conditions on theses new extra state variables.

+

Besides being guarded by a guard condition, a given transition can also be labelled by a reset function that resets the extended-state variables.

+
+

Example 12 (Counting up to 10) In this example, there are two modes (on and off), which can be captured by a single binary state variable, say x. But then there is an additional integer variable k, and the two variables together characterize the extended state.

+
+
+
+
+
+
+ + +G + + +init +init + + + +OFF + +OFF + + + +init->OFF + + +int k=0 + + + +ON + +ON + + + +OFF->ON + + +press + + + +ON->OFF + + +(press ⋁ k ≥ 10); k=0 + + + +ON->ON + + +(press ∧ k < 10); k=k+1 + + + +
+
+
+Figure 13: Example of a digraph representation of the extended-state automaton for counting up to ten +
+
+
+
+
+
+
+
+
+

Composing automata

+

Any practically useful modelling framework should support decomposition of a large system into smaller subsystems. These should then be able to communicate/synchronize with each other. In automata such synchronization can be realized by sending (or generating) and receiving (or accepting) events. A common choice of symbols for the two is !,?, as illustrated in the following example. But these symbols are just one possible convention, and any other symbols can be used.

+
+

Example 13 (Composing automata)  

+
+
+
+
+
+
+ + +G + + +init +init + + + +1 + +1 + + + +init->1 + + + + + +2 + +2 + + + +1->2 + + +press? + + + +3 + +3 + + + +3->3 + + +press! + + + +
+
+
+Figure 14: Example illustrating how two automata can be synchronized by sending and receiving events +
+
+
+
+
+
+
+
+

Languages and automata

+

When studying automata, we often encounter the concept of a language. Indeed, the concept of an automaton is heavily used in the formal laguage theory. Although in our course we are not going to refer to these results, some resources we recommend for our courses do, and so it is useful to understand how automata and languages are related.

+

First, we extend the definition of a transition function in that it accepts the current state and not just a single event but a sequence of events, that is

+

+f: \mathcal X \times \mathcal E^\ast \rightarrow \mathcal X, + where \mathcal E^\ast stands for the set of all possible sequences of events.

+

Language generated by the automaton is +\mathcal L(\mathcal G) = \{s\in\mathcal E^\ast \mid f(x_0,s) \;\text{is defined}\} +

+

Language marked by the automaton (the automaton is accepting or recognizing that language) +\mathcal L_\mathrm{m}(\mathcal G) = \{s\in\mathcal L(\mathcal G) \mid f(x_0,s) \in \mathcal{X}_\mathrm{m}\} +

+
+

Example 14 (Language accepted by automaton) +\mathcal{E} = \{a,b\}, \mathcal{L} = \{a,aa,ba,aaa,aba,baa,bba,\ldots\} +

+
+
+
+
+
+
+ + +G + + +init +init + + + +0 + +0 + + + +init->0 + + + + + +1 + + +1 + + + +1->1 + + +a + + + +1->0 + + +b + + + +0->1 + + +a + + + +0->0 + + +b + + + +
+
+
+Figure 15: Example of an automaton generating the language \mathcal{L} = \{a,aa,ba,aaa,aba,baa,bba,\ldots\} +
+
+
+
+
+

What if we remove the self loop at state 0? The automaton then accepts languages starting with a and with b being the last event or immediately followed by a.

+
+
+

What is the language view of automata good for?

+
    +
  • Definitions, analysis, synthesis.
  • +
  • We then need language concepts such as +
      +
    • concatenation of strings: \quad c = ab
    • +
    • empty string \varepsilon: \quad\varepsilon a = a \varepsilon = a
    • +
    • prefix, suffix
    • +
    • prefix closure \bar{\mathcal{L}} (of the language \mathcal L)
    • +
    • +
  • +
+
+
+
+

Blocking

+

An important concept in automata is blocking. A state is blocking if there is no transition out of it. An example follows.

+
+

Example 15 (Blocking states) In the automaton in Fig 16, state 2 is blocking. It is a deadlock state. States 3 and 4 are livelock states.

+
+
+
+
+
+
+ + +G + + +init +init + + + +0 + +0 + + + +init->0 + + + + + +2 + + +2 + + + +2->0 + + +g + + + +1 + +1 + + + +0->1 + + +a + + + +1->2 + + +b + + + +5 + +5 + + + +1->5 + + +g + + + +3 + +3 + + + +1->3 + + +a + + + +4 + +4 + + + +3->4 + + +b + + + +4->3 + + +a + + + +4->4 + + +g + + + +
+
+
+Figure 16: Example of an automaton with blocking states +
+
+
+
+
+

Language characterization: \bar{\mathcal{L}}_\mathrm{m}(\mathcal G) \sub \mathcal L(\mathcal G).

+
+
+
+

Queueing systems

+

Queueing systems are a particular and very useful class of discrete-event systems. They consist of these three components:

+
    +
  • entities (also customers, jobs, tasks, requests, etc.)
  • +
  • resources (also servers, processors, etc.): customers are waiting for them
  • +
  • queues (also buffers): where waiting is done
  • +
+

A common graphical representation that contains all these three compoments is in Fig 17.

+
+
+
+ +
+
+Figure 17: Queueing system +
+
+
+
+

Examples of queueing systems

+
    +
  • entities: people waiting for service in a bank or at a bust stop
  • +
  • resources: people (again) in a bank at the counter
  • +
  • queues: bank lobbies, bus stops, warehouses, …
  • +
+
+
+
+ +
+
+Note +
+
+
+

What are other examples?

+
    +
  • entities: packets, …
  • +
  • resources: processor, computer periphery, router, …
  • +
  • queues: …
  • +
+
+
+
+
+

Why shall we study queueing systems?

+
    +
  • Resources are not unlimited
  • +
  • Tradeoff needed between customer satisfaction and fair resources allocation
  • +
+
+
+

Networks of queueing systems

+

Queueing systems can be interconnected into networks.

+
+
+
+ +
+
+Figure 18: Example of a network of queueing systems +
+
+
+
+
+

Queueing systems as automata

+

The reason why we mentioned queueing systems in this part of our course is that they can be modelled as automata. And we already know that in order to define and automaton, we must characterize the key components defining the automaton – three in this case:

+
    +
  • events: \mathcal E = \{\text{arrival},\text{departure}\};

  • +
  • states: number of customers in the queue +\mathcal X = \{0,1,2,3,\ldots\}, \quad \mathcal X_0 = \{0\}, +

  • +
+
+
+
+ +
+
+Note +
+
+
+

Obviously this is not a finite state automation – unless the queue is bounded – and whether the queue’s length is bounded is a modelling assumption.

+
+
+
    +
  • state transition: +f(x,e) = +\begin{cases} +x+1, & \text{if}\; x\leq 0 \land e = \mathrm{arrival}\\ +x-1, & \text{if}\; x > 0 \land e = \mathrm{departure}. +\end{cases} +
  • +
+
+
+

Queueing system as an automaton

+
+
+
+ +
+
+Figure 19: Queueing system as an automaton +
+
+
+
+
+
+ +
+
+Note +
+
+
+

Note how the states correspond to the value of the state variable.

+
+
+
+

Example 16 (Example of a queueing system: jobs processing by a CPU)

+
+
+
+

Stochastic queueing systems

+

An important extension of the basic concept of a queueing system is the introduction of randomness. In particular, the arrivals can be modelled using random processes. Similarly, the departures given by the delays (the processing time) of the server can be modelled as random.

+

Obviously, the time needs to be included in the automaton, and so far we do not have it there. It is then high time to introduce it.

+
+
+
+

Timed automaton

+

So far, even if the automaton corresponded to a physical system (and did not just represent a generator of a language), the time was not included. The transitions were triggered by the events, but we did not specify the time at which the event occurred.

+

There are, however, many situations when it is useful or even crucial to incorporate time. We can then answer questions such as

+
    +
  • How many events of a certain type in a given interval?
  • +
  • Is the time interval between two events above a given threshold?
  • +
  • How long does the system spend in a given state?
  • +
  • +
+

There are several ways how to incorporate time into the automaton. We will follow the concept of a timed automaton with guards (introduced by Alur and Dill). Within their framework we have

+
    +
  • one or several resettable clocks: c_i,\, i=1,\ldots, k, driven by the ODE + \frac{\mathrm{d} c_i(t)}{\mathrm d t} = 1, \quad c_i(0) = 0; +
  • +
  • each transition labelled by the tripple {guard; event; reset}.
  • +
+
+
+
+ +
+
+Note +
+
+
+

Both satisfaction of the guard and arrival of the event constitute enabling conditions for the transition. They could be wrapped into a single compound condition.

+
+
+
+

Example 17 (Timed automaton with guards)  

+
+
+
+
+
+
+ + +G + + +init +init + + + +0 + +0 + + + +init->0 + + + + + +1 + +1 + + + +0->1 + + +-; msg; c₁ + + + +1->1 + + +c₁≥1; msg; c₁ + + + +2 + +2 + + + +1->2 + + +0<c₁<1; msg; c₁ + + + +3 + +3 + + + +2->3 + + +c₁<1; alarm; - + + + +
+
+
+Figure 20: Example of a timed automaton with guards +
+
+
+
+
+
+
+

Example 18 (Timed automaton with guards and invariant)  

+
+
+
+
+
+
+ + +G + + +init +init + + + +0 + +0 + + + +init->0 + + + + + +2 + +2 +c₁<1 + + + +3 + +3 + + + +2->3 + + +-; alarm; - + + + +1 + +1 + + + +0->1 + + +-; msg; c₁ + + + +1->2 + + +0<c₁<1; msg; c₁ + + + +1->1 + + +c₁≥1; msg; c₁ + + + +
+
+
+Figure 21: Example of a timed automaton with guards and invariant +
+
+
+
+
+
+
+

Invariant vs guard

+
    +
  • Invariant (of a location) gives an upper bound on the time the system can stay at the given location. It can leave earlier but not later.
  • +
  • Guard (of a given transition) gives an enabling condition on leaving the location through the given transition.
  • +
+
+

Example 19 (Several trains approaching a bridge) The example is taken from [1] and is included in the demos coming with the Uppaal tool.

+
+ + + +
+
+ + Back to top

References

+
+
[1]
G. Behrmann, A. David, and K. G. Larsen, “A Tutorial on Uppaal,” in Formal Methods for the Design of Real-Time Systems, M. Bernardo and F. Corradini, Eds., in Lecture Notes in Computer Science, no. 3185., Berlin, Heidelberg: Springer, 2004, pp. 200–236. doi: 10.1007/978-3-540-30080-9_7.
+
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/des_automata.html b/des_automata.html index e04a64f..b95a8f9 100644 --- a/des_automata.html +++ b/des_automata.html @@ -2,7 +2,7 @@ - + @@ -91,10 +91,10 @@ - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Hybrid automata

+
+ + + +
+ + + + +
+ + + +
+ + +

Well, here we are at last. After these three introductory topics on discrete-event systems, we’ll finally get into hybrid systems.

+

There are two frameworks for modelling hybrid systems:

+ +

Here we start with the former and save the latter for the next chapter/week.

+

First we consider an autonomous (=no external/control inputs) hybrid automaton – it is a tuple of sets and (set) mappings +\boxed{ +\mathcal{H} = \{\mathcal Q, \mathcal Q_0, \mathcal X, \mathcal X_0, f, \mathcal I, \mathcal E, \mathcal G, \mathcal R\},} + where

+ +
+
+
+ +
+
+Caution +
+
+
+

Strictly speaking, \mathcal{I} is a mapping and not a set. Only the mapping evaluated at a given location q, that is, \mathcal{I}(q), is a set.

+
+
+ +
+

Example 1 (Thermostat – the hello world example of a hybrid automaton) The thermostat is a device that turns some heater on or off (or sets some valve open or closed) based on the sensed temperature. The goal is to keep the temperature around, say, 18^\circ C.

+

Naturally, the discrete states (modes, locations) are on and off. Initially, the heater is off. We can identify the first two components of the hybrid automaton: \mathcal Q = \{\text{on}, \text{off}\}, \quad \mathcal Q_0 = \{\text{off}\}

+

The only continuous state variable is the temperature. The initial temperature not not quite certain, say it is known to be in the interval [5,10]. Two more components of the hybrid automaton follow: \mathcal X = \mathbb R, \quad \mathcal X_0 = \{x:x\in \mathcal X, 5\leq x\leq 10\}

+

In the two modes on and off, the evolution of the temperature can be modelled by two different ODEs. Either from first-principles modelling or from system identification (or preferrably from the combination of the two) we get the two differential equations, say: +f_\text{off}(x) = -0.1x,\quad f_\text{on}(x) = -0.1x + 5, + which gives another component for the hybrid automaton.

+

The control logic of the thermostat is captured by the \mathcal I and \mathcal G components of the hybrid automaton. Let’s determine them now. Obviously, if we just set 18 as the threshold, the heater would be switching on and off all the time. We need to introduce some hysteresis. Say, keeping the temperature within the interval (18 \pm 2)^\circ is acceptable. +\mathcal I(\text{off}) = \{x\mid x> 16\},\quad \mathcal I(\text{on}) = \{x\mid x< 20\}, +

+

+\mathcal G(\text{off},\text{on}) = \{x\mid x\leq 17\},\; \mathcal G(\text{on},\text{off}) = \{x\mid x\geq 19\}. +

+

Finally, \mathcal R (or r) is not specified as the x variable (the temperature) doesn’t jump. Well, it is specified implicitly as an identity mapping r(x)=x.

+

The graphical representation of the thermostat hybrid automaton is shown in Fig 1.

+
+
+
+ +
+
+Figure 1: Hybrid automaton for a thermostat +
+
+
+

Is this model deterministic? There are actually two reasons why it is not:

+
    +
  1. If we regard the characterization of the initial state (the temperature in this case) as a part of the model, which is the convention that we adhere to in our course, the model is nondeterministic.
  2. +
  3. Since the invariant for a given mode and the guard set for the only transition to the other model overlap, the response of the system is not uniquely determined. Consider the case when the system is in the off mode and the temperature is 16.5. The system can either stay in the off mode or switch to the on mode.
  4. +
+
+
+

Hybrid automaton with external events and control inputs

+

We now extend the hybrid automaton with two new components:

+
    +
  • a set \mathcal{A} of (external) events (also actions or symbols),
  • +
  • a set \mathcal{U} external continuous-valued inputs (control inputs or disturbances).
  • +
+

\boxed{ + \mathcal{H} = \{\mathcal Q, \mathcal Q_0, \mathcal X, \mathcal X_0, \mathcal I, \mathcal A, \mathcal U, f, \mathcal E, \mathcal G, \mathcal R\} ,} + where

+
    +
  • \mathcal A = \{a_1,a_2,\ldots, a_s\} is a set of events

    +
      +
    • The role identical as in a (finite) state automaton: an external event triggers an (enabled) transition from the current discrete state (mode, location) to another.
    • +
    • Unlike in pure discrete-event systems, here they are considered within a model that does recognize passing of time – each action must be “time-stamped”.
    • +
    • In simulations such timed event can be represented by an edge in the signal. In this regard, it might be tempting not to introduce it as a seperate entity, but it is useful to do so.
    • +
  • +
  • \mathcal U\in\mathbb R^m is a set of continuous-valued inputs

    +
      +
    • Real-valued functions of time.
    • +
    • Control inputs, disturbances, references, noises. In applications it will certainly be useful to distinghuish these roles, but here we keep just a single type of such an external variable, we do not have to distinguish.
    • +
  • +
+
+

Some modifications needed

+

Upon introduction of these two types of external inputs we must modify the components of the definition we provided earlier:

+
    +
  • f: \mathcal Q \times \mathcal X \times \mathcal U \rightarrow \mathbb R^n is a vector field that now depends not only on the location but also on the external (control) input, that is, at a given location we consider the state equation \dot x = f_q(x,u).

  • +
  • \mathcal E\subseteq \mathcal Q \times (\mathcal A) \times \mathcal Q is a set of transitions now possibly parameterized by the actions (as in classical automata).

  • +
  • \mathcal I : \mathcal Q \rightarrow 2^{\mathcal{X}\times \mathcal U} is a location invariant now augmented with a subset of the control input set. The necessary condition for staying in the given mode can be thus imposed not only on x but also on u.

  • +
  • \mathcal G: \mathcal E \rightarrow 2^{\mathcal{X}\times U} is a guard set now augmented with a subset of the control input set. The necessary condition for a given transition can be thus imposed not only on x but also on u.

  • +
  • \mathcal R: \mathcal E \times \mathcal X\times \mathcal U\rightarrow 2^{\mathcal X} is a (state) reset map that is now additionally parameterized by the control input.

  • +
+

If enabled, the transition can happen if one of the two things is satisfied:

+
    +
  • the continous state leaves the invariant set of the given location,
    +
  • +
  • an external event occurs.
  • +
+
+

Example 2 (Button-controlled LED)  

+
+
+
+ +
+
+Figure 2: Automaton for a button controlled LED +
+
+
+

+\mathcal{Q} = \{\mathrm{off}, \mathrm{dim}, \mathrm{bright}\},\quad \mathcal{Q}_0 = \{\mathrm{off}\} +

+

+\mathcal{X} = \mathbb{R}, \quad \mathcal{X}_0 = \{0\} +

+

+\mathcal{I(\mathrm{off})} = \mathcal{I(\mathrm{bright})} = \mathcal{I(\mathrm{dim})} = \{x\in\mathbb R \mid x \geq 0\} +

+

+f(x) = 1 +

+

+\mathcal{A} = \{\mathrm{press}\} +

+

+\begin{aligned} +\mathcal{E} &= \{(\mathrm{off},\mathrm{press},\mathrm{dim}),(\mathrm{dim},\mathrm{press},\mathrm{off}),\\ +&\qquad (\mathrm{dim},\mathrm{press},\mathrm{bright}),(\mathrm{bright},\mathrm{press},\mathrm{off})\} +\end{aligned} +

+

+\begin{aligned} +\mathcal{G}((\mathrm{off},\mathrm{press},\mathrm{dim})) &= \mathcal X \\ +\mathcal{G}((\mathrm{dim},\mathrm{press},\mathrm{off})) &= \{x \in \mathcal X \mid x>2\}\\ +\mathcal{G}((\mathrm{dim},\mathrm{press},\mathrm{bright})) &= \{x \in \mathcal X \mid x\leq 2\}\\ +\mathcal{G}((\mathrm{bright},\mathrm{press},\mathrm{off})) &= \mathcal X. +\end{aligned} +

+

+r((\mathrm{off},\mathrm{press},\mathrm{dim}),x) = 0, +

+
    +
  • that is, x^+ = r((\mathrm{off},\mathrm{press},\mathrm{dim}),x) = 0.
  • +
  • For all other transitions r((\cdot, \cdot, \cdot),x)=x, +
      +
    • that is, x^+ = x.
    • +
  • +
+
+
+

Example 3 (Water tank) We consider a water tank with one inflow and two outflows – one at the bottom, the other at some nonzero height h_\mathrm{m}. The water level h is the continuous state variable.

+
+
+
+ +
+
+Figure 3: Water tank example +
+
+
+

The model essentially expresses that the change in the volume is given by the difference between the inflow and the outflows. The outflows are proportional to the square root of the water level (Torricelli’s law) +\dot V = +\begin{cases} +Q_\mathrm{in} - Q_\mathrm{out,middle} - Q_\mathrm{out,bottom}, & h>h_\mathrm{m}\\ +Q_\mathrm{in} - Q_\mathrm{out,bottom}, & h\leq h_\mathrm{m} +\end{cases} +

+

Apparently things change when the water level crosses (in any direction) the height h_\mathrm{m}. This can be modelled using a hybrid automaton.

+
+
+
+ +
+
+Figure 4: Automaton for a water tank example +
+
+
+

One lesson to learn from this example is that the transition from one mode to another is not necessarily due to some computer-controlled switch. Instead, it is our modelling choice. It is an approximation that assumes negligible diameter of the middle pipe. But taking into the consideration the volume of the tank, it is probably a justifiable approximation.

+
+
+

Example 4 (Bouncing ball) We assume that a ball is falling from some initial nonzero height above the table. After hitting the table, it bounces back, loosing a portion of the energy (the deformation is not perfectly elastic).

+
+
+
+ +
+
+Figure 5: Bouncing ball example +
+
+
+

The state equation during the free fall is +\dot{\bm x} = \begin{bmatrix} x_2\\ -g\end{bmatrix}, \quad \bm x = \begin{bmatrix}10\\0\end{bmatrix}. +

+

But how can we model what happens during and after the collision? High-fidelity model would be complicated, involving partial differential equations to model the deformation of the ball and the table. These complexities can be avoided with a simpler model assuming that immediately after the collision the sign of the velocity abruptly (discontinuously) changes, and at the same time the ball also looses a portion of the energy.

+

When modelling this using a hybrid automaton, it turns out that we only need a single discrete state. The crucial feature of the model is then the nontrivial (non-identity) reset map. This is depicted in Fig 6.

+
+
+
+ +
+
+Figure 6: Hybrid automaton for a bouncing ball eaxample +
+
+
+

For completeness, here are the individual components of the hybrid automaton: +\mathcal{Q} = \{q\}, \; \mathcal{Q}_0 = \{q\} +

+

+\mathcal{X} = \mathbb R^2, \; \mathcal{X}_0 = \left\{\begin{bmatrix}10\\0\end{bmatrix}\right\} +

+

+\mathcal{I} = \{\mathbb R^2 \mid x_1 > 0 \lor (x_1 = 0 \land x_2 \geq 0)\} +

+

+f(\bm x) = \begin{bmatrix} x_2\\ -g\end{bmatrix} +

+

+\mathcal{E} = \{(q,q)\} +

+

+\mathcal{G} = \{\bm x\in\mathbb R^2 \mid x_1=0 \land x_2 < 0\} +

+

+r((q,q),\bm x) = \begin{bmatrix}x_1\\ -\gamma x_2 \end{bmatrix}, + where \gamma is the coefficient of restitution (e.g., \gamma = 0.9).

+
+
+
+ +
+
+Comment on the invariant set for the bouncing ball +
+
+
+

Some authors characterize the invariant set as x_1\geq 0. But this means that as the ball touches the ground, nothing forces it to leave the location and do the transition. Instead, the ball must penetrate the ground, however tiny distance, in order to trigger the transition. The current definition avoids this.

+
+
+
+
+
+ +
+
+Another comment on the invariant set for the bouncing ball +
+
+
+

While the previous remark certainly holds, when solving the model numerically, the use of inequalities to define sets is inevitable. And some numerical solvers, in particular optimization solvers, cannot handle strict inequalities. That is perhaps why some authors are quite relaxed about this issue. We will encounter it later on.

+
+
+
+
+

Example 5 (Stick-slip friction model (Karnopp)) Consider a block of mass m placed freely on a surface. External horizontal force F_\mathrm{a} is applied to the block, setting it to a horizontaly sliding motion, against which the friction force F_\mathrm{f} is acting: +m\dot v = F_\mathrm{a} - F_\mathrm{f}(v). +

+

Common choice for a model of friction between two surfaces is Coulomb friction +F_\mathrm{f}(v) = F_\mathrm{c}\operatorname*{sgn}(v). +

+

The model is perfectly intuitive, isn’t it? Well, what if v=0 and F_\mathrm{a}<F_\mathrm{c}? Can you see the trouble?

+

One of the remedies is the Karnopp model of friction +m\dot v = 0, \qquad v=0, \; |F_\mathrm{a}| < F_\mathrm{c} + +F_\mathrm{f} = \begin{cases}\operatorname*{sat}(F_\mathrm{a},F_\mathrm{c}), & v=0\\F_\mathrm{c}\operatorname*{sgn}(v), & \mathrm{else}\end{cases} +

+

The model can be formulated as a hybrid automaton with two discrete states (modes, locations) as in Fig 7.

+
+
+
+ +
+
+Figure 7: Hybrid automaton for the Karnopp model of friction +
+
+
+
+
+

Example 6 (Rimless wheel) A simple mechanical model that is occasionally used in the walking robot community is the rimless wheel rolling down a declined plane as depicted in Fig 8.

+
+
+
+ +
+
+Figure 8: Rimless wheel +
+
+
+

A hybrid automaton for the rimless wheel is below.

+
+
+
+ +
+
+Figure 9: Hybrid automaton for a rimless wheel +
+
+
+

Alternatively, we do not represent the discrete state graphically as a node in the graph but rather as another – extending – state variable s \in \{0, 1, \ldots, 5\} within a single location.

+
+
+
+ +
+
+Figure 10: Alternative hybrid automaton for a rimless wheel +
+
+
+
+
+

Example 7 (DC-DC boost converter) The enabling mechanism for a DC-DC converter is switching. Although the switching is realized with a semiconductor switch, for simplicity of the exposition we consider a manual switch in Fig 11 below.

+
+
+
+ +
+
+Figure 11: DC-DC boost converter +
+
+
+

The switch introduces two modes of operation. But the (ideal) diode introduces a mode transition too.

+
+

The switch closed

+
+
+
+ +
+
+Figure 12: DC-DC boost converter: the switch closed +
+
+
+

+\begin{bmatrix} +\frac{\mathrm{d}i_\mathrm{L}}{\mathrm{d}t}\\ +\frac{\mathrm{d}v_\mathrm{C}}{\mathrm{d}t} +\end{bmatrix} += +\begin{bmatrix} +-\frac{R_\mathrm{L}}{L}i_\mathrm{L} & 0\\ +0 & -\frac{1}{C(R+R_\mathrm{C})} +\end{bmatrix} +\begin{bmatrix} +i_\mathrm{L}\\ +v_\mathrm{C} +\end{bmatrix} ++ +\begin{bmatrix} +\frac{1}{L}\\ +0 +\end{bmatrix} +v_0 +

+
+
+

Continuous conduction mode (CCM)

+
+
+
+ +
+
+Figure 13: DC-DC boost converter: continuous conduction mode (CCM) +
+
+
+

+\begin{bmatrix} +\frac{\mathrm{d}i_\mathrm{L}}{\mathrm{d}t}\\ +\frac{\mathrm{d}v_\mathrm{C}}{\mathrm{d}t} +\end{bmatrix} += +\begin{bmatrix} +-\frac{R_\mathrm{L}+ \frac{RR_\mathrm{C}}{R+R_\mathrm{C}}}{L} & -\frac{R}{L(R+R_\mathrm{C})}\\ +\frac{R}{C(R+R_\mathrm{C})} & -\frac{1}{C(R+R_\mathrm{C})} +\end{bmatrix} +\begin{bmatrix} +i_\mathrm{L}\\ +v_\mathrm{C} +\end{bmatrix} ++ +\begin{bmatrix} +\frac{1}{L}\\ +0 +\end{bmatrix} +v_0 +

+
+
+

Discontinuous cond. mode (DCM)

+
+
+
+ +
+
+Figure 14: DC-DC boost converter: discontinuous conduction model (DCM) +
+
+
+

+\begin{bmatrix} +\frac{\mathrm{d}i_\mathrm{L}}{\mathrm{d}t}\\ +\frac{\mathrm{d}v_\mathrm{C}}{\mathrm{d}t} +\end{bmatrix} += +\begin{bmatrix} +0 & 0\\ +0 & -\frac{1}{C(R+R_\mathrm{C})} +\end{bmatrix} +\begin{bmatrix} +i_\mathrm{L}\\ +v_\mathrm{C} +\end{bmatrix} ++ +\begin{bmatrix} +0\\ +0 +\end{bmatrix} +v_0 +

+
+

Possibly the events of opening and closing the switch can be driven by time: opening the switch is derived from the value of an input signal, closing the switch is periodic.

+
+
+
+
+ +
+
+Figure 15: Hybrid automaton for a DC-DC boost converter +
+
+
+
+
+ + +
+
+ + Back to top
+ + +
+ + + + + + \ No newline at end of file diff --git a/hybrid_automata.html b/hybrid_automata.html index 6121639..ac67737 100644 --- a/hybrid_automata.html +++ b/hybrid_automata.html @@ -2,7 +2,7 @@ - + @@ -37,10 +37,10 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Software

+
+ + + +
+ + + + +
+ + + +
+ + +
+

Matlab

+ +
+
+

Julia

+ +
+
+

Python

+
    +
  • +
+ + +
+ + Back to top
+ + +
+ + + + + + \ No newline at end of file diff --git a/hybrid_automata_software.html b/hybrid_automata_software.html index 7d1bea3..27fc920 100644 --- a/hybrid_automata_software.html +++ b/hybrid_automata_software.html @@ -2,7 +2,7 @@ - + @@ -37,10 +37,10 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Literature

+
+ + + +
+ + + + +
+ + + +
+ + +

The theoretical and computational framework of hybrid equations has been mostly developed by a relatively small circle of researchers (Sanfelice, Goebel, Teel, …). The primary monograph is [1]. It is also supported by a freely available Matlab toolbox, see the section on software.

+

+

The book [2] can be regarded as a predecessor and/or complement of the just mentioned [1]. Although the book is not available online, a short version appears as an article [3] in the popular IEEE Control Systems magazine (the one with color figures :-).

+

+ + + + + Back to top

References

+
+
[1]
R. G. Sanfelice, Hybrid Feedback Control. Princeton University Press, 2021. Accessed: Sep. 23, 2020. [Online]. Available: https://press.princeton.edu/books/hardcover/9780691180229/hybrid-feedback-control
+
+
+
[2]
R. Goebel, R. G. Sanfelice, and A. R. Teel, Hybrid Dynamical Systems: Modeling, Stability, and Robustness. Princeton University Press, 2012. Available: https://press.princeton.edu/books/hardcover/9780691153896/hybrid-dynamical-systems
+
+
+
[3]
R. Goebel, R. G. Sanfelice, and A. R. Teel, “Hybrid dynamical systems,” IEEE Control Systems Magazine, vol. 29, no. 2, pp. 28–93, Apr. 2009, doi: 10.1109/MCS.2008.931718.
+
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/hybrid_equations_references.html b/hybrid_equations_references.html index 918ccae..bd40378 100644 --- a/hybrid_equations_references.html +++ b/hybrid_equations_references.html @@ -2,7 +2,7 @@ - + @@ -57,10 +57,10 @@ - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Course outline

+
+ + + +
+ + + + +
+ + + +
+ + +

The course is structured into 14 topics, each of them corresponding to one lecture. The topics are as follows:

+ +
    +
  1. Solutions of hybrid systems
  2. +
+ +
    +
  1. Mixed-logical dynamical (MLD) description of hybrid systems
  2. +
  3. Model predictive control (MPC) for MLD systems
  4. +
  5. (Formal) verification of hybrid systems
  6. +
+ + + + Back to top
+ + +
+ + + + + + \ No newline at end of file diff --git a/intro_outline.html b/intro_outline.html index 60fd76f..b9eb4c4 100644 --- a/intro_outline.html +++ b/intro_outline.html @@ -2,7 +2,7 @@ - + @@ -37,10 +37,10 @@ - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Discrete hybrid automata

+
+ + + +
+ + + + +
+ + + +
+ + +

Since the new modelling framework is expected to be useful for prediction of a system response within model predictive control, it must model a hybrid system in discrete time. This is a major difference from what we did in our course so far.

+

In particular, we are going to model a hybrid system as a discrete(-time) hybrid automaton (DHA), which means that

+ +
+

Four components of a discrete(-time) hybrid automaton

+

We are already well familiar with the concept of a hybrid automaton, and the restriction to discrete time does not seem to warrant reopening the definition (modes/locations, guards, invariants/domains, reset maps, …). However, it turns out that reformulating/restructuring the hybrid automaton will be useful for our ultimate goal of developing an MPC-friendly modelling framework. In particular, we consider four components of a DHA:

+
    +
  • switched affine system (SAS),
  • +
  • mode selector (MS),
  • +
  • event generator (EG),
  • +
  • finite state machine (FSM).
  • +
+

Their interconnection is shown in the following figure.

+
+

Draw the block diagram from Bemporad’s materials (book, toolbox documentation).

+
+

Let’s discuss the individual components (and while doing that, you can think about the equivalent concept in the classical definition of a hybrid automaton such as mode, invariant, guard, …).

+
+

Switched affine systems (SAS)

+

This is a model of the continuous-value dynamics parameterized by the index i that evolves in (discrete) time +\begin{aligned} +x_c(k+1) &= A_{i(k)} x_c(k) + B_{i(k)} u_c(k) + f_{i(k)}\\ +y_c(k) &= C_{i(k)} x_c(k) + D_{i(k)} u_c(k) + g_{i(k)} +\end{aligned} +

+

In principle there is no need to restrict the right hand sides to affine functions as we did, but the fact is that the methods and tools are currently only available for this restricted class of systems.

+
+
+

Event generator (EG)

+

We consider partitioning of the state space or possibly state-control space into polyhedral regions. The system is then in the ith region of the state-input space, if the continuous-value state x_c(k) and the continuous-value control input u_c satisfy +H_i x_c(k) + J_i u_c(k) + K_i \leq 0 +

+

The event indicated by the (vector) binary variable +\delta_e(k) = h(x_c(k), u_c(k)) \in \{0,1\}^m, +

+

where +h_i(x_c(k), u_c(k)) = \begin{cases}1 & H_i x_c(k) + J_i u_c(k) + K_i \leq 0\\ 0 & \text{otherwise}. \end{cases} +

+
+
+

Finite state machine (FSM)

+

+x_d(k+1) = f_d(x_d(k),u_d(k),\delta_e(k)) +

+
+
+

Mode selector (MS)

+

i(k) \in \{1, 2, \ldots, s\}

+

+i(k) = \mu(x_d(k), u_d(k), \delta_e(k)) +

+
+
+
+

Trajectory of a DHA

+

+\begin{aligned} +\delta_e(k) &= h(x_c(k), u_c(k))\\ +i(k) &= \mu(x_d(k), u_d(k), \delta_e(k))\\ +y_c(k) &= C_{i(k)} x_c(k) + D_{i(k)} u_c(k) + g_{i(k)}\\ +y_d(k) &= g_d(x_d(k), u_d(k), \delta_e(k))\\ +x_c(k+1) &= A_{i(k)} x_c(k) + B_{i(k)} u_c(k) + f_{i(k)}\\ +x_d(k+1) &= f_d(x_d(k),u_d(k),\delta_e(k)) +\end{aligned} +

+
+
+

How to get rid of the IF-THEN conditions in the model?

+ + +
+ + Back to top
+ + +
+ + + + + + \ No newline at end of file diff --git a/mld_DHA.html b/mld_DHA.html index a1a9087..ae827ef 100644 --- a/mld_DHA.html +++ b/mld_DHA.html @@ -2,7 +2,7 @@ - + @@ -37,10 +37,10 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Logic vs inequalities

+
+ + + +
+ + + + +
+ + + +
+ + +

Our goal now is to turn the IF-THEN conditions in the model into linear inequalities. This will allow us to formulate the model as a mathematical program, actually a mixed-integer program (MIP).

+
+

Propositional logic and connectives

+

Propositions that are either true or false are composed of elementary propositions (Boolean variables) and connectives.

+
+

Boolean variable (or elementary proposition)

+

\(X\) evaluates to true or false. Oftentimes values 0 and 1 are used, but it should be clear that these are not numbers but logical values.

+
+
+

Connectives

+
    +
  • Conjunction (logical and): \(X_1 \land X_2\)
  • +
  • Disjunction (logical or): \(X_1 \lor X_2\)
  • +
  • Negation: \(\neg X_2\) (or \(\overline{X_2}\) or \(\sim X_2\))
  • +
  • Implication: \(X_1 \implies X_2\)
  • +
  • Equivalence: \(X_1 \iff X_2\)
  • +
  • Logical XOR: \(X_1 \oplus X_2\)
  • +
+
+
+
+

Equivalences of logic propositions

+

We will heavily used the following equivalences: \[ +\begin{aligned} +X_1 \implies X_2 \qquad &\equiv \qquad \neg X_2 \implies \neg X_1,\\ +X_1 \iff X_2 \qquad &\equiv \qquad (X_1 \implies X_2) \land (X_2 \implies X_1),\\ +X_1 \land X_2 \qquad &\equiv \qquad \neg (\neg X_1 \lor \neg X_2),\\ +X_1 \implies X_2 \qquad &\equiv \qquad \neg X_1 \lor X_2. +\end{aligned} +\]

+

The last one can be seen as follows: it cannot happen that \(X1 \land \neg X2\), that is, it holds that \(\neg(X1 \land \neg X2)\). De Morgan gives \(\neg X1 \lor X2\).

+
+ + +
+

General transformation of Boolean expressions to integer inequalities

+

From Conjunctive Normal Form (CNF) \[ +\bigwedge_{j=1}^m \left[\left(\lor_{i\in \mathcal{P}_j} X_i\right) \lor \left(\lor_{i\in \mathcal{N}_j} \neg X_i\right)\right] +\] to 0-1 integer inequalities defining a polyhedron \[ +\begin{aligned} +\sum_{i\in \mathcal{P}_1} \delta_i + \sum_{i\in \mathcal{N}_1} (1-\delta_i) &\geq 1,\\ +&\vdots\\ +\sum_{i\in \mathcal{P}_m} \delta_i + \sum_{i\in \mathcal{N}_m} (1-\delta_i) &\geq 1. +\end{aligned} +\]

+
+
+

Finite state machine (FSM) using binary variables

+

Encode the discrete state variables in binary \[ +x_b \in \{0,1\}^{n_b} +\]

+

Similarly the discrete inputs \[ +u_b \in \{0,1\}^{m_b} +\]

+

The logical state equation then \[ +x_b(k+1) = f_b(x_b(k),u_b(k),\delta_e(k)) +\]

+
+

Example 1 (Example)  

+
+
+
+ +
+
+Figure 1: Example of a FSM +
+
+
+

The state update/transition equation is \[ +\begin{aligned} +x_d(k+1) = +\begin{cases} +\text{Red} & \text{if}\; ([x_d = \text{green}] \land \neg [\delta_3=1]) \lor ([x_d = \text{red}] \land \neg [\delta_3=1])\\ +\text{Green} & \text{if} \; \ldots\\ +\text{Blue} & \text{if} \; \ldots +\end{cases} +\end{aligned} +\]

+

Binary encoding of the discrete states \[ +\text{Red}: x_b = \begin{bmatrix}0\\0 \end{bmatrix}, \; \text{Green}: x_b = \begin{bmatrix}0\\1 \end{bmatrix}, \; \text{Blue}: x_b = \begin{bmatrix}1\\0 \end{bmatrix} +\]

+

Reformulating the state update equations for binary variables \[ +\begin{aligned} +x_{b1} &= (\neg [x_{b1} = 1] \land \neg [x_{b2} = 1] \land \neg [\delta_1=1]) \\ +&\quad (\neg [x_{b1} = 1] \land \neg [x_{b2} = 1] \land [\delta_1=1]) \land [u_{b2}=1]\\ +&\quad (\neg [x_{b1} = 1] \land [x_{b2} = 1] \land \neg [u_{b1}=1] \land [\delta_3=1])\\ +&\quad \lor ([x_{b1} = 1]\land \neg [\delta_2=1])\\ +x_{b2} &= \ldots +\end{aligned} +\]

+

Finally, simplify, convert to CNF.

+
+
+
+

Mixing logical and continuous

+
    +
  • see Indicator variables.
  • +
+
+

Logical implies continuous

+

\[X \implies [f(x)\leq 0]\]

+

\[[\delta = 1] \implies [f(x)\leq 0]\]

+
    +
  • introduce \(M\) \[ +f(x) \leq (1-\delta) M +\]

  • +
  • that is large enough so that when \(\delta=0\), there is no practical restriction on \(f\).

    +
      +
    • Big-M technique.
    • +
  • +
+
+
+

Continuous implies logical

+

\[[f(x)\leq 0] \implies X\]

+

\[[f(x)\leq 0] \implies [\delta = 1]\]

+
    +
  • Equivalently \[\neg [\delta = 1] \implies \neg [f(x)\leq 0],\]

  • +
  • that is, \[[\delta = 0] \implies [f(x) > 0]\]

  • +
  • Introduce \(m\) such that \(f(x)>0\) is enforced when \(\delta=0\) \[ +f(x) > m\delta +\]

  • +
  • but small enough that there is no restriction on \(f\) when \(\delta=1\).

  • +
  • For numerical reasons, modify to nonstrict inequality \[ +f(x) \geq \epsilon + (m-\epsilon)\delta, +\] where \(\epsilon\approx 0\) (for example, machine epsilon).

  • +
+
+
+

Equivalence between logical and continuous

+
    +
  • Combining the previous two implications.
  • +
+

\[ +\begin{aligned} +f(x) &\leq (1-\delta) M,\\ +f(x) &\geq \epsilon + (m-\epsilon)\delta. +\end{aligned} +\]

+
+
+
+

IF-THEN-ELSE rule as an inequality

+
    +
  • If \(X\) +
      +
    • then \(z = a^\top x + b^\top u + f\),
    • +
    • else \(z = 0\).
    • +
  • +
  • It can be expressed as a product \[ +z = \delta\,(a^\top x + b^\top u + f) +\]
  • +
+

\[ +\begin{aligned} +z &\leq M\delta,\\ +- z &\leq -m\delta,\\ +z &\leq a^\top x + b^\top u + f - m(1-\delta),\\ +-z &\leq -(a^\top x + b^\top u + f) + M(1-\delta). +\end{aligned} +\]

+
+

The reasoning is that if \(\delta=0\), then \(z\) is restricted, while \(a^\top x + b^\top u + f\) is not. And the other way around.

+
+
+
+

Another IF-THEN-ELSE rule

+
    +
  • If \(X\) +
      +
    • then \(z = a_1^\top x + b_1^\top u + f_1\),
    • +
    • else \(z = a_2^\top x + b_2^\top u + f_2\).
    • +
  • +
  • It can be expressed as \[ +\begin{aligned} +z &= \delta\,(a_1^\top x + b_1^\top u + f_1) \\ +&\quad + (1-\delta)(a_2^\top x + b_2^\top u + f_2) +\end{aligned} +\]
  • +
+

\[ +\begin{aligned} +(m_2-M_1)\delta + z &\leq a_2^\top x + b_2^\top u + f_2,\\ +(m_1-M_2)\delta - z &\leq -a_2^\top x - b_2^\top u - f_2,\\ +(m_1-M_2)(1-\delta) + z &\leq a_1^\top x + b_1^\top u + f_1,\\ +(m_2-M_1)(1-\delta) - z &\leq -a_1^\top x - b_1^\top u - f_1. +\end{aligned} +\]

+
+
+

Generation of events by mixing logical and continuous variables in inequalities

+

\[ +\begin{aligned} +h_i(x_c(k), u_c(k)) &\leq M_i (1-\delta_{e,i})\\ +h_i(x_c(k), u_c(k)) &\geq \epsilon + (m_i-\epsilon) \delta_{e,i} +\end{aligned} +\]

+
+
+

Switched affine system

+
    +
  • We want to get rid of the IF-THEN and formulate the switching mechanism into the format of inequalities too.
  • +
+

\[ +x_c(k+1) = \sum_{i=1}^s z_i(k), +\]

+
    +
  • where \[ +z_1(k) = +\begin{cases} +A_1 x_c(k) + B_1 u_c(k) + f_1 & \text{if}\;i(k)=1\\ +0 & \text{otherwise} +\end{cases} +\]
  • +
+

\[\quad \vdots\]

+

\[ +z_s(k) = +\begin{cases} +A_s x_c(k) + B_s u_c(k) + f_s & \text{if}\;i(k)=s\\ +0 & \text{otherwise} +\end{cases} +\]

+
    +
  • For each \(i\in \{1, 2, \ldots, s\}\)
  • +
+

\[ +\begin{aligned} +z_i &\leq M_i\delta_i,\\ +- z_i &\leq -m_i\delta_i,\\ +z_i &\leq a_i^\top x + b_i^\top u + f_i - m_i(1-\delta_i),\\ +-z_i &\leq -(a_i^\top x + b_i^\top u + f_i) + M_i(1-\delta_i). +\end{aligned} +\]

+
+
+

Mixed logical dynamical (MLD) system

+

\[ +\begin{aligned} +x(k+1) &= Ax(k) + B_u u(k) + B_\delta\delta + B_zz(k) + B_0\\ +y(k) &= Cx(k) + D_u u(k) + D_\delta \delta + D_z z + D_0\\ +E_\delta \delta &+ E_z z(k) \leq E_u u(k) + E_x x(k) + E_0 +\end{aligned} +\]

+
+
+

Simple example

+
+
+

HYSDEL language

+
+
+

Piecewise affine systems

+

\[ +\begin{aligned} +x(k+1) &= A_{i(k)}x(k) + B_{i(k)} u(k) + f_{i(k)}\\ +y(k) &= C_{i(k)}x(k) + D_{i(k)} u(k) + g_{i(k)}\\ +& \; H_{i(k)} x(k) + J_{i(k)} u(k) \leq K_{i(k)} +\end{aligned} +\]

+
    +
  • DHA, MLD, PWA are equivalent.
  • +
+ + +
+ + Back to top
+ + +
+ + + + + + \ No newline at end of file diff --git a/mld_intro.html b/mld_intro.html index b6c3d48..7c3d613 100644 --- a/mld_intro.html +++ b/mld_intro.html @@ -2,7 +2,7 @@ - + @@ -37,10 +37,10 @@ - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Why another framework?

+
+ + + +
+ + + + +
+ + + +
+ + +

We are going to introduce yet another framework for modeling hybrid systems – mixed logical dynamical (MLD) description. A question must inevitably pop up: “why yet another framework?”

+

The answer is, that we would like to have a model of a hybrid system that is suitable for model predictive control (MPC). Recall that the role of the model in MPC is that the model is used to define some constraints (equations and inequalities) in the numerical optimization problem. The frameworks that we considered so far did not offer it.

+

In particular, with the state variable and control input vectors composed of continuous and discrete variables +\bm x = \begin{bmatrix}\bm x_c\\\bm x_d\end{bmatrix}, \quad \bm u = \begin{bmatrix}\bm u_c\\\bm u_d\end{bmatrix}, + where \bm x_c\in\mathbb R^{n_c},\;\bm x_d\in\mathbb N^{n_d},\; \bm u_c\in\mathbb R^{m_c} and \bm u_d\in\mathbb N^{m_d}, we would like to formulate the model in the form of state equations, say +\begin{aligned} +\begin{bmatrix}\bm x_c(k+1) \\ \bm x_d(k+1)\end{bmatrix} +&= +\begin{bmatrix} \mathbf f_c(\bm x(k), \bm u(k)) \\ \mathbf f_d(\bm x(k), \bm u(k)) \end{bmatrix} +\end{aligned} +

+

Is it possible?

+

Unfortunately no. At least not exactly in this form. But something close to it is achievable instead.

+

But first we need to set the terminology and notation used to define a discrete(-time) hybrid automaton.

+ + + + Back to top
+ + +
+ + + + + + \ No newline at end of file diff --git a/mld_why.html b/mld_why.html index 555f5d3..a5a24ac 100644 --- a/mld_why.html +++ b/mld_why.html @@ -2,7 +2,7 @@ - + @@ -37,10 +37,10 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Explicit MPC for hybrid systems

+
+ + + +
+ + + + +
+ + + +
+ + +

Model predictive control (MPC) is not computationally cheap (compared to, say, PID or LQG control) as it requires solving optimization problem – typically a quadratic program (QP) - online. The optimization solver needs to be a part of the controller.

+

There is an alternative, though, at least in same cases. It is called explicit MPC. The computationally heavy optimization is only perfomed only during the design process and the MPC controller is then implemented just as an affine state feedback

+

+\bm u_k(\bm x(k)) = \mathbf F_k^i \bm x(k) + \mathbf g_k^i,\; \text{if}\; \bm x(k) \in \mathcal R_k^i, +

+

with the coefficients picked from some kind of a lookup table in real time Although retreiving the coefficients of the feedback controller is not computationally trivial, still it is cheaper than full optimization.

+
+

Multiparametric programming

+

The key technique for explicit MPC is multi-parametric programming. In order to explain it, consider the following problem

+

+J^\ast(x) = \inf_z J(z;x). +

+

The z variable is an optimization variable, while x is a parameter. For a given parameter x, the cost function J is minimized. We study how the optimal cost J^\ast depends on the parameter, hence the name parametric programming. If x is a vector, the name of the problem changes to multiparametric programming.

+
+

Example: scalar variable, single parameter

+

Consider the following cost function J(z;x) in z parameterized by x. The optimization variable z is constrained and this constraint is also parameterized by x. +\begin{aligned} +J(z;x) &= \frac{1}{2} z^2 + 2zx + 2x^2 \\ +\text{subject to} &\quad z \leq 1 + x. +\end{aligned} +

+

In this simple case we can aim at analytical solution. We proceed in the standard way – we introduce a Lagrange multiplicator \lambda and form the augmented cost function +L(z,\lambda; x) = \frac{1}{2} z^2 + 2zx + 2x^2 + \lambda (z-1-x). +

+

The necessary conditions of optimality for the inequality-constrained problem come in the form of KKT conditions +\begin{aligned} +z + 2x + \lambda &= 0,\\ +z - 1 - x &\leq 0,\\ +\lambda & \geq 0,\\ +\lambda (z - 1 - x) &= 0. +\end{aligned} +

+

The last condition – the complementarity condition – gives rise to two scenarios: one corresponding to \lambda = 0, and the other corresponding to z - 1 - x = 0. We consider them separately below.

+

After substituting \lambda = 0 into the KKT conditions, we get +\begin{aligned} +z + 2x &= 0,\\ +z - 1 - x & \leq 0. +\end{aligned} +

+

From the first equation we get how z depends on x, and from the second we obtain a bound on x. Finally, we can also substitute the expression for z into the cost function J to get the optimal cost J^\ast as a function of x. All these are summarized here +\begin{aligned} +z &= -2x,\\ +x & \geq -\frac{1}{3},\\ +J^\ast(x) &= 0. +\end{aligned} +

+

Now, the other scenario. Upon substitutin z - 1 - x = 0 into the KKT conditions we get

+

+\begin{aligned} +z + 2x + \lambda &= 0,\\ +z - 1 - x &= 0,\\ +\lambda & \geq 0. +\end{aligned} +

+

From the second equation we get the expression for z in terms of x, substituting into the first equation and invoking the condition on nonnegativity of \lambda we get the bound on x (not suprisingly it complements the one obtained in the previous scenario). Finally, substituting for z in the cost function J we get a formula for the cost J^\ast as a function of x.

+

+\begin{aligned} +z &= 1 + x,\\ +\lambda &= -z - 2x \geq 0 \quad \implies \quad x \leq -\frac{1}{3},\\ +J^\ast(x) &= \frac{9}{2}x^2 + 3x + \frac{1}{2}. +\end{aligned} +

+

The two scenarios can now be combined into a single piecewise affine function z(x) +z(x) = \begin{cases} +1+x & \text{if } x \leq -\frac{1}{3},\\ +-2x & \text{if } x > -\frac{1}{3}. +\end{cases} +

+
x = range(-1, 1, length=100)
+z(x) = x <= -1/3 ? 1 + x : -2x
+Jstar(x) = x <= -1/3 ? 9/2*x^2 + 3x + 1/2 : 0
+
+using Plots
+plot(x, z.(x), label="z(x)")
+vline!([-1/3],line=:dash)
+xlabel!("x")
+ylabel!("z(x)")
+

and a piecewise quadratic cost function J^\ast(x) +J^\ast(x) = \begin{cases} +\frac{9}{2}x^2 + 3x + \frac{1}{2} & \text{if } x \leq -\frac{1}{3},\\ +0 & \text{if } x > -\frac{1}{3}. +\end{cases} +

+
plot(x, Jstar.(x), label="J*(x)")
+vline!([-1/3],line=:dash)
+xlabel!("x")
+ylabel!("J*(x)")
+ + +
+
+ + Back to top
+ + +
+ + + + + + \ No newline at end of file diff --git a/mpc_mld_explicit.html b/mpc_mld_explicit.html index c95401f..6b1ce5f 100644 --- a/mpc_mld_explicit.html +++ b/mpc_mld_explicit.html @@ -2,7 +2,7 @@ - + @@ -37,10 +37,10 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Literature

+
+ + + +
+ + + + +
+ + + +
+ + +

The main resource for us is the Chapter 17 of the freely available book [1] that we already referred to in the previous chapter.

+

Those who have not been exposed to fundamentals of MPC can check the Chapter 12 in the same book. Alternatively, our own introduction to the topic in the third chapter/week of the Optimal and robust control course can be found useful.

+ + + + + Back to top

References

+
+
[1]
F. Borrelli, A. Bemporad, and M. Morari, Predictive Control for Linear and Hybrid Systems. Cambridge, New York: Cambridge University Press, 2017. Available: http://cse.lab.imtlucca.it/~bemporad/publications/papers/BBMbook.pdf
+
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/mpc_mld_references.html b/mpc_mld_references.html index 2ad44fe..8a8dd03 100644 --- a/mpc_mld_references.html +++ b/mpc_mld_references.html @@ -2,7 +2,7 @@ - + @@ -57,10 +57,10 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Software

+
+ + + +
+ + + + +
+ + + +
+ + +

Essentially the same as in the previous chapter.

+ + + + Back to top
+ + +
+ + + + + + \ No newline at end of file diff --git a/mpc_mld_software.html b/mpc_mld_software.html index b8f98d8..167d289 100644 --- a/mpc_mld_software.html +++ b/mpc_mld_software.html @@ -2,7 +2,7 @@ - + @@ -37,10 +37,10 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Literature

+
+ + + +
+ + + + +
+ + + +
+ + +

Literature for Petri nets is vast, but a decent (and perfectly satisfactory) introduction can be found in Chapter 4 and 5.3 (for the timed PN) of the classical (and award-winning) reference [1]. Note that electronic version (in fact, PDF) is accessible through the NTK library (upon CTU login, for example to usermap first).

+

A nice introduction is also in Chapter 2 of the freely online available book [2].

+

The survey paper that is particularly focused on Petri nets from the control systems perspective is [3] and it gives a wealth of other references.

+

A few more monographs, mostly inclined towards control systems, are [4], [5], [6].

+
+

Petri nets and their derivatives such as Grafcet in international standards

+

We mention at the beginning of this chapter that Petri nets have made it to international standards. Here they are: [7], [8], and [9].

+

Based on Petri nets, another framework has been derived and standardized, namely GRAFCET, see [10] and [11], upon which, in turn, the popular Sequential Function Chart (SFC) language for PLC programming [12] is based.

+ + + +
+ + Back to top

References

+
+
[1]
C. G. Cassandras and S. Lafortune, Introduction to Discrete Event Systems, 3rd ed. Cham: Springer, 2021. Available: https://doi.org/10.1007/978-3-030-72274-6
+
+
+
[2]
F. Baccelli, G. Cohen, G. J. Olsder, and J.-P. Quadrat, Synchronization and linearity: An algebra for discrete event systems, Web edition. Chichester: Wiley, 2001. Available: https://www.rocq.inria.fr/metalau/cohen/documents/BCOQ-book.pdf
+
+
+
[3]
A. Giua and M. Silva, “Petri nets and Automatic Control: A historical perspective,” Annual Reviews in Control, vol. 45, pp. 223–239, Jan. 2018, doi: 10.1016/j.arcontrol.2018.04.006.
+
+
+
[4]
J. O. Moody, Supervisory Control of Discrete Event Systems Using Petri Nets. in The International Series on Discrete Event Dynamic Systems. New York, NY: Springer, 31 {\v c}ervence 1998. Available: https://doi.org/10.1007/978-1-4615-5711-1
+
+
+
[5]
B. Hrúz and M. Zhou, Modeling and Control of Discrete-event Dynamic Systems: With Petri Nets and Other Tools. in Advanced Textbooks in Control and Signal Processing (C&SP). London: Springer, 2007. Available: https://doi.org/10.1007/978-1-84628-877-7
+
+
+
[6]
W. Reisig, Understanding Petri Nets: Modeling Techniques, Analysis Methods, Case Studies. Berlin; Heidelberg: Springer, 2013. Available: https://doi.org/10.1007/978-3-642-33278-4
+
+
+
[7]
ISO/IEC 15909-1:2019 Systems and software engineering — High-level Petri nets — Part 1: Concepts, definitions and graphical notation.” ISO/IEC, Aug. 2019. Accessed: Sep. 27, 2023. [Online]. Available: https://www.iso.org/standard/67235.html
+
+
+
[8]
ISO/IEC 15909-2:2011 Systems and software engineering — High-level Petri nets — Part 2: Transfer format.” ISO/IEC, Feb. 2011. Accessed: Sep. 27, 2023. [Online]. Available: https://www.iso.org/standard/43538.html
+
+
+
[9]
ISO/IEC 15909-3:2021: Systems and software engineering — High-level Petri nets — Part 3: Extensions and structuring mechanisms.” ISO/IEC, 2021. Accessed: Sep. 29, 2023. [Online]. Available: https://www.iso.org/standard/81504.html
+
+
+
[10]
IEC 60848:2013 GRAFCET specification language for sequential function charts.” IEC, Feb. 2013. Available: https://webstore.iec.ch/publication/3684
+
+
+
[11]
C. Johnsson and K.-E. Årzén, “Grafchart and its Relations to Grafcet and Petri Nets,” IFAC Proceedings Volumes, vol. 31, no. 15, pp. 95–100, Jun. 1998, doi: 10.1016/S1474-6670(17)40535-0.
+
+
+
[12]
IEC 61131-3 Programmable controllers - Part 3: Programming languages.” IEC, Feb. 2013. Accessed: Jan. 08, 2023. [Online]. Available: https://webstore.iec.ch/publication/4552
+
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/petri_nets_references.html b/petri_nets_references.html index 1595873..eeefbdb 100644 --- a/petri_nets_references.html +++ b/petri_nets_references.html @@ -2,7 +2,7 @@ - + @@ -57,10 +57,10 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Timed Petri nets

+
+ + + +
+ + + + +
+ + + +
+ + +

Recall that when introducing enabled transitions, we emphasized that these can but do not have to fire immediately after having been enabled \boxed{\mathrm{ENABLING} \neq \text{FIRING}.}

+
+

Delays associated with transitions

+

Well then, the enabled transitions do not have to fire immediately, but they can possibly fire with some delay after enabling. This is for the first time that we are introducing the concept of time into the Petri nets, isn’t it?

+

For the jth transition, the delay of the kth firing is v_{j,k}, and we collect the sequence of delayes into v_j = \{v_{j,1}, v_{j,2}, \ldots \}.

+

But not all transitions have to be timed. Denote the timed transitions \mathcal{T}_\mathrm{D}\subseteq \mathcal{T}. We define the clock structure for a PN as \mathcal{V} = \{v_j\mid t_j\in\mathcal{T}_\mathrm{D}\}.

+

The definition of a timed Petri net (TPN) is then obtained by augmenting the definition of a Petri net with the clock structure

+

\boxed{TPN = \{\mathcal{P}, \mathcal{T}, \mathcal{A}, w, x, \mathcal{V}\}}.

+
+

Example 1 (Timed Petri net) Model of processing multiple tasks: task 1 and task 2 are processed sequentially, and task 3 is processed in parallel with them; task 4 can only be processed after both tasks 2 and 3 have been finished. Finishing individual tasks corresponds to the individual transitions. The transition 4 is untimed, it only expresses the logical requirement.

+
+
+

+
Example of a timed Petri net
+
+
+
+
+
+
+ +
+
+Rectangles instead of bars +
+
+
+

Sometimes instead of a bar, the untimed transitions are modelled using similarly thin rectangles as the timed transitions, but filled.

+
+
+
+

Places can also be delayed

+

With delays associated with just one type of a node in a Petri net, the situation is rather nonsymmetric. In some literature, delays can also associated with places. And yet in some other literature delays are only associated with places. Such delays associated with places are called holding time for a place It is the minimum duration the token must rest in the place. But the token can stay longer if the output transition is waiting for other places.

+
+
+
+ +
+
+Delays associated with transitions and places +
+
+
+

There is a major difference in delays associated with places compared to the delays associated with transitions. While the former tells the minimum duration the token has to dwell in the place, the latter tell the exact delay with which the transition fires after having been enabled.

+
+
+
+
+
+

Timed Petri net dynamics

+

With the introduction of time into the Petri nets, we can now study the dynamics of the system. For general Petri nets, alhough perfectly doable, it may quicly become too complex, and therefore here we only consider event graphs.

+

Some notation:

+
    +
  • \{\tau_{j,1}, \tau_{j,2}, \ldots\} are the firing times of the jth transition,
  • +
  • \{\pi_{i,1},\pi_{i,2},\ldots\} are the times when the ith place receives a token,
  • +
  • x_i = x(p_i) is the number of tokens at the ith place,
  • +
  • x_{i,k} = \left.x(p_i)\right|_k, is the number of tokens at the ith place after the kth firing.
  • +
+

Now, assume first that x_{i,0} = 0. We can then relate the time of the arrival of the token to the place with the firing of the transition from which the token arrives \pi_{i,k} = \tau_{j,k},\quad p_i\in \mathcal{O}(t_j).

+

But generally x_{i,0} \neq 0 and the above relation needs to be modified to \pi_{i,k+x_{i,0}} = \tau_{j,k},\quad p_i\in \mathcal{O}(t_j), or, equivalently \boxed{\pi_{i,k} = \tau_{j,k-x_{i,0}},\quad p_i\in \mathcal{O}(t_j).} \tag{1}

+

This can be read in the following way. If there are initially, say, 3 tokens in the place, the time of the arrival of the 4th token is the time of the first firing of the transition from which the 4th token arrives.

+

Good. Keep this result in mind. Now we go for another.

+

For an untimed transition with a single input place, the firing time is the same as the time of the arrival of the token to the place +\tau_{j,k} = \pi_{i,k}. +

+

Modifying this result for a timed transition with a single input place we get +\tau_{j,k} = \pi_{i,k} + v_{j,k}. +

+

In words, the firing time is given by the time of the arrival of the token to the place, which enables the transition, and the delay associated with the transition.

+

Finally, we extend this result to the case of a timed transition with multiple input places \boxed{ +\tau_{j,k} = \max_{p_i\in\mathcal{I}(t_j)}\{\pi_{i,k}\} + v_{j,k}.} +\tag{2}

+

This is the other promised important result. Keep both boxed formulas Equation 1 and Equation 2 handy, they will be needed in what is coming.

+
+

Example 2 (Timed Petri net dynamics) Consider the Petri net with three places and two transitions, one of which is timed, as in Fig 1.

+
+
+
+ +
+
+Figure 1: Example of a Petri net for which the dynamics is analyzed +
+
+
+

We first use Equation 2 to write down the firing times of the two transitions +\begin{aligned} +\tau_{1,k} &= \max\{\pi_{1,k},\pi_{3,k}\}\\ +\tau_{2,k} &= \pi_{2,k}+v_{2,k}. +\end{aligned} +

+

Now we apply Equation 1 to write down the times of the arrival of the tokens to the places +\begin{aligned} +\pi_{1,k} &= \tau_{1,k-1}, \qquad k=2,\ldots, \qquad \pi_{1,0} = 0\\ +\pi_{2,k} &= \tau_{1,k-1}, \qquad k=2,\ldots, \qquad \pi_{2,0} = 0\\ +\pi_{3,k} &= \tau_{2,k}, \qquad k=1,\ldots +\end{aligned} +

+

Substituting from the latter into the former we get +\begin{aligned} +\tau_{1,k} &= \max\{\tau_{1,k-1},\tau_{1,k-1}+v_{2,k}\}\\ +&= \tau_{1,k-1}+v_{2,k}, \quad \tau_{1,k} = 0\\ +\tau_{2,k} &= \tau_{1,k-1}+v_{2,k}. +\end{aligned} +

+

This is the ultimate model for the dynamics of the Petri net. Should we need it, we can also get similar expressions for the times of the arrival of the tokens to the places.

+
+
+
+
+ +
+
+Update equations for times and not states +
+
+
+

While with state equations we compute a sequences of values of the state vector (\bm x_0, \bm x_1, \bm x_2, \ldots), in other words, we compute the evolution of the state in time, here we compute the sequences of times when transitions fire (or token arrive to places). This update scheme for times resembles the state equations, but the interpretation is different.

+
+
+
+
+

Queueing system using TPN

+

We can also model a queueing system using a TPN. The Petri net is shown in Fig 2.

+
+
+
+ +
+
+Figure 2: Timed Petri net modelling a queueing system +
+
+
+

Of the three transitions \mathcal{T} = \{a,s,c\}, which we have already identified previously, we assume that only are times, namely \mathcal{T}_\mathrm{D} = \{a,c\}. The associated firing delays are \bm v = \begin{bmatrix}v_a \\ v_c\end{bmatrix}.

+

For convenience we relabel the firing times of the transitions. Instead of t_{a,k} we will use a_k, and similarly s_k, and c_k. Application of Equation 2 and Equation 1 gives +\begin{aligned} +a_k &= a_{k-1} + v_{a,k},\quad k=1,2,\ldots,\quad a_0 = 0\\ +s_k &= \max\{\pi_{Q,k},\pi_{I,k}\}\\ +c_k &= \pi_{B,k} + v_{c,k}\\ +\pi_{Q,k} &= a_{k},\quad k=1,2,\ldots\\ +\pi_{I,k} &= c_{k-1},\quad k= 2, \ldots, \quad \pi_{I,0}=1\\ +\pi_{B,k} &= s_{k},\quad k=1,2,\ldots\\ +\end{aligned} +

+

Combining gives the desired update equations +\begin{aligned} +a_k &= a_{k-1} + v_{a,k},\quad k=1,2,\ldots,\quad a_0 = 0\\ +s_k &= \max\{a_{k},c_{k-1}\}\\ +c_k &= s_{k} + v_{c,k}\\ +&= \max\{a_{k},c_{k-1}\} + v_{c,k},\quad k=1,\ldots, \quad c_0=0 +\end{aligned} +

+

The time of completing the kth task is given by the time at which the previous task was completed and the time needed to complete the kth task itself, unless there is a gap in the queue after finishing the previous task, in which case the server must wait for the next task to arrive.

+
+

Example 3 (Timed Petri net for synchronization of train lines) We consider three closed rail tracks and two stations as in Fig 3.

+
+
+
+ +
+
+Figure 3: Example with three train lines +
+
+
+

Departure of a train at a station must be synchronized with arrival of the other train so that passengers can change train. The timed Petri net for this system is shown in Fig 4.

+
+
+
+ +
+
+Figure 4: Timed Petri net for the example of synchronization of three train lines +
+
+
+

If time is associated with the places, the Petri net simplifies significantly to Fig 5.

+
+
+
+ +
+
+Figure 5: Timed Petri net for the example of synchronization of three train lines +
+
+
+
+
+

Example 4 (Manufacturing) tbd

+
+
+
+

Extensions

+
+

Stochastic Petri nets (SPN)

+

Numerous extensions are possible, some of which we have already mentioned when discussing untimed Petri nets. But upon introducing time, stochastic Petr nets can be concived, in which delays are random variables.

+ + +
+
+ + Back to top
+ + +
+ + + + + + \ No newline at end of file diff --git a/petri_nets_timed.html b/petri_nets_timed.html index 15c42df..4ce3796 100644 --- a/petri_nets_timed.html +++ b/petri_nets_timed.html @@ -2,7 +2,7 @@ - + @@ -37,10 +37,10 @@ - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Recap of stability analysis for continuous dynamical systems

+
+ + + +
+ + + + +
+ + + +
+ + +

Before we start discussing stability of hybrid dynamical systems, it will not hurt to recapitulate the stability analysis for continuous (both in value and in time) dynamical systems modelled by the standard state equation

+

\dot{\bm{x}} = \mathbf f(\bm x).

+
+

Equilibrium

+

Although every now and then we may hear the term stability attributed to a system, strictly speaking it is an equilibrium that is stable or unstable.

+

Equilibrium is a point in the state space, that is, a vector x_\mathrm{eq}\in \mathbb R^n, such that

+

\dot{\bm x} = \mathbf f(\bm x_\mathrm{eq}) = \mathbf 0.

+

Without loss of generality \bm x_\mathrm{eq} = \mathbf 0. If it is nonzero, we can introduce a new shifted state vector.

+
+
+

Lyapunov stability

+

One of the most common types of stability is Lyapunov stability. Loosely speaking, it means that if the system starts close to the equilibrium, it stays close to it. More formally, for a given \varepsilon>0, there is a \delta>0 such that …

+
+
+

Attractivity

+

This is another property of an equilibrium. If it is (locally) attractive, it means that if the systems starts close to the equilibrium, it will converge to it. The global version of attractivity means that the system asymptotically converges to the equilibrium from anywhere.

+

Perhaps it is not immediately clear that attractivity is distinct from (Lyapunov) stability. The following example shows an attractive but Lyapunov unstable equilibrium.

+
+
+Show the code +
f(x) = [(x[1]^2*(x[2]-x[1])+x[2]^5)/((x[1]^2+x[2]^2)*(1+(x[1]^2+x[2]^2)^2)); 
+        (x[2]^2*(x[2]-2x[1]))/((x[1]^2+x[2]^2)*(1+(x[1]^2+x[2]^2)^2))]
+
+using CairoMakie
+fig = Figure(; size = (800, 800),fontsize=20)
+ax = Axis(fig[1, 1], xlabel = "x₁", ylabel = "x₂")
+streamplot!(ax,x->Point2f(f(x)), -1.5..1.5, -1.5..1.5, colormap = :magma)
+fig
+
+
+
+
+

+
+
+
+
+
+
+

Asymptotic stability

+

Combination of Lyapunov stability and attractivity is called assymptotic stability.

+

If the attractivity is global, the assymptotic stability is called global too.

+
+
+

Exponential stability

+

Exponential convergence.

+
+
+

Stability of time-varying systems

+

Stability (Lyapunov, asymptotic, …) is called uniform, if it is independent of the inititial time.

+
+
+

Stability analysis via Lyapunov function

+

Now that we recapitulated the key stability concepts, it is time to recapitulate the methods of checking if this or that type of stability is achieved. The classical method is based on the searching for a Lyapunov function.

+

Lyapunov function is a scalar function V(\cdot)\in\mathcal{C}_1 defined on open \mathcal{D}\subset \mathbb{R}^n containing the origin (the equilibrium) that satisfies the following conditions V(0) = 0, \; V(x) > 0\, \text{for all}\, x\in \mathcal{D}\setminus \{0\},

+

\underbrace{\left(\nabla V(x)\right)^\top f(x)}_{\frac{\mathrm d}{\mathrm d t}V(x)} \leq 0.

+

In words, Lyapunov function for a given system and the equilibrium is a function that is positive everywhere except at the origin, where it is zero, we call such function positive definite, and its derivative along the trajectories of the system is nonpositive (aka positive semidefinite), which is a way to guarantee that the function does not increase along the trajectories. If such function exists, the equilibrium is Lyapunov stable.

+

If the latter condition is made strict, that is, if \left(\nabla V(x)\right)^\top f(x) < 0, which is a way to guarantee that the function decreases along the trajectories, the equilibrium is asymptotically stable.

+

The interpretation is quite intuitive:

+
+
+

LaSalle’s invariance principle

+

A delicate question is if the derivative of the Lyapunov function ocassionally vanishes, it it automatically means that the equilibrium is not assymptotically stable. The aswer is: not necessarily. LaSalle’s invariance principle states that even if the derivative of the Lyapunov function occasionally vanishes, the equilibrium can still be asymptotically stable, provided some condition is satisfied. We will not elaborate on it here. Look it up in your favourite nonlinear (control) system textbook.

+
+
+

Formulated using comparison functions

+

The above properties of the Lyapunov function be also be formulated using comparison functions. For Lyapunov stability, the following holds \kappa_1(\|x\|) \leq V(x) {\color{gray}\leq \kappa_2(\|x\|)}, where

+
    +
  • \kappa_1(\cdot), \kappa_2(\cdot) are class \mathcal{K} comparison functions, that is, they are continuous, zero at zero and (strictly) increasing.
  • +
  • If \kappa_1 increases to infinity (\kappa_1(\cdot)\in\mathcal{K}_\infty), the stability is global.
  • +
+

For asymptotic stability

+

\left(\nabla V(x)\right)^\top f(x) \leq -\rho(\|x\|), where \rho(\cdot) is a positive definite continuous function, zero at the origin.

+
+

The upper bound \kappa_2(\cdot) does not have to be there, it is automatically satisfied for time-invariant systems. It does have to be imposed for time-varying systems though.

+
+
+
+

Exponential stability

+

k_1 \|x\|^p \leq V(x) \leq k_2 \|x\|^p,

+

\left(\nabla V(x)\right)^\top f(x) \leq -k_3 \|x\|^p.

+
+
+

Exponential stability with quadratic Lyapunov function

+

+V(x) = x^\top P x +

+

\lambda_{\min} (P) \|x\|^2 \leq V(x) \leq \lambda_{\max} (P) \|x\|^2

+
+
+

Converse theorems

+
    +
  • for (G)UAS,
  • +
  • for Lyapunov stability only time-varying Lyapunov function guaranteed.
  • +
+ + +
+ + Back to top
+ + +
+ + + + + + \ No newline at end of file diff --git a/stability_recap.html b/stability_recap.html index 355bed3..b701933 100644 --- a/stability_recap.html +++ b/stability_recap.html @@ -2,7 +2,7 @@ - + @@ -71,10 +71,10 @@ - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Stability via multiple Lyapunov functions

+
+ + + +
+ + + + +
+ + + +
+ + +
+

Example: CQLF cannot be found

+
+

Example 4.11 from Lin & Antsaklis (2022)

+
+
+
+

Multiple Lyapunov Function (MLF) approach to analysis of stability

+
    +
  • Not just a single common Lyapunov function V(\bm x).
  • +
  • Instead, several Lyapunov-like functions V_i(\bm x),\; i=1,\ldots,r, that are Lyapunov on some subsets of the state space \Omega_i.
  • +
  • Stitch them together to form +V(x) = +\begin{cases} +V_1(x) & \text{if } x\in \Omega_1, \\ +\vdots\\ +V_r(x) & \text{if } x\in \Omega_r, \\ +\end{cases} +
  • +
+
+
+

S-procedure

+
    +
  • A result about solvability of two or more quadratic inequalities, not necessarily convex ones.

    +
      +
    • For convex problems we have nonlinear Farkas’ lemma.
    • +
  • +
  • Origin in the control theory (analysis of stability of nonlinear systems, hence the S letter) with the first rigorous result provided by Yakubovich in 1970s.

  • +
  • It gives conditions under which (satisfaction of) one quadratic inequality follows from (satisfaction of) another one (or more), that is, it gives a condition under which the following implication holds:

  • +
  • Quadratic inequality #1 satisfied by some x \Rightarrow Quadratic inequality #0 satisfied by the same x.

  • +
  • In other words, it gives a condition under which the solution set of the inequality #1 denoted as \mathcal X_1 is included in the solution set \mathcal X_0 of the inequality #0.

  • +
+
+
+

S-procedure with nonstrict inequalities

+
    +
  • Consider the general quadratic functions F_i(x) = x^\top A_i x + 2b_i^\top x + c_i, \; i=0,\ldots, p.

  • +
  • Question: under which conditions F_0(x) \geq 0 for all x satisfying F_i(x)\geq 0,\; i=1,\ldots,p ?

  • +
  • In other words, we are looking for conditions under which the implication +F_i(x) \geq 0,\; i=1,\ldots,p \quad \Rightarrow \quad F_0(x) \geq 0 +
    +holds.

  • +
  • In the simplest (yet relevant) case n=1 we search for conditions under which F_0(x) \geq 0 for all x satisfying F_1(x)\geq 0,

  • +
  • that is, conditions under which the implication +F_1(x) \geq 0 \quad \Rightarrow \quad F_0(x) \geq 0 +
    +holds.

  • +
+
+
+

Sufficient conditions

+

The existence of \alpha_i\geq 0,\; i=1,\ldots,p such that +F_0(x)-\sum_{i=1}^p \alpha_i F_i(x) \geq 0. +

+
    +
  • Generally not necessary, the condition is conservative.
    +
  • +
  • It can be formulated as an LMI +\begin{bmatrix} +A_0 & b_0 \\ +b_0^\top & c_0 +\end{bmatrix} - +\sum_{i=1}^p +\alpha_i +\begin{bmatrix} +A_i & b_i \\ +b_i^\top & c_i +\end{bmatrix} +\succeq 0 +
    +where \alpha_i \geq 0,\; i=1,\ldots,p.
  • +
+
+
+

Sufficient and also necessary

+
    +
  • It is nontrivial that for p=1 it is also necessary, provided that there is some x_0 such that F_1(x_0)>0 .

  • +
  • Then we have the following equivalence between the two constraints: +\begin{aligned} +F_0(x) &\geq 0 \; \forall x \;\mathrm{satisfying}\; F_1(x)\geq 0 \\ +&\Longleftrightarrow \\ +F_0(x)-\alpha F_1(x) &\geq 0,\;\text{for some}\; \alpha\in\mathbb{R}, \; \alpha\geq 0, +\end{aligned} +

  • +
  • which again can be formulated as an LMI, namely
    + +\begin{bmatrix} +A_0 & b_0 \\ +b_0^\top & c_0 +\end{bmatrix} - \alpha +\begin{bmatrix} +A_1 & b_1 \\ +b_1^\top & c_1 +\end{bmatrix} +\succeq 0,\quad \alpha\geq 0. +

  • +
+
+
+

More on S-procedure

+
    +
  • There are several variants +
      +
    • strict, nonstrict or mixed inequalities,
    • +
    • just two or more,
    • +
    • some of the constraints can be equations.
    • +
  • +
  • Literature (freely available online) +
      +
    • Boyd, S., El Ghaoui, L., Feron, E., Balakrishnan, V., 1994. Linear Matrix Inequalities in System and Control Theory. SIAM. Pages 23 and 24.
    • +
    • Boyd, S., Vandenberghe, L., 2004. Convex Optimization. Cambridge University Press. Page 655.
    • +
  • +
+
+
+

Piecewise quadratic Lyapunov function

+
    +
  • Quadratic Lyapunov-like functions, that is, quadratic functions V_i(\bm x) = \bm x^\top \mathbf P_i \bm x that qualify as Lyapunov functions only on respective subsets \Omega_i\sub \mathbb R^n:
  • +
+

. . .

+

+V_i(\bm x) = \bm x^\top \mathbf P_i \bm x > 0\quad \forall \;\bm x\in \Omega_i +

+

. . .

+

+\dot V_i(\bm x) = \bm x^\top \left( \mathbf A_i^\top \mathbf P_i + \mathbf P_i \mathbf A_i \right) \bm x < 0\quad \forall \;\bm x\in \Omega_i +

+
+
+

Using comparison functions and nonstrict inequalities

+

. . .

+

+\alpha_1 \bm x^\top \mathbf I \bm x \leq \bm x^\top \mathbf P_i \bm x \leq \alpha_2 \bm x^\top \mathbf I \bm x \quad \forall \;\bm x\in \Omega_i +

+

. . .

+

+\bm x^\top \left( \mathbf A_i^\top \mathbf P_i + \mathbf P_i \mathbf A_i \right) \bm x \leq -\alpha_3 \bm x^\top \mathbf I \bm x\quad \forall \;\bm x\in \Omega_i +

+
+
+

Characterization of subsets of state space using LMI

+
    +
  • Some subsets \Omega_i\sub \mathbb R^n characterized using linear and quadratic inequalities can be formulated as within the LMI framework as + \bm x^\top \mathbf Q_i \bm x \geq 0. +

  • +
  • In particular, centered ellipsoids and cones.

  • +
  • For example,
    + +\begin{aligned} +\Omega_i &= \{\bm x \in \mathbb R^n \mid (\mathbf c^\top \bm x \geq 0 \land \mathbf d^\top \bm x \geq 0) \\ +& \qquad \qquad \qquad \lor (\mathbf c^\top \bm x \leq 0 \land \mathbf d^\top \bm x \leq 0)\}. +\end{aligned} +

  • +
  • This constraint can be reformulated as +(\mathbf c^\top \bm x) (\mathbf d^\top \bm x) \geq 0, +

  • +
  • which can be reformatted to +\bm x^\top \mathbf c \mathbf d^\top \bm x \geq 0, +

  • +
  • which can further be symmetrized to +\bm x^\top \left(\frac{\mathbf c \mathbf d^\top + \mathbf d \mathbf c^\top}{2}\right) \bm x \geq 0. +

  • +
  • More general sets (general polyhedra, noncentered ellipsoids) can also be modelled using LMI too…

  • +
+
+
+

Combining the subset characterization and Lyapunov-ness using the S-procedure

+

. . .

+

+\alpha_i \bm x^\top \mathbf I \bm x \leq \bm x^\top \mathbf P_i \bm x, +

+

. . .

+

+\bm x^\top \left( \mathbf A_i^\top \mathbf P_i + \mathbf P_i \mathbf A_i \right) \bm x \leq -\gamma_i \bm x^\top \mathbf I \bm x, +

+

. . .

+

both for all \bm x\in \Omega_i, that is, all \bm x such that \bm x^\top \mathbf Q_i \bm x \geq 0.

+

. . .

+

+\mathbf P_i - \alpha_i \mathbf I - \mu_i \mathbf Q_i \succeq 0,\quad \mu_i \geq 0,\; \alpha_i > 0, +

+

. . .

+

+\mathbf A_i^\top \mathbf P_i + \mathbf P_i \mathbf A_i + \gamma_i \mathbf I + \xi_i \mathbf Q \preceq 0,\quad \mu_i \geq 0,\; \gamma_i > 0. +

+
+
+

More general sets

+

. . .

+

+\bm x^\top \mathbf Q \bm x + 2\mathbf r^\top \bm x + s \geq 0 +

+

. . .

+

+\begin{bmatrix} +\bm x^\top & 1 +\end{bmatrix} +\underbrace{ +\begin{bmatrix} +\mathbf Q & \mathbf r \\ \mathbf r^\top & s +\end{bmatrix}}_{\bar{\mathbf{Q}}} +\underbrace{ +\begin{bmatrix} +\bm x \\ 1 +\end{bmatrix}}_{\bar{\bm x}} +\geq 0 +

+

. . .

+

+\begin{bmatrix} +\mathbf Q & \mathbf r \\ \mathbf r^\top & s +\end{bmatrix} +\succeq 0 +

+
+
+

Example: affine subspace

+

. . .

+

+\mathbf c^\top \bm x + d \geq 0 +

+

. . .

+

+\begin{bmatrix} +\bm x^\top & 1 +\end{bmatrix} +\begin{bmatrix} +\mathbf 0 & \mathbf c \\ \mathbf c^\top & 2d +\end{bmatrix} +\begin{bmatrix} +\bm x \\ 1 +\end{bmatrix} +\geq 0 +

+

. . .

+

+\begin{bmatrix} +\mathbf 0 & \mathbf c \\ \mathbf c^\top & 2d +\end{bmatrix} +\succeq 0 +

+
+
+

But then the Lyapunov-like functions and system matrices must also be extended

+

. . .

+

+V(\bm x) = +\begin{bmatrix} +\bm x^\top & 1 +\end{bmatrix} +\underbrace{ +\begin{bmatrix} +\mathbf P & \mathbf P_{12} \\ \mathbf P_{12} & P_{22} +\end{bmatrix}}_{\bar{\mathbf P}} +\begin{bmatrix} +\bm x \\ 1 +\end{bmatrix} +

+

. . .

+

+\bar{\mathbf{A}} = +\begin{bmatrix} +\mathbf A & \mathbf 0 \\ \mathbf 0 & 0 +\end{bmatrix} +

+
+
+

Continuity conditions

+
    +
  • The boundary between the regions \Omega_i and \Omega_j described by +\Omega_{ij} = \{\bm x \in \mathbb R^n \mid \mathbf F_{ij} \bm z + \mathbf{l}_{ij}\}, + where \bm z\in \mathbb R^p, \mathbf F_{ij}\in \mathbb R^{n\times p}, and \mathbf l_{ij}\in \mathbb R^{n}.

  • +
  • The continuity conditions are +V_i(\bm x) = V_j(\bm x) \quad \forall \bm x \in \Omega_{ij}, +

  • +
  • which can be reformulated as +\begin{aligned} +&\left(\mathbf F_{ij} \bm z + \mathbf{l}_{ij}\right)^\top \mathbf P_i \left(\mathbf F_{ij} \bm z + \mathbf{l}_{ij}\right) \\ +& \qquad + 2\left(\mathbf F_{ij} \bm z + \mathbf{l}_{ij}\right)^\top \bm q_i + r_i \\ +&= \left(\mathbf F_{ij} \bm z + \mathbf{l}_{ij}\right)^\top \mathbf P_j \left(\mathbf F_{ij} \bm z + \mathbf{l}_{ij}\right) \\ +& \qquad + 2\left(\mathbf F_{ij} \bm z + \mathbf{l}_{ij}\right)^\top \bm q_j + r_j +\end{aligned}. +

  • +
  • Collecting the terms with equal powers of \bm z. +\begin{aligned} +\mathbf F_{ij}^\top (\mathbf P_1 - \mathbf P_2) \mathbf F_{ij} &= 0, \\ +\mathbf F_{ij}^\top (\mathbf P_1 - \mathbf P_2) \mathbf l_{ij} + (\mathbf q_1-\mathbf q_2) &= 0, \\ +\mathbf l_{ij}^\top (\mathbf P_1 - \mathbf P_2)\mathbf l_{ij} + 2\mathbf l_{ij}^\top (\mathbf q_1-\mathbf q_2) + r_1-r_2 &= 0. +\end{aligned} +

  • +
+ + +
+ + Back to top
+ + +
+ + + + + + \ No newline at end of file diff --git a/stability_via_multiple_lyapunov_function.html b/stability_via_multiple_lyapunov_function.html index 7c84f1e..60357ad 100644 --- a/stability_via_multiple_lyapunov_function.html +++ b/stability_via_multiple_lyapunov_function.html @@ -2,7 +2,7 @@ - + @@ -37,10 +37,10 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

What is verification?

+
+ + + +
+ + + + +
+ + + +
+ + +

About…

+ + + + Back to top
+ + +
+ + + + + + \ No newline at end of file diff --git a/verification_intro.html b/verification_intro.html index 8773c73..af85c95 100644 --- a/verification_intro.html +++ b/verification_intro.html @@ -2,7 +2,7 @@ - + @@ -37,10 +37,10 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+

Literature

+
+ + + +
+ + + + +
+ + + +
+ + +

The topic of verification of hybrid systems is vast. While we only reserved a single week/chapter/block for it, it would easily fill a dedicated course, supported by a couple of books. Having a smaller time budget, we have still found some encouragement that modest introduction is feasible in the Chapter 3 of [1]. Although we are not following the book closely, we are covering some of their topics.

+

Among general references for hybrid system verification, we can recommend [2]. Although the book is not freely available for download, its web page contains quite some additional material such as slides and codes.

+
+

Reachability analysis

+

[3] [4]

+
+
+

Barier certificates

+

[5]

+
+
+

Temporal logics

+

[6], [7]

+

[8], [9].

+ + + +
+ + Back to top

References

+
+
[1]
H. Lin and P. J. Antsaklis, Hybrid Dynamical Systems: Fundamentals and Methods. in Advanced Textbooks in Control and Signal Processing. Cham: Springer, 2022. Accessed: Jul. 09, 2022. [Online]. Available: https://doi.org/10.1007/978-3-030-78731-8
+
+
+
[2]
S. Mitra, Verifying Cyber-Physical Systems: A Path to Safe Autonomy. in Cyber Physical Systems Series. Cambridge, MA, USA: MIT Press, 2021. Available: https://sayanmitracode.github.io/cpsbooksite/about.html
+
+
+
[3]
M. Althoff, G. Frehse, and A. Girard, “Set Propagation Techniques for Reachability Analysis,” Annual Review of Control, Robotics, and Autonomous Systems, vol. 4, no. 1, pp. 369–395, 2021, doi: 10.1146/annurev-control-071420-081941.
+
+
+
[4]
M. Althoff, N. Kochdumper, M. Wetzlinger, and T. Ladner, CORA 2024 Manual.” 2023. Accessed: Jan. 10, 2023. [Online]. Available: https://tumcps.github.io/CORA/data/archive/manual/Cora2024Manual.pdf
+
+
+
[5]
S. Prajna and A. Jadbabaie, “Safety Verification of Hybrid Systems Using Barrier Certificates,” in Hybrid Systems: Computation and Control, R. Alur and G. J. Pappas, Eds., in Lecture Notes in Computer Science. Berlin, Heidelberg: Springer, 2004, pp. 477–492. doi: 10.1007/978-3-540-24743-2_32.
+
+
+
[6]
C. Baier and J.-P. Katoen, Principles of Model Checking. Cambridge, MA, USA: MIT Press, 2008. Available: https://mitpress.mit.edu/books/principles-model-checking
+
+
+
[7]
E. M. Clarke, Jr, O. Grumberg, D. Kroening, D. Peled, and H. Veith, Model Checking, 2nd ed. in Cyber Physical Systems Series. Cambridge, MA, USA: MIT Press, 2018. Available: https://mitpress.mit.edu/9780262038836/model-checking/
+
+
+
[8]
R. M. Murray, U. Topcu, and N. Wongpiromsarn, “Lecture 3 Linear Temporal Logic (LTL).” Belgrade (Serbia), Mar. 2020. Available: http://www.cds.caltech.edu/~murray/courses/eeci-sp2020/L3_ltl-09Mar2020.pdf
+
+
+
[9]
N. Wongpiromsarn, R. M. Murray, and U. Topcu, “Lecture 4 Model Checking and Logic Synthesis.” Belgrade (Serbia), Mar. 2020. Available: http://www.cds.caltech.edu/~murray/courses/eeci-sp2020//L4_model_checking-09Mar2020.pdf
+
+
+ + +
+ + + + + + \ No newline at end of file diff --git a/verification_references.html b/verification_references.html index b517c59..baab2af 100644 --- a/verification_references.html +++ b/verification_references.html @@ -2,7 +2,7 @@ - + @@ -56,10 +56,10 @@ - + - + - + - +