Petri Nets 1. Finite State Automata 2. Petri net notation and - - PowerPoint PPT Presentation

petri nets
SMART_READER_LITE
LIVE PREVIEW

Petri Nets 1. Finite State Automata 2. Petri net notation and - - PowerPoint PPT Presentation

Petri Nets 1. Finite State Automata 2. Petri net notation and definition (no dynamics) 3. Introducing State: Petri net marking 4. Petri net dynamics 5. Capacity Constrained Petri nets 6. Petri net models for . . . FSA Nondeterminism


slide-1
SLIDE 1

Petri Nets

  • 1. Finite State Automata
  • 2. Petri net notation and definition (no dynamics)
  • 3. Introducing State: Petri net marking
  • 4. Petri net dynamics
  • 5. Capacity Constrained Petri nets
  • 6. Petri net models for . . .
  • FSA
  • Nondeterminism
  • Data Flow Computation
  • Communication Protocols

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 1/69

slide-2
SLIDE 2
  • 7. Queueing Systems
  • 8. Petri nets vs. State Automata
  • 9. Analysis of Petri nets
  • Boundedness
  • Liveness and Deadlock
  • State Reachability
  • State Coverability
  • Persistence
  • Language Recognition
  • 10. The Coverability Tree
  • 11. Extensions: colour, time, . . .

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 2/69

slide-3
SLIDE 3

Finite State Automaton

(E, X, f, x0, F)

  • E is a finite alphabet
  • X is a finite state set
  • f is a state transition function,

f : X × E → X

  • x0 is an initial state, x0 ∈ X
  • F is the set of final states

Dynamics (x′ is next state): x′ = f(x, e)

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 3/69

slide-4
SLIDE 4

FSA graphical/visual notation: State Transition Diagram

Init End_1 End_0 1 1 1

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 4/69

slide-5
SLIDE 5

FSA Operational Semantics

/ <ANY> <ANY> <ANY> Current State 2 4 3 1 / <COPIED> <COPIED> <COPIED> Current State 2 4 3 1 <ANY> 1 / <ANY> <ANY> <ANY> <ANY> Current State 2 4 3 5 1

/ <COPIED> <COPIED> <COPIED> <COPIED> Current State 2 4 3 5 1

::= ::= ::=

Rule 1 (priority 3) Rule 2 (priority 1) Rule 3 (priority 2) Locate Initial Current State State Transition Local State Transition condition: matched(4).input == input[0] action: remove(input[0]) condition: matched(4).input == input[0] action: remove(input[0])

<COPIED> Current State 3 1 2

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 5/69

slide-6
SLIDE 6

Simulation steps

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 6/69

slide-7
SLIDE 7

Init End_1 End_0 1 1 1 Current State Init End_1 End_0 1 1 1 Current State Init End_1 End_0 1 1 1 Current State Init End_1 End_0 1 1 1 Current State

Rule 1 Rule 2 Rule 2 Rule 2 Final Action

"Accept Input"

input 0 input 1 input 0 end of input

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 7/69

slide-8
SLIDE 8

State Automaton

(E, X, Γ, f, x0)

  • E is a countable event set
  • X is a countable state space
  • Γ(x) is the set of feasible or enabled events

x ∈ X, Γ(x) ⊆ E

  • f is a state transition function,

f : X × E → X, only defined for e ∈ Γ(x)

  • x0 is an initial state, x0 ∈ X

(E, X, Γ, f)

  • mits x0 and describes a class of State Automata.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 8/69

slide-9
SLIDE 9

State Automata for Queueing Systems

Physical View Queue Cashier Departure Arrival Departure Queue Abstract View Cashier [ST distribution] [IAT distribution] Arrival

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 9/69

slide-10
SLIDE 10

State Automata for Queueing Systems: customer centered

...

1 2 3 4 5

a d a d a d a d a d a d

E = {a, d} X = {0, 1, 2, . . .} Γ(x) = {a, d}, ∀x > 0; Γ(0) = {a} f(x, a) = x + 1, ∀x ≥ 0 f(x, d) = x − 1, ∀x > 0

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 10/69

slide-11
SLIDE 11

State Automata for Queueing Systems: server centered (with breakdown)

I B

s c b r

D

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 11/69

slide-12
SLIDE 12

State Automata for Queueing Systems: server centered (with breakdown)

