Computer Engineering and Networks Technische Informatik und Kommunikationsnetze Discrete Event Systems - Petri Nets – Lothar Thiele 2 Petri Nets – Motivation • In contrast to state machines, state transitions in Petri nets are asynchronous. The ordering of transitions is partly uncoordinated; it is specified by a partial order. • Therefore, Petri nets can be used to model concurrent distributed systems. • Many flavors of Petri nets are in use, e.g. • Activity charts (UML) • Data flow graphs and marked graphs • GRAFCET (programming language for programming logic controllers) • Specialized languages for workflow management and business processes • Invented by Carl Adam Petri in 1962 in his thesis “Kommunikation mit Automaten” 3 Contents • Definition of Petri nets • Properties of Petri nets • Analysis of Petri nets • Coverability Tree • Incidence Matrix • Timed Petri nets • Definition • Simulation 4 Petri Net – Definition •A Petri net is a bipartite, directed graph defined by a 4-tuple (S, T, F, M 0 ), where: • S is a set of places p • T is a set of transitions t • F is a set of edges (flow relations) f, no parallel edges are allowed • M 0 : S → N; the initial marking p1 p3 p5 p4 p2 •t1 •t2 t1, t2 ∈ T p1, p2, p3, p4, p5 ∈ S p1, t1 , p2, t1 , t1, p5 , … ∈ F
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Computer Engineering and NetworksTechnische Informatik und Kommunikationsnetze
Discrete Event Systems- Petri Nets –
Lothar Thiele
2
Petri Nets – Motivation
• In contrast to state machines, state transitions in Petri nets are asynchronous. The
ordering of transitions is partly uncoordinated; it is specified by a partial order.
• Therefore, Petri nets can be used to model concurrent distributed systems.
• Many flavors of Petri nets are in use, e.g.
• Activity charts (UML)
• Data flow graphs and marked graphs
• GRAFCET (programming language for programming logic controllers)
• Specialized languages for workflow management and business processes
• Invented by Carl Adam Petri in 1962 in his thesis “Kommunikation mit Automaten”
3
Contents
• Definition of Petri nets
• Properties of Petri nets
• Analysis of Petri nets
• Coverability Tree
• Incidence Matrix
• Timed Petri nets
• Definition
• Simulation
4
Petri Net – Definition
• A Petri net is a bipartite, directed graph defined by a 4-tuple
(S, T, F, M0), where:
• S is a set of places p
• T is a set of transitions t
• F is a set of edges (flow relations) f, no
parallel edges are allowed
• M0 : S → N; the initial marking
p1 p3
p5 p4
p2
•t1 •t2
t1, t2 ∈ T
p1, p2, p3, p4, p5 ∈ S
p1, t1 , p2, t1 , t1, p5 , … ∈ F
5
Token Marking
• Each place pi is marked with a certain number of token.
• The initial distribution of the tokens is given by M0 .
• M(s) denotes the marking of a place s.
• The distribution of tokens on places defines the state of
a Petri net.
• The dynamics of a Petri net is defined by a token game.
p1
p2
•t1
6
Token Game of Petri Nets
• A marking M activates a transition t ∈ T if each place p connected through an edge
f towards t contains at least one token.
• If a transition t is activated by M, a state transition to M’ fires (happens)
eventually.
• Only one transition is fired at any time.
• When a transition fires, it
• consumes a token from each of its input places,
• adds a token to each of its output places.
p3 p4
p1 p2
•t1
p3 p4
p1 p2
•t1•t1 fires
7
Non-Deterministic Evolution
• Any of the activated transactions might fire:
The evolution of Petri nets is not deterministic.
p3 p4
p1 p2
•t1•t2
p3 p4
p1 p2
•t1•t2
p3 p4
p1 p2
•t1•t2
•t2 •t1
8
Syntax Exercise (1)
•A •B •C •D •E
•F •G •H •I
• Is it a valid Petri Net?
• Which transitions
are activated?
• What is the marking
after firing?
9
Syntax Exercise (2)
•J •K
•L
•t2•t1
• Is it a valid Petri Net?
• Which transitions
are activated?
• What is the marking
after firing?
•t1 •t2 •t3
10
Weighted Edges
• Associating weights to edges:
• Each edge f has an associated weight W(f) (defaults to 1).
• A transition t is activated if each place p connected through an edge f to t contains at least
W(f) token.
• When transition t fires, then W(f) token are transferred.
H2O2
chemical reaction
2 H2 + O2 → 2H2O
2
2
H2O
H2 O2
2
2
H2O
11
State Transition Function
• Using the previous definitions, we can now define the state transitions function δ
of a Petri net:
• Suppose that in a given Petri net (S, T, F, W, M0) the
transition t is activated. Before firing the marking is M.
• Then after firing t, the new marking is M’ = δ(M, t) with
• We also write sometimes M’ = M · t instead of M’ = δ(M, t).
M(p) – W(p, t) if (p, t) ϵ F and (t, p) ϵ F
M(p) + W(t, p) if (t, p) ϵ F and (p, t) ϵ F
M(p) – W(p, t) + W(t, p) if (t, p) ϵ F and (p, t) ϵ F
M(p) otherwise
M’(p) =
12
Finite Capacity Petri Net
• Each place p can hold maximally K(p) token.
• A transition t is only active if all output places pi of t cannot exceed K(pi) after
firing t.
• Finite capacity Petri Nets can be transformed into equivalent infinite capacity Petri
Nets (without capacity restrictions).
• Equivalence: Both nets have the same set of all possible firing sequences
p1
p2 K(2)=1
t1
t2
p1
p2 K(2)=1
t1
t2
p1
p2 K(2)=1
t1
t2
t1
•t2
13
Removing Capacity Constraints
• For each place p with K(p) > 1, add a complementary place p’ with initial marking
M0(p’) = K(p) – M0(p).
• For each outgoing edge f = (p, t), add an edge f’ from t to p’ with weight W(f).
• For each incoming edge f = (t, p), add an edge f’ from p’ to t with weight W(f).
p1
p2 K(2)=3
t1
t2
p1
p2
t1
t2
p2’
2 2
2
•remove capacity
•constraint
14
Your turn!
• Remove the capacity constraint from place p3:
p2
p3•K(3)=3
t2
t3
p1
p4
t4
t1
t5
2
15
Your turn!
• Remove the capacity constraint from place p3:
p2
p3•K(3)=3
t2
t3
p1
p4
t4
t1
t5
2
p2
p3
t2
t3
p1
p4
t4
t1
t5
2 p3’
•2
16
Modeling Finite Automata
• Finite automata can be represented by a subclass of Petri nets, where each
transition has exactly one incoming edge and one outgoing edge.
• Such Petri nets are also called state machines.
• Coke vending machine revisited:
p1
p2
p4
p5
D
•Q
Q
p3
•D
p4
•D|Q
•Q
Dp6
D
Q D
p4
Q
D|Q
Soda
10 ¢
40 ¢
30 ¢20 ¢
≥ 45 ¢
35 ¢
25 ¢
• Coke costs 45 ¢.
• Customer pays with
Dime (10 ¢) or
Quarter (25 ¢).
• Overpaid money is lost.
17
Concurrent Activities
• Finite Automata allow the representation of decisions, but no concurrency.
• General Petri nets support concurrency with intuitive notation: