1 / 36

Automata

Automata. Summary . Deterministic Automata Languages Stochastic Automata Other Automata Formalisms Automata with input and output Protocol Representation with Finite State Automata (FSM) Timed Automata. Deterministic Automaton. X is the state space

montana
Download Presentation

Automata

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 • x0 is the initial state • Xm 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 x0= I

  5. Example: Automaton Graphical Representation a I B a c f r f D a

  6. Languages Generated by Automata a 1 2 a c r f 3 a • 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 I B a c f f D a • Suppose that the technician has resigned and it is no longer possible to fix the computer. • Now it is possible to create a deadlock. • D is an absorbing state

  8. Example: Queueing a d a a a a 0 1 2 3 … d d d d • 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 x0= 0 • State transition diagram

  9. Non-Deterministic Automaton a b 1 2 a 3 b • A non-deterministic automaton is similar to the deterministic except • fnd: may probabilistically transition to a set of states. • x0 the initial state may also be a set of states. • Example

  10. Equivalent Deterministic Automaton 1 2 1 2 a b b a 3 3 a a b b • For each non-deterministic automaton there is an equivalent automaton that generates the same language. L={a, b, ab, ba. aba, bab, abab, baba, ababa, …}

  11. Automata with Inputs/Outputs s1 s2 a a/s2 1 1 2 2 c c/s3 d/s1 b/s2 d b 3 3 s3 • 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. Example of FSM Model for Protocol Verification(Stop and Wait Protocol) Transmitter Receiver Frame 0 ACK 0 Frame 1 ACK 1 Frame 0 Timer Timer ACK 0 • 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.

  13. FSM for Stop and Wait Protocol Send Pkt 0 Ack 1 Received Pkt 0 transmitted Timeout or Ack 1 Received Wait Ack 0 Wait Ack 1 Timeout or Ack 0 Received Ack 0 Received Pkt 1 transmitted Send Pkt 1 • Transmitter

  14. FSM for Stop and Wait Protocol Wait Pkt 1 Wait Pkt 0 Pkt 0 Received Pkt 1 Received • Receiver Pkt 0 received Send Ack 0 Send Ack 0 Send Ack 1 Pkt 1 received Send Ack 1

  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 {(ei,ti)} where ei is the i-th event and ti 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 • Xm (the set of marked states) is omitted for simplicity

  16. Simple Example e1 = a e2 = a ek-1 = a ek = a t time t1 t2 tk-1 tk zk yk vk • Assume a system with a single event, i.e., E={a} and Γ(x)={a} for all xX. We are interested for the sequence {(ei, ti)} where ei is the i-th event and ti is the time when ei occurs. … • vk= tk-tk-1 is the event lifetime • zk= t - tk-1 is the age of event • yk= tk - t is the residual lifetime

  17. Simple Example with Two Events that are Always Feasible e1 = a e4 = a e3 = b e2 = b t1 t4 t3 t2 time • 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 va={va,1, va,2,… }, vb={vb,1, vb,2,… }, … x0 x1 x2 x3 x4 a va1 b vb1 a va2 b yb1 a ya2 b vb2 a ya3 b vb3

  18. Example with Two Events that are NOT Always Feasible e1 = a e4 = b e3 = b e2 = b t1 t4 t3 t2 time • Assume that in the previous example that Γ(x)={a,b} for x{x0, x2, x4} Γ(x)={b} for x{x1 ,x3,} … x0 x1 x2 x3 x4 a va1 b vb1 b yb1 a va2 b vb2 a ya2 b vb3

  19. The Score of an Event e3 = b e1 = a e2 = b e4 = b t4 t1 t3 t2 time • The score Nik of an event iE after the kth state transition on a given sample path is the number of times that i has been activated (not occurred). … x0 x1 x2 x3 x4 a va1 b vb1 a va2 b yb1 a ya2 b vb2 Na0 = Nb0=1 a ya3 Na1 = 2 Nb1=1 b vb3 Na2 = Nb2=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 nextevent (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’iis the next score of event i • y’iis 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 yi of all events iΓ(x) determine the minimum clock value y*= miniΓ(x){yi} • Step 3: Determine the triggering event e’= arg miniΓ(x){yi} • 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 … INPUT OUTPUT • The automaton timing dynamics can also be represented as a dynamical system • The initial conditions are given by x0, Ni,0=1 for all iΓ(x0) and Ni,0=0 for all iΓ(x0) and yi= vi,1 for all iΓ(x0). • What represents the state variables of the system?

  24. Example: Queueing Model a d • Feasible event sets • Γ(0)={a}, • Γ(x)={a, d}, x > 0 • Transition functions • Initial state x0= 0 • State space • X={0, 1, 2, 3, …} • Event set • E={a, d} • a: customer arrival, • d: customer departure • Clock structure • Va ={0.5, 0.5, 1.0, 0.5, 2.0, 0.5, …} • Vd ={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 0.5 0.5 1 0.5 2 0.5 a 1.5 0.5 0.5 1 1 b • Clock structure • Va={0.5, 0.5, 1.0, 0.5, 2.0, 0.5, …} • Vd={1.0, 1.5, 0.5, 0.5, 1.0, …} t=0 t=0.5 t=1 t=1.5 t=2 t=2.5 t=3 t=3.5 t=4 t=4.5 t=5

  26. The Event Scheduling Scheme STATE TIME EVENT CALENDAR e1 t1 Update Time t’=t1 Update State x’=f(x,e1) e2 t2 … Delete Infeasible Events Add New Feasible Events CLOCK STRUCTURE INITIALIZE

  27. Recall the Queueing System from Introduction • System Dynamics • System Input u1(t) t u2(t) t x(t) t

  28. Time Driven vs. Event Driven Simulation Models • Time Driven Dynamics • Event Driven Dynamics • In this case, time is divided in intervals of length Δt, and the state is updated at every step • State is updated only at the occurrence of a discrete event

  29. Example: Two Queues in Series B1 B2 • Determine the automaton that describes the following network where the B1 and B2have finite capacities of 3 and 2 packets respectively (including the customer in the server) • When a customer departs from B1 when B2 is full, then the customer is lost! • State x = [x1, x2] where xi denotes the number of customers in Bi

  30. Example: Two Queues in Series B1 B2 a d1 d2 • State space • X={[x1, x2] : x1= 0,…,3, x2 = 0, 1, 2} • Event set • E={a, d1, d2} • Feasible event sets • Γ([0,0])= {a}, Γ([0, x])={a, d2} if x > 0, Γ([x, 0])= {a, d1} if x > 0, • Γ([x1, x2])= {a, d1, d2} if x1 > 0 and x2 > 0. • Transition functions • Initial state x0= [0,0].

  31. Communication Link B1 B2 B1 … • 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? ?

  32. Exercise B1 B2 • 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. a d1 d2

  33. Example: Two Class FIFO Buffer a1 B1 d a2 • 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. • Define the following string operations • Concatenation: [a1,a2,…,am] + [am+1]= [a1,a2,…,am, am+1] • Reduction: [a1,a2,…,am]\[aj] = [a1,…, aj-1 , aj+1 ,…am] • Head Reduction: [a1,a2,…,am]\1= [a2,…,am]

  34. Example: Two Class FIFO Buffer • Event Set • E={a1,a2,d} • State Space: • X={ x : {ε} {all possible permutations of a1 and a2 with length 0,…,K}} • K is the buffer size • Feasible Event set • Γ(ε)={a1,a2} and Γ(x)={a1,a2,d} for all other statesx • Transition Functions • f(x, a1)= x + {a1} • f(x, a2)= x + {a2} • f(x, d)= x\1 for all x {ε}. • Initial State: x0 = ε.

  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. a1), 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. a2), 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 a d • onArr() • first=UpdateState(); • ActivateNextArr(); • If(first) ActivateNextDep(); • End • InitializeSimulator(); • While !end_of_simulation • event= GetNextEvent(); • time= event(time); • Switch(event(type)) • case ‘a’: onArr(); • case ‘d’: onDep(); • EndSwitch; • EndWhile; • onDep() • empty=UpdateState(); • If(!empty) ActivateNextDep(); • End

More Related