E = {s, c, b, r} Events: s denotes service starts, c denotes service completes, b denotes breakdown, r denotes repair. X = {I, B, D} State: I denotes idle, B denotes busy, D denotes broken down. Γ(I) = {s}, Γ(B) = {c, b}, Γ(D) = {r} f(I, s) = B, f(B, c) = I, f(B, b) = D, f(D, r) = I

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 12/69

slide-13
SLIDE 13

Limitiations/extensions of State Automata

  • Adding time ?
  • Hierarchical modelling ?
  • Concurrency by means of ×
  • States are represented explicitly
  • Specifying control logic, synchronisation ?

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 13/69

slide-14
SLIDE 14

Petri nets

  • Formalism similar to FSA
  • Graphical/Visual notation
  • C.A. Petri 1960s
  • Additions to FSA:

– Explicitly (graphically/visually) represent when event is enabled → describe control logic – Elegant notation of concurrency – Express non-determinism

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 14/69

slide-15
SLIDE 15

Petri net notation and definition (no dynamics)

(P, T, A, w)

  • P = {p1, p2, . . .} is a finite set of places
  • T = {t1, t2, . . .} is a finite set of transitions
  • A ⊆ (P × T) ∪ (T × P) is a set of arcs
  • w : A → N is a weight function

Note: no need for countable P and T.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 15/69

slide-16
SLIDE 16

Derived Entities

  • I(tj) = {pi : (pi, tj) ∈ A} set of input places to transition tj

(≡ conditions for transition)

  • O(tj) = {pi : (tj, pi) ∈ A} set of output places from transition tj

(≡ affected by transition)

  • Transitions ≡ events
  • similarly: input- and output-transitions for pi
  • graphical/visual representation: Petri net graph (multigraph)

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 16/69

slide-17
SLIDE 17

Example Petri net

  • P = {H2, O2, H2O}
  • T = {t}
  • A = {(H2, t), (O2, t), (t, H2O)}
  • w((H2, t)) = 2, w((O2, t)) = 1, , w((t, H2O)) = 2

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 17/69

slide-18
SLIDE 18

Pure Petri net

  • No self-loops:

∃pi ∈ P, tj ∈ T : (pi, tj) ∈ A, (tj, pi) ∈ A

  • Can convert impure to pure Petri net

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 18/69

slide-19
SLIDE 19

Impure to Pure Petri net

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 19/69

slide-20
SLIDE 20

Introducing State: Petri net Markings

  • Conditions met ? Use tokens in places
  • Token assignment ≡ marking x

x : P → N

  • A marked Petri net

(P, T, A, w, x0) x0 is the initial marking

  • The state x of a marked Petri net

x = [x(p1), x(p2), . . . , x(pn)] Number of tokens need not be bounded (cfr. State Automata states).

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 20/69

slide-21
SLIDE 21

State Space of Marked Petri net

  • All n-dimensional vectors of nonnegative integer markings

X = Nn

  • Transition tj ∈ T is enabled if

x(pi) ≥ w(pi, tj), ∀pi ∈ I(tj)

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 21/69

slide-22
SLIDE 22

Example with marking, enabled

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 22/69

slide-23
SLIDE 23

Petri Net Dynamics

State Transition Function f of marked Petri net (P, T, A, w, x0) f : Nn × T → Nn is defined for transition tj ∈ T if and only if x(pi) ≥ w(pi, tj), ∀pi ∈ I(tj) If f(x, tj) is defined, set x′ = f(x, tj) where x′(pi) = x(pi) − w(pi, tj) + w(tj, pi)

  • State transition function f based on structure of Petri net
  • Number of tokens need not be conserved (but can)

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 23/69

slide-24
SLIDE 24

Example “firing”

  • Use PNS tool http://www.ee.uwa.edu.au/ braunl/pns/
  • Select Sequential Manual execution
  • Transition: [2, 2, 0] → [0, 1, 2]

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 24/69

slide-25
SLIDE 25

Example

  • order of firing not determined (due to untimed model)
  • selfloop
  • “dead” net

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 25/69

slide-26
SLIDE 26

Conflict, choice, decision

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 26/69

slide-27
SLIDE 27

Semantics

  • sequential vs. parallel
  • Handle nondeterminism:
  • 1. User choice
  • 2. Priorities
  • 3. Probabilities (Monte Carlo)
  • 4. Reachability Graph (enumerate all choices)

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 27/69

slide-28
SLIDE 28

Application: Critical Section

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 28/69

