Download presentation
Presentation is loading. Please wait.
Published byPatience Evans Modified over 9 years ago
1
Automata
2
Summary Deterministic Automata Languages Stochastic Automata Other Automata Formalisms Automata with input and output Protocol Representation with Finite State Automata (FSM) Timed Automata
3
Deterministic Automaton X is the state space E is the event set associated with G f: X E X is the transition function f(x,e)=y means that when G is at state x and event e occurs then G transitions to y Γ is the feasible event set. For every state x, Γ(x) is the set of all events that are active x 0 is the initial state X m is the set of marked states and is a subset of X
4
Example: Computer Basic Functions Design an automaton that describes the basic functions of a computer: down, waiting, processing State space D : down, I : Idle, B : Busy Event set f : failure, r : repair, a : job arrival, c : job completion Feasible event sets Γ(D)={r,a}, Γ(I)={a, f}, Γ(B)={f, a, c} Alternatively Γ(I)={a} (computer cannot fail when idle) Transition functions p(D, r)= I, p(D, a)=D p(I, a)= B, p(I, f)= D p(B, f)= D, p(B, a)= B, p(B, c)= I. Initial state x 0 = I
5
Example: Automaton Graphical Representation a c a a f r f IB D
6
Languages Generated by Automata a c a a f r 12 3 A language is a set of a finite length event strings to marked states L={a, aa, aaa, …, ac, aac, aca, acaa, ar, aar, ara,…}
7
Example: Automaton Graphical Representation a c a a f f IB D Now it is possible to create a deadlock. D is an absorbing state Suppose that the technician has resigned and it is no longer possible to fix the computer.
8
Example: Queueing What is an automaton model for simple FIFO queueing system? State space X={0, 1, 2, 3, …} Event set E={a, d} a : customer arrival, d : customer departure Feasible event sets Γ(0)={a}, Γ(x)={a, d}, x > 0 Transition functions f(x, a)= x+1 f(x, d)= x-1, if x > 0 Initial state x 0 = 0 ad State transition diagram a d a d a d a d … 0123
9
Non-Deterministic Automaton A non-deterministic automaton is similar to the deterministic except f nd : may probabilistically transition to a set of states. x 0 the initial state may also be a set of states. Example a b ba 12 3
10
Equivalent Deterministic Automaton For each non-deterministic automaton there is an equivalent automaton that generates the same language. a b ba 12 3 L={a, b, ab, ba. aba, bab, abab, baba, ababa, …} a b ab 12 3
11
Automata with Inputs/Outputs Each state “emits” an output symbol that is noted on the state Alternatively, each transition is marked with the event that triggers the transition and below it lists the actions that are taken as a result of the transition. 12 3 a c bd s1s1 s2s2 s3s3 12 3 a/s 2 b/s 2 c/s 3 d/s 1
12
Example of FSM Model for Protocol Verification (Stop and Wait Protocol) The transmitter sends a frame and stops waiting for an acknowledgement from the receiver (ACK) Once the receiver correctly receives the expected packet, it sends an acknowledgement to let the transmitter send the next frame. When the transmitter does not receive an ACK within a specified period of time (timer) then it retransmits the packet. Timer TransmitterReceiver Frame 0 Frame 1 ACK 0 ACK 1 Frame 0 ACK 0
13
FSM for Stop and Wait Protocol Transmitter Ack 1 Received Pkt 0 transmitted Ack 0 Received Pkt 1 transmitted Timeout or Ack 0 Received Timeout or Ack 1 Received Send Pkt 0 Send Pkt 1 Wait Ack 1 Wait Ack 0
14
FSM for Stop and Wait Protocol Receiver Pkt 0 received Send Ack 0 Pkt 1 received Send Ack 1 Pkt 0 Received Pkt 1 Received Wait Pkt 1 Wait Pkt 0 Send Ack 1 Send Ack 0
15
Timed Automata Models So far, the models we studied did not consider the time when an event occurred. For dynamic systems, the sample path of the system is specified by the sequence of pairs {(e i,t i )} where e i is the i -th event and t i is the time that the event has occurred. Timed automata are similar to the deterministic automata with the addition of a clock structure V is the clock structure X m (the set of marked states) is omitted for simplicity
16
Simple Example Assume a system with a single event, i.e., E={a} and Γ(x)={a} for all x X. We are interested for the sequence {(e i, t i )} where e i is the i -th event and t i is the time when e i occurs. t1t1 e 1 = a t k-1 e k-1 = a tktk e k = a t2t2 e 2 = a … t time vkvk zkzk ykyk v k = t k -t k-1 is the event lifetime z k = t - t k-1 is the age of event y k = t k - t is the residual lifetime
17
Simple Example with Two Events that are Always Feasible Assume a system with two events, i.e., E={a, b} and Γ(x)={a, b} for all x X. In addition we are given the sequences v a ={v a,1, v a,2,… }, v b ={v b,1, v b,2,… }, t1t1 e 1 = a time a b va1va1 vb1vb1 a b va2va2 yb1yb1 t2t2 e 2 = b a b ya2ya2 vb2vb2 t3t3 e 3 = b a b ya3ya3 vb3vb3 t4t4 e 4 = a x0x0 x1x1 x2x2 x3x3 x4x4 …
18
Example with Two Events that are NOT Always Feasible Assume that in the previous example that Γ(x)={a,b} for x {x 0, x 2, x 4 } Γ(x)={b} for x {x 1, x 3, } t1t1 e 1 = a time a b va1va1 vb1vb1 b yb1yb1 t2t2 e 2 = b a b va2va2 vb2vb2 t3t3 e 3 = b a b ya2ya2 vb3vb3 t4t4 e 4 = b x0x0 x1x1 x2x2 x3x3 x4x4 …
19
The Score of an Event The score N ik of an event i E after the k th state transition on a given sample path is the number of times that i has been activated (not occurred). t1t1 e 1 = a time a b va1va1 vb1vb1 a b va2va2 yb1yb1 t2t2 e 2 = b a b ya2ya2 vb2vb2 t3t3 e 3 = b a b ya3ya3 vb3vb3 t4t4 e 4 = b x0x0 x1x1 x2x2 x3x3 x4x4 … N a0 = N b0 =1 N a1 = 2 N b1 =1 N a2 = N b2 =2
20
The Event Timing Dynamics Notation x is the current state e is the event that caused the system to go into state x t is the time that the corresponding event occurred e ’ is the next event (triggering event) (clearly e ’ Γ(x) ) t ’ is the next event time (corresponding to e ’ ) x ’ is the next state given by x ’ = f(x, e ’ ). N ’ i is the next score of event i y ’ i is the next clock value of event i (after e ’ occurs)
21
The Event Timing Dynamics Step 1: Given x evaluate the feasible event set Γ(x) Step 2: From the clock value y i of all events i Γ(x) determine the minimum clock value y*= min i Γ(x) {y i } Step 3: Determine the triggering event e ’ = arg min i Γ(x) {y i } Step 4: Determine the next state x ’ = f(x, e ’ ) where f() is the state transition function.
22
The Event Timing Dynamics Step 5: Determine t ’ = t + y * Step 6: Determine the new clock values Step 7: Determine the new event scores
23
State Space Model The automaton timing dynamics can also be represented as a dynamical system … INPUT OUTPUT The initial conditions are given by x 0, N i,0 =1 for all i Γ(x 0 ) and N i,0 =0 for all i Γ(x 0 ) and y i = v i,1 for all i Γ(x 0 ). What represents the state variables of the system?
24
Example: Queueing Model State space X={0, 1, 2, 3, …} Event set E={a, d} a : customer arrival, d : customer departure Feasible event sets Γ(0)={a}, Γ(x)={a, d}, x > 0 Transition functions Initial state x 0 = 0 ad Clock structure V a ={0.5, 0.5, 1.0, 0.5, 2.0, 0.5, …} V d ={1.0, 1.5, 0.5, 0.5, 1.0, …} In general, the numbers of the clock structure are generated by a Random Number Generator
25
Example: Queueing Model time a b 0.5 Clock structure V a ={0.5, 0.5, 1.0, 0.5, 2.0, 0.5, …} V d ={1.0, 1.5, 0.5, 0.5, 1.0, …} 0.5 1 1.5 0.512 1 t=0t=0.5t=1t=1.5t=2t=2.5t=3t=3.5t=4t=4.5t=5
26
The Event Scheduling Scheme INITIALIZE EVENT CALENDAR e1e1 t1t1 e2e2 t2t2 … CLOCK STRUCTURE TIME STATE Update State x ’ =f(x,e 1 ) Update Time t ’ =t 1 Delete Infeasible Events Add New Feasible Events
27
Recall the Queueing System from Introduction System Input System Dynamics t u1(t)u1(t) t u2(t)u2(t) t x(t)x(t)
28
Time Driven vs. Event Driven Simulation Models Time Driven Dynamics Event Driven Dynamics State is updated only at the occurrence of a discrete event In this case, time is divided in intervals of length Δt, and the state is updated at every step
29
Example: Two Queues in Series Determine the automaton that describes the following network where the B 1 and B 2 have finite capacities of 3 and 2 packets respectively (including the customer in the server) When a customer departs from B 1 when B 2 is full, then the customer is lost! B1B1 B2B2 State x = [x 1, x 2 ] where x i denotes the number of customers in B i
30
State space X={[x 1, x 2 ] : x 1 = 0,…,3, x 2 = 0, 1, 2} Event set E={a, d 1, d 2 } Feasible event sets Γ([0,0])= {a}, Γ([0, x])={a, d 2 } if x > 0, Γ([x, 0])= {a, d 1 } if x > 0, Γ([x 1, x 2 ])= {a, d 1, d 2 } if x 1 > 0 and x 2 > 0. Transition functions Initial state x 0 = [0,0]. Example: Two Queues in Series ad2d2 B1B1 B2B2 d1d1
31
Communication Link How would you model a transmission link that can transmit packets at a rate G packets per second and has a propagation delay equal to 100ms? B1B1 B2B2 B1B1 … ?
32
Exercise Write a simulation program that imitates the behavior of the network shown below. The inputs to your program are the capacities of each buffer as well as the clock structure (three vectors with the lifetimes of each event) The output from your program is the sample path of the network i.e., the state trajectory and/or a “trace” consisting of a sequence of events and its corresponding time. B1B1 B2B2 ad1d1 d2d2
33
Example: Two Class FIFO Buffer Assume the queueing model shown below. The arrival process consists of two classes of customers (in general n classes) and each class has different priority as well as different service requirements. B1B1 a1a1 a2a2 d Define the following string operations Concatenation: [a 1,a 2,…,a m ] + [a m+1 ]= [a 1,a 2,…,a m, a m+1 ] Reduction: [a 1,a 2,…,a m ]\[a j ] = [a 1,…, a j-1, a j+1,…a m ] Head Reduction : [a 1,a 2,…,a m ]\1= [a 2,…,a m ]
34
Example: Two Class FIFO Buffer Event Set E={ a 1,a 2, d } State Space: X ={ x : {ε} { all possible permutations of a 1 and a 2 with length 0,…,K} } K is the buffer size Feasible Event set Γ(ε)={a 1,a 2 } and Γ(x)={a 1,a 2,d} for all other states x Transition Functions f(x, a 1 )= x + {a 1 } f(x, a 2 )= x + {a 2 } f(x, d)= x\1 for all x {ε}. Initial State : x 0 = ε.
35
Exercise Consider the two class FIFO buffer from the previous example and determine how you would simulate the following policies Threshold policy (with threshold B < K ) When a high priority customer arrives (e.g. a 1 ), it is accommodated as long as there is enough buffer space, i.e., as long as |x| < K where |x| is the “cardinality” of the set x, (the number of elements in x or 0 if x=ε ). When a low priority customer arrives (e.g. a 2 ), it is accommodated only if the number of customers currently in the queue does not exceed B, i.e., as long as |x| < B. Push-out Policy When a low priority customer arrives, it is accommodated if |x| < K. When a high priority customer arrives, it is accommodated at the end of the queue if |x| < K. However, if |x| = K then, the last low priority customer from the queue (if one is present) is removed and the new customer is accommodated the at the tail of the queue.
36
Single Queue Simulation Pseudo-code InitializeSimulator(); While !end_of_simulation event= GetNextEvent(); time= event(time); Switch(event(type)) case ‘a’: onArr(); case ‘d’: onDep(); EndSwitch; EndWhile; ad onArr() first=UpdateState(); ActivateNextArr(); If(first) ActivateNextDep(); End onDep() empty=UpdateState(); If(!empty) ActivateNextDep(); End
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.