CIS 4930/6930: Principles of Cyber-Physical Systems Chapter 4: Hybrid Systems Hao Zheng Department of Computer Science and Engineering University of South Florida H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 1 / 50
Hybrid Systems • Differential equations are used to model continuous dynamics. • State machines are used to model discrete dynamics. • Cyber-physical systems are hybrid systems that include both continuous and discrete dynamics. • Hybrid system models must represent continuous and discrete dynamics. H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 2 / 50
FSM Model i 1 o 1 ... ... o m i n H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 3 / 50
Hybrid System, or Modal Model i 1 o 1 ... ... o m i n Mode Continuous dynamics time-based system time-based system H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 4 / 50
A Thermostat Model with a Continuous-Time Input Signal H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 5 / 50
A Thermostat Model with a Continuous-Time Output Signal h H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 6 / 50
Timed Automata: Modeling and Analysis H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 7 / 50
Motivation • In time-critical systems, reactions must happen not only correctly but also timely. • Applications: • ABS in cars • Traffic control • Flight control • How is time modeled? Discrete or continuous? H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 8 / 50
Discrete Modeling of Time • Time is represented as multiples of basic units. • Leads to large state space. H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 9 / 50
Timed Automata: Overview • Time automata = FSMs extended with clock variables. • Clocks are dynamic variables that progress linearly in time. ∀ t ∈ T m , s ( t ) = 1 ˙ • s : R → R is a continuous-time signal, • s ( t ) is the value of the clock at time t , • All clocks progress synchronously. H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 10 / 50
Timed Automata: Syntax A timed automata is defined with (ignoring discrete variables) • L : a finite set of locations. • l 0 ∈ L : the initial location. • C : a finite set of clock variables. • A : a finite set of actions. • E : a finite set of edges connecting locations. • I : location invariants. For each e ∈ E , e = ( l 1 , α, cc , reset , l 2 ) where • α ∈ A is an action, • cc ∈ B ( C ) is a clock constraint, • reset ⊂ C is a subset of clocks to reset to 0. H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 11 / 50
Timed Automata: Clock Constraints: Syntax • In timed automata, only two operations can be applied to clocks • It is reset to 0, or • its value can read and tested for some condition. • Atomic clock constraints on clock variables x , y ∈ C , ⊳ c or x − y ⊲ x ⊲ ⊳ c where c is a rational constant, and ⊲ ⊳ ∈ { <, ≤ , >, ≥} . • Clock constraints B ( C ) is a set of conjunctions over the atomic clock constraints. • Examples: ≡ ( x ≤ c ) ∧ ( x ≥ c ) x = c H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 12 / 50
Timed Automata: Clock Constraints: Semantics Given a clock x ∈ C , let u : C → R ≥ 0 be an assignment of non-negative real numbers to clocks in C , and u ( x ) return the value of x ∈ C . u | = x ⊲ ⊳ c u ( x ) ⊲ ⊳ c iff u | = x − y ⊲ u ( x ) − u ( y ) ⊲ ⊳ c iff ⊳ c u | = cc 1 ∧ cc 2 u | = cc 1 ∧ u | = cc 2 iff Example: x = 0 . 5 , y = 1 . 39 | = ( x < 1) ∧ ( y ≤ 5) while x = 1 . 01 , y = 1 . 39 �| = ( x < 1) ∧ ( y ≤ 5) H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 13 / 50
Timed Automata: An Example A lamp has a button. When the button is pushed once, the lamp lights on at the low level. When the button is pushed twice in a row, the lamp lights on at the bright level. In either level, the lamp lights off when the button is pushed again. bright off low press? press? press? press? H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 14 / 50
Timed Automata: An Example y<5 bright off low press? press? y:=0 y>=5 press? press? H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 15 / 50
Timed Automata: Understand Time u ( x ) 45 40 35 30 25 20 l 0 x ≥ 10 / reset ( x ) 15 10 5 5 10 15 20 25 30 35 40 45 Time H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 16 / 50
Timed Automata: Understand Time u ( x ) 45 40 35 30 25 20 l 0 x ≥ 10 / reset ( x ) x ≤ 20 15 10 5 5 10 15 20 25 30 35 40 45 Time H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 17 / 50
Timed Automata: Understand Time u ( x ) 45 40 35 30 25 20 l 0 10 ≤ x ≤ 20 / reset ( x ) 15 10 5 5 10 15 20 25 30 35 40 45 Time H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 18 / 50
Timed Automata: Semantics H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 19 / 50
Transitions • A state of a timed automata is ( l , u ). • The initial state is ( l 0 , u 0 ). e − → ( l 2 , u 2 ) Discrete transition: ( l 1 , u 1 ) • An edge ( l 1 , α, cc , reset , l 2 ) ∈ E is enabled/executable in a state ( l , u ) if • l = l 1 , u | = cc , and • there is a matching synchronization action to a . • A new state ( l ′ , u ′ ) after executing e such that l ′ = l 2 , u ′ is the same as u except all clocks in reset reset to 0. δ → ( l , u 2 ) , δ ∈ R + Delay transition: ( l , u 1 ) − u 2 = u 1 + δ where u 1 + δ means u ( x ) + δ for every x ∈ C . H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 20 / 50
Execution Traces δ e • Execution step: − → = − → ∪ − → • Execution trace: ( l 0 , u 0 ) − → ( l 1 , u 1 ) − → ( l 2 , u 2 ) . . . • Reachability: ( i , u ) is reachable if there exists a trace ( l 0 , u 0 ) − → ( l 1 , u 1 ) . . . − → ( l n , u n ) such that l = l n and u = u n . H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 21 / 50
A Timed Automaton that Generates a Pure Output H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 22 / 50
Timed Automaton Model of a Thermostat h time to stay in heating time to stay in cooling H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 23 / 50
Possible Execution of the Timed Thermostat Model τ ( t ) ... t h (a) 20 t 1 t 1 + T h h ( t ) 1 ... t (b) 0 s ( t ) T c ... t (c) 0 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 24 / 50
FSM for the Traffic Light Controller It reacts in every second. H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 25 / 50
Timed Automaton for the Traffic Light Controller H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 26 / 50
Timed Automaton: Exercise x ≥ 1 / l 0 l 1 x ≤ 2 x ≤ 4 x ≥ 3 / x := 0 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 27 / 50
Zenoness A zeno trace of a timed automata has infinite number of discrete transitions within finite amount of time. x := 0 x := 0 l 0 l 1 l 0 l 1 x := 0 x := 0 x ≤ ∞ x ≤ 4 x = 0 x = 0 x ≥ 1 / x ≥ 1 / x := 0 x := 0 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 28 / 50
Eliminate Zenoness Make sure that time can progress on every cycle in timed automata. x := 0 l 1 x ≥ 1 / l 0 x ≤ 4 x = 0 x := 0 x ≥ 1 / x := 0 H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 29 / 50
Composing Timed Automata H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 30 / 50
Parallel Composition of Timed Automata Two TAs T 1 = ( L 1 , l 10 , C 1 , A 1 , E 1 , Inv 1 ) and T 2 = ( L 2 , l 20 , C 2 , A 2 , E 2 , Inv 2 ) such that C 1 ∩ C 2 = ∅ , their parallel composition, T 1 � T 2 is a TA ( L , l 0 , C , A , E , Inv ) where • L = L 1 × L 2 , • l 0 = ( l 10 , l 20 ); • C = C 1 ∪ C 2 , • A = A 1 ∪ A 2 , • Inv = I 1 ( l 1 ) ∧ I 2 ( l 2 ) for all ( l 1 , l 2 ) ∈ L , • E = { . . . } , H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 31 / 50
Parallel Composition of Timed Automata E includes edges defined as follows. ( l 1 , α, cc 1 , reset 1 , l ′ 1 ) ∈ E 1 ( l 2 , α, cc 2 , reset 2 , l ′ 2 ) ∈ E 2 Sync (( l 1 , l 2 ) , α, cc 1 ∧ cc 2 , reset 1 ∪ reset 2 , ( l ′ 1 , l ′ 2 )) ∈ E ( l 1 , α, cc 1 , reset 1 , l ′ 1 ) ∈ E 1 ∈ A 2 α / Async (( l 1 , l 2 ) , α, cc 1 , reset 1 , ( l ′ 1 , l 2 )) ∈ E ( l 2 , α, cc 2 , reset 2 , l ′ 2 ) ∈ E 2 α / ∈ A 1 Async (( l 1 , l 2 ) , α, cc 2 , reset 2 , ( l 1 , l ′ 2 )) ∈ E H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 32 / 50
A Lamp y<5 bright off low press? press? y:=0 y>=5 press? idle press! press? H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 33 / 50
A Classic Example H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 34 / 50
A Train-Gate-Control Example A road crosses a railway. In the cross, gates are controlled to block traffic on the road for safety. • Trains communicates with the controller about its position relative to the cross. Trains signal the controller with approach and exit . • The controller reacts to approach by signaling the gate with lower , and reacts to exit by signaling the gate with raise . • The gate reacts to lower by closing the gate, and reacts to raise by opening the gate. H. Zheng (CSE USF) CIS 4930/6930: Principles of CPS 35 / 50
Recommend
More recommend