slide-29
SLIDE 29

Reachability Graph

[1,0,1,0,1] [0,1,0,0,1] [1,0,0,1,0] t1 t2 t1e t2e

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 29/69

slide-30
SLIDE 30

Algebraic Description of Dynamics

  • Firing vector u: transition j firing

u = [0, 0, . . . , 1, 0, . . . , 0]

  • Incidence matrix A :

aji = w(tj, pi) − w(pi, tj)

  • State Equation

x′ = x + uA

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 30/69

slide-31
SLIDE 31

Infinite Capacity Petri net

  • Add Capacity Constraint: K : P → N
  • New transition rule

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 31/69

slide-32
SLIDE 32

Can transform to infinite capacity net

  • 1. Add complimentary place p′ with initial marking x0(p′) = K(p)
  • 2. Between each transition t and complimentary places p′
  • add arcs (t, p′) or (p′, t) where
  • w(t, p′) = w(p, t)
  • w(p′, t) = w(t, p)

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 32/69

slide-33
SLIDE 33

Capacity Constrained Petri net

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 33/69

slide-34
SLIDE 34

Equivalence proof: use Reachability Graph

[1 , 0] [2 , 0] [0 , 0] [0 , 1] [1 , 1] [2 , 1] t1 t3 t2 t1 t2 t4 t4 t1 t1 [p1K2 , p2K1]

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 34/69

slide-35
SLIDE 35

Petri net as State Machine

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 35/69

slide-36
SLIDE 36

Representing a Petri net as a State Machine

Construct Reachability Graph

  • Reachability Graph is State Machine
  • States are tuples (p1, p2, . . . , pn)
  • Events correspond to ti firing
  • May be infinite

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 36/69

slide-37
SLIDE 37

Representing a State Machine as a Petri net

  • 1. no output
  • 2. with output

⇒ automatic (though inefficient) transformation

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 37/69

slide-38
SLIDE 38

FSA without output

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 38/69

slide-39
SLIDE 39

FSA with output

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 39/69

slide-40
SLIDE 40

Petri net models for Queueing Systems

Physical View Queue Cashier Departure Arrival Departure Queue Abstract View Cashier [ST distribution] [IAT distribution] Arrival

Capacity Constraints for Resource Conservation

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 40/69

slide-41
SLIDE 41

Simple Server/Queue Model

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 41/69

slide-42
SLIDE 42

Model departure explicitly

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 42/69

slide-43
SLIDE 43

Model Server Breakdown

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 43/69

slide-44
SLIDE 44

Modular Composition: Communication Protocol

Build incrementally:

  • 1. Single transmitter: FSA vs. Petri net
  • 2. Two transmitters competing for channel

Pros/Cons of Petri net models (depends on goals !):

  • Petri net is more complex than FSA for single transmitter
  • More insight
  • Incremental modelling
  • Modular modelling
  • Intuitive modelling of concurrency

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 44/69

slide-45
SLIDE 45

Single Transmitter FSA

I M T Idle Message present Transmitting ack received arr arr arr transmit timeout

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 45/69

slide-46
SLIDE 46

Single Transmitter Petri net

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 46/69

slide-47
SLIDE 47

Concurrent, Non-interacting Transmitters

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 47/69

slide-48
SLIDE 48

Concurrent, Interacting Transmitters

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 48/69

slide-49
SLIDE 49

Analysis of Petri nets

Analysis of logical or qualitative behaviour. Resource sharing ⇒ fair usage of resources:

  • Boundedness
  • Conservation
  • Liveness and Deadlock
  • State Reachability
  • State Coverability
  • Persistence
  • Language Recognition

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 49/69

slide-50
SLIDE 50

Boundedness

  • Example: upper bound on number of customers in queue.
  • Definition: A place pi ∈ P in a Petri net with initial state x0 is

k−bounded or k−safe if x(pi) ≤ k for all states in all possible sample paths.

  • A 1−bounded place is called safe.
  • If a place is k−bounded for some k, the place is bounded.
  • If all places are bounded, the Petri net is bounded.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 50/69

slide-51
SLIDE 51

Bounded vs. Unbounded

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 51/69

slide-52
SLIDE 52

Conservation

Token represents resource, process, . . . Sum Busy + Idle tokens must be constant for all states in all sample paths

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 52/69

slide-53
SLIDE 53

Conservation, weighted sum

2 Transm + Idle + trsChannel = constant

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 53/69

