Professional Documents
Culture Documents
l7 PetriNets
l7 PetriNets
• Petri nets
– Introduction
– Examples
– Properties
– Analysis techniques
1
EE249Fall04
Petri Nets (PNs)
2
EE249Fall04
Example:
Synchronization at single track rail segment
• „Preconditions“
3
EE249Fall04
Playing the „token game“
4
EE249Fall04
Conflict for resource „track“
5
EE249Fall04
Petri Net Graph
p1 t1 2
p4
3
t3
6
p3 EE249Fall04
Petri Net
• A PN (N,M0) is a Petri Net Graph N
– places: represent distributed state by holding tokens
– marking (state) M is an n-vector (m1,m2,m3…), where mi is the non-negative
number of tokens in place pi.
– initial marking (M0) is initial state
3
Places/Transitions: conditions/events t3
7 p3
EE249Fall04
Transition firing rule
• A marking is changed according to the following rules:
– A transition is enabled if there are enough tokens in each input place
– An enabled transition may or may not fire
– The firing of a transition modifies marking by consuming tokens from the
input places and producing tokens in the output places
2 2
2
2
3
3
8
EE249Fall04
Concurrency, causality, choice
t1
t2
t5
t3 t4
9
t6 EE249Fall04
Concurrency, causality, choice
t1
Concurrency
t2
t5
t3 t4
10
t6 EE249Fall04
Concurrency, causality, choice
t1
t2
t5
Causality, sequencing
t3 t4
11
t6 EE249Fall04
Concurrency, causality, choice
t1
t2
t5
Choice,
t3 t4 conflict
12
t6 EE249Fall04
Concurrency, causality, choice
t1
t2
t5
Choice,
t3 t4 conflict
13
t6 EE249Fall04
Communication Protocol
P1 P2
Send Ack
Receive Ack
14
EE249Fall04
Communication Protocol
P1 P2
Send Ack
Receive Ack
15
EE249Fall04
Communication Protocol
P1 P2
Send Ack
Receive Ack
16
EE249Fall04
Communication Protocol
P1 P2
Send Ack
Receive Ack
17
EE249Fall04
Communication Protocol
P1 P2
Send Ack
Receive Ack
18
EE249Fall04
Communication Protocol
P1 P2
Send Ack
Receive Ack
19
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
20
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
21
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
22
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
23
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
24
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
25
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
26
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
27
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
28
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
29
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
30
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
31
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
32
EE249Fall04
Producer-Consumer Problem
Produce
Buffer
Consume
33
EE249Fall04
Producer-Consumer with priority
A
Consumer B can
consume only if
buffer A is empty
Inhibitor arcs
34
EE249Fall04
PN properties
35
EE249Fall04
Reachability
p2
t2
p1 t1 p4
Μ0 = (1,0,1,0)
t3
M1 = (1,0,0,1)
t3
p3 t2
Μ0 = (1,0,1,0)
M = (1,1,0,0)
36
M = (1,1,0,0)
EE249Fall04
Liveness
Not live
37
EE249Fall04
Liveness
Not live
38
EE249Fall04
Liveness
Deadlock-free
39
EE249Fall04
Liveness
Deadlock-free
40
EE249Fall04
Boundedness
Unbounded
41
EE249Fall04
Boundedness
Unbounded
42
EE249Fall04
Boundedness
Unbounded
43
EE249Fall04
Boundedness
Unbounded
44
EE249Fall04
Boundedness
Unbounded
45
EE249Fall04
Conservation
Not conservative
46
EE249Fall04
Conservation
Not conservative
47
EE249Fall04
Conservation
Conservative
48
EE249Fall04
Analysis techniques
49
EE249Fall04
Incidence Matrix
t2
p1 t1 p2 p3
t1 t2 t3
t3 -1 0 0 p1
A= 1 1 -1 p2
0 -1 1 p3
• Necessary condition for marking M to be reachable from initial
marking M0:
there exists firing vector v s.t.:
M = M0 + A v
50
EE249Fall04
State equations
t2
p1 t1 p2 p3 -1 0 0
A= 1 1 -1
0 -1 1
t3
1 0 1 -1 0 0 1
v1 = 0 0 = 0 + 1 1 -1 0
1 1 0 0 -1 1 1
t2
t3
t1
2
2
Firing vector: (1,2,2) Deadlock!!
52
EE249Fall04
State equations and invariants
t2
p1 t1 p2 p3 -1 0 0
A= 1 1 -1
0 -1 1
53 t3
EE249Fall04
Application of T-invariants
• Scheduling
– Cyclic schedules: need to return to the initial state
i *k2 + o
*k1
T-invariant: (1,1,1,1,1)
Schedule: i *k2 *k1 + o
54
EE249Fall04
State equations and invariants
• Solutions of yA = 0
S-invariants
– sets of places whose weighted total token count does not change after
the firing of any transition (y M = y M’)
– e.g. y =| 1 1 1 |T
t2
p1 t1 p2 p3 -1 1 0
AT= 0 1 -1
0 -1 1
t3
55
EE249Fall04
Application of S-invariants
56
EE249Fall04
Summary of algebraic methods
• Extremely efficient
(polynomial in the size of the net)
• Generally provide only necessary or sufficient information
• Excellent for ruling out some deadlocks or otherwise
dangerous conditions
• Can be used to infer structural boundedness
57
EE249Fall04
Coverability Tree
Karp-Miller algorithm
• Label initial marking M0 as the root of the tree and tag it as new
• While new markings exist do:
– select a new marking M
– if M is identical to a marking on the path from the root to M, then tag M as old and go to
another new marking
– if no transitions are enabled at M, tag M dead-end
– while there exist enabled transitions at M do:
– obtain the marking M’ that results from firing t at M
– on the path from the root to M if there exists a marking M’’ such that M’(p)>=M’’(p) for each place
p and M’ is different from M’’, then replace M’(p) by ω for each p such that M’(p) >M’’(p)
– introduce M’ as a node, draw an arc with label t from M to M’ and tag M’ as new.
58
EE249Fall04
Coverability Tree
• Boundedness is decidable with coverability tree
1000
t2
p1 t1 p2 p3
p4
t3
59
EE249Fall04
Coverability Tree
• Boundedness is decidable with coverability tree
1000
t1
0100
t2
p1 t1 p2 p3
p4
t3
60
EE249Fall04
Coverability Tree
• Boundedness is decidable
with coverability tree 1000
t1
0100
t2
p1 t1 p2 p3 t3
0011
p4
t3
61
EE249Fall04
Coverability Tree
• Boundedness is decidable
with coverability tree 1000
t1
0100
t2
p1 t1 p2 p3 t3
0011
t2
p4 0101
t3
62
EE249Fall04
Coverability Tree
• Boundedness is decidable
1000
with coverability tree
t1
0100
t2
p1 t1 p2 p3 t3
0011
t2
t3 p4 010ω
63
EE249Fall04
Coverability Tree
• Is (1) reachable from (0)?
t1 p1 t2
t1 p1
2 2 t2
64
EE249Fall04
Coverability Tree
• Is (1) reachable from (0)?
t1 0
p1 t2
t1 (0) (1) (2)…
ω
t1 p1
2 2 t2
65
EE249Fall04
Coverability Tree
• Is (1) reachable from (0)?
t1 0
p1 t2
t1 (0) (1) (2)…
ω
t1 0
p1 2 t2
2 t1 (0) (2) (0)…
ω
66
EE249Fall04
Coverability Tree
• Is (1) reachable from (0)?
t1 0
p1 t2
t1 (0) (1) (2)…
ω
t1 0
p1 2 t2
2 t1 (0) (2) (0)…
ω
67
EE249Fall04
Reachability graph
t2
p1 t1 p2 p3 100
t3
68
EE249Fall04
Reachability graph
t2
p1 t1 p2 p3 100
t1
010
t3
69
EE249Fall04
Reachability graph
t2
p1 t1 p2 p3 100
t1
010
t3
t3
001
• For bounded nets the Coverability Tree is called Reachability
Tree since it contains all possible reachable markings
70
EE249Fall04
Reachability graph
t2
p1 t1 p2 p3 100
t1
010
t3
t2 t3
001
• For bounded nets the Coverability Tree is called Reachability
Tree since it contains all possible reachable markings
71
EE249Fall04
Subclasses of Petri nets
72
EE249Fall04
Marked Graphs
• Every place has at most 1 predecessor and 1 successor transition
• Models only causality and concurrency (no conflict)
NO
YES
73
EE249Fall04
State Machines
YES NO
74
EE249Fall04
Free-Choice Petri Nets (FCPN)
t2
Confusion (not-Free-Choice) Extended Free-Choice
Free-Choice: the outcome of a choice depends on the
value of a token (abstracted non-deterministically)
rather than on its arrival time.
75
EE249Fall04
Free-Choice nets
76
EE249Fall04
MG (& SM) decomposition
77
EE249Fall04
MG reduction and cover
78
EE249Fall04
MG reduction and cover
79
EE249Fall04
MG reduction and cover
• Choose one successor for each conflicting place:
80
EE249Fall04
MG reduction and cover
81
EE249Fall04
MG reduction and cover
82
EE249Fall04
MG reductions
• The set of all reductions yields a cover of MG components (T-
invariants)
83
EE249Fall04
MG reductions
• The set of all reductions yields a cover of MG components (T-
invariants)
84
EE249Fall04
MG reductions
• The set of all reductions yields a cover of MG components (T-
invariants)
85
EE249Fall04
Hack’s theorem (‘72)
86
EE249Fall04
Hack’s theorem
87
EE249Fall04
Hack’s theorem
88
EE249Fall04
Hack’s theorem
89
EE249Fall04
Hack’s theorem
90
EE249Fall04
Hack’s theorem
91
EE249Fall04
Hack’s theorem
92
EE249Fall04
Hack’s theorem
93
EE249Fall04
Hack’s theorem
94
EE249Fall04
Hack’s theorem
95
EE249Fall04
Hack’s theorem
96
EE249Fall04
Hack’s theorem
97
EE249Fall04
Hack’s theorem
98
EE249Fall04
Hack’s theorem
99
EE249Fall04
Hack’s theorem
100
EE249Fall04
Hack’s theorem
101
EE249Fall04
Hack’s theorem
Deadlock
102
EE249Fall04
Summary of LSFC nets
103
EE249Fall04
Petri Net extensions
104
EE249Fall04
2
PNs Summary
• Analysis techniques
– Structural (only CN or CS): State equations, Invariants
– Behavioral: coverability tree
• Reachability
• Subclasses: Marked Graphs, State Machines, Free-Choice PNs
105
EE249Fall04
References
• http://www.daimi.au.dk/PetriNets/
106
EE249Fall04