slide-54
SLIDE 54

Conservation

A Petri net with initial state x0 is conservative with respect to γ = [γ1, γ2, . . . , γn] if Σn

i=1γix(pi) = constant

for all states in all possible sample paths.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 54/69

slide-55
SLIDE 55

Liveness and Deadlock

  • Cyclic dependency ⇒ wait indefinitely
  • Deadlock
  • Deadlock avoidance: avoid certain states in sample paths

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 55/69

slide-56
SLIDE 56

Deadlock in Queueing system with Rework

[QueueFree, Queue1, Rework] = [0, 1, 1]

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 56/69

slide-57
SLIDE 57

Deadlock resolved

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 57/69

slide-58
SLIDE 58

Liveness

Given initial state x0, a transition in a Petri net is:

  • L0-live (dead): if the transition can never fire.
  • L1-live: if there is some firing sequence from x0 such that the

transition can fire at least once.

  • L2-live: if the transition can fire at least k times for some given

positive integer k.

  • L3-live: if there exists some infinite firing sequence in which the

transition appears infinitely often.

  • L4-live: if the transition is L1-live for every possible state reached

from x0.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 58/69

slide-59
SLIDE 59

Liveness example

  • t1 is L1-live;
  • t2 is dead;
  • t3 is L3-live, not L4-live.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 59/69

slide-60
SLIDE 60

State Reachability

  • A state x in a Petri net is reachable from a state x0 if there exists

a sequence of transitions starting at x0 such that the state eventually becomes x.

  • Build/use reachability graph.
  • Deadlock avoidance is a special case of reachability.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 60/69

slide-61
SLIDE 61

State Coverability

  • In a Petri net with initial state x0, a state y is coverable if there

exists a sequence of transitions starting at x0 such that the state eventually becomes x and x(pi) ≥ y(pi).

  • Related to L1-liveness: minimum number of tokens required to

enable a transition.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 61/69

slide-62
SLIDE 62

Persistence

  • More than one transition enabled by the same set of conditions

(choice, undeterminism).

  • If one fires, does the other remain enabled ?
  • A Petri net is persistent if, for any two enabled transitions, the

firing of one cannot disable the other.

  • Non-interruptedness (of multiple processes).

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 62/69

slide-63
SLIDE 63

Language Recognition

Language defined by Petri net ≡ set of transition sequences which can fire

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 63/69

slide-64
SLIDE 64

Coverability Notation

  • Root node
  • Terminal node
  • Duplicate node

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 64/69

slide-65
SLIDE 65

Coverability Notation

  • Node dominance

x = [x(p1), x(p2), . . . , x(pn)] y = [y(p1), y(p2), . . . , y(pn)] x >d y (x dominates y)if

  • 1. x(pi) ≥ y(pi), ∀i ∈ {1, . . . , n}
  • 2. x(pi) > y(pi) for at least some i ∈ {1, . . . , n}
  • The symbol ω represents infinity

x >d y For all i such that x(pi) > y(pi), replace x(pi) by ω ω + k = ω = ω − k

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 65/69

slide-66
SLIDE 66

Coverability Tree Construction

  • 1. Initialize x = x0 (initial state)
  • 2. Fore each new node x,

evaluate the transition function f(x, ti) for all tj ∈ T: (a) if f(x, tj) is undefined for all tj ∈ T, then x is a terminal node. (b) if f(x, tj) is defined for some tj ∈ T, create a new node x′ = f(x, tj).

  • i. if x(pi) = ω for some pi, set x′(pi) = ω.
  • ii. If there exists a node y in the path from root node x0

(included) to x such that x′ >d y, set x′(pi) = ω for all pi such that x′(pi) > y(pi)

  • iii. Otherwise, set x′ = f(x, tj).
  • 3. Stop if all new nodes are either terminal or duplicate

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 66/69

slide-67
SLIDE 67

Coverability Tree Example: Cashier/Queue

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 67/69

slide-68
SLIDE 68

Coverability Tree Example: Cashier/Queue

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 68/69

slide-69
SLIDE 69

Applications of the Coverability Tree

  • Boundedness: ω does not appear in coverability tree
  • Bounded Petri net ⇒ reachability graph
  • Conservation: γi = 0 for ω positions
  • Inverse problem: what are γ and C ?
  • Coverability: inspect coverability tree
  • Limitations: deadlock detection

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation: Petri Nets 69/69