Professional Documents
Culture Documents
Petri Nets Refesher: Prof - Dr.ir. Wil Van Der Aalst
Petri Nets Refesher: Prof - Dr.ir. Wil Van Der Aalst
Petri Nets Refesher: Prof - Dr.ir. Wil Van Der Aalst
Petri nets
Classical Petri nets: The basic model
Process modeling
Emphasis on dynamic behavior rather than structuring the state space Transition system is too low level We start with the classical Petri net Then we extend it with:
Color Time Hierarchy
History:
Carl Adam Petri (1962, PhD thesis) In sixties and seventies focus mainly on theory. Since eighties also focus on tools and applications (cf. CPN work by Kurt Jensen). Hidden in many diagramming techniques and systems.
/faculteit technologie management
PN-4
p4 place
Elements
(name) place
t34 p3
t43
transition
t23 p2
t32
(name)
transition
token
token
t01 p0
t10
free
Rules
wait enter before make_picture after leave gone
occupied
Connections are directed. No connections between two places or two transitions. Places may hold zero or more tokens. First, we consider the case of at most one arc between two nodes.
PN-6
Enabled
A transition is enabled if each of its input places contains at least one token.
free
wait
enter
before
make_picture
after
leave
gone
occupied
enabled
/faculteit technologie management
Not enabled
Not enabled
PN-7
Firing
An enabled transition can fire (i.e., it occurs). When it fires it consumes a token from each input place and produces a token for each output place. free
fired
wait enter before make_picture after leave gone
occupied
wait
enter
before
make_picture
after
leave
gone
occupied
Remarks
Firing is atomic. Multiple transitions may be enabled, but only one fires at a time, i.e., we assume interleaving semantics (cf. diamond rule). The number of tokens may vary if there are transitions for which the number of input places is not equal to the number of output places. The network is static. The state is represented by the distribution of tokens over places (also referred to as marking).
/faculteit technologie management
PN-10
Non-determinism
t34
p4
p4
t43 p3
t34 p3
t43
t23 p2
t23 p2
t32
t12 p1
t21
t12 p1
t21
t01 p0
t10
t01 p0
t10
PN-11
rg
green
red
go
orange
or
/faculteit technologie management
PN-12
rg
green
green green
red
go
red
go
OR
orange
red
go
orange
or
or
orange
or
/faculteit technologie management
PN-13
Problem
Solution
rg1 rg2
g1
g2
r1
go1
go2
r2
o1
o2
or2
PN-15
WARNING
It is not sufficient to understand the (process) models. You have to be able to design them yourself !
/faculteit technologie management
PN-21
wait
enter
before
make_picture
after
leave
gone
rr
bb
subassembly2
engine 2 chair subassembly1 4 chassis
/faculteit technologie management
PN-26
wheel
Formal definition
A classical Petri net is a four-tuple (P,T,I,O) where: P is a finite set of places, T is a finite set of transitions, I : P x T -> N is the input function, and O : T x P -> N is the output function. Any diagram can be mapped onto such a four tuple and vice versa.
/faculteit technologie management
PN-27
rr
bb
Enabling formalized
Transition t is enabled in state s1 if and only if:
Firing formalized
If transition t is enabled in state s1, it can fire and the resulting state is s2 :
Reachability graph
The reachability graph of a Petri net is the part of the transition system reachable from the initial state in graph-like notation. The reachability graph can be calculated as follows:
1. Let X be the set containing just the initial state and let Y be the empty set. 2. Take an element x of X and add this to Y. Calculate all states reachable for x by firing some enabled transition. Each successor state that is not in Y is added to X. 3. If X is empty stop, otherwise goto 2.
/faculteit technologie management
PN-34
Example
red rb black
(3,2)
(3,1)
(3,0)
(1,3)
rr bb
(1,2)
(1,1)
(1,0)
Nodes in the reachability graph can be represented by a vector (3,2) or as 3 red + 2 black. The latter is useful for sparse states (i.e., few places are marked).
/faculteit technologie management
PN-35
g1
g2
r1
go1
go2
r2
o1
o2
or1
or2
Modeling
Place: passive element Transition: active element Arc: causal relation Token: elements subject to change
The state (space) of a process/system is modeled by places and tokens and state transitions are modeled by transitions (cf. transition systems).
/faculteit technologie management
PN-40
Role of a token
Tokens can play the following roles: a physical object, for example a product, a part, a drug, a person; an information object, for example a message, a signal, a report; a collection of objects, for example a truck with products, a warehouse with parts, or an address file; an indicator of a state, for example the indicator of the state in which a process is, or the state of an object; an indicator of a condition: the presence of a token indicates whether a certain condition is fulfilled.
/faculteit technologie management
PN-41
Role of a place
a type of communication medium, like a telephone line, a middleman, or a communication network; a buffer: for example, a depot, a queue or a post bin; a geographical location, like a place in a warehouse, office or hospital; a possible state or state condition: for example, the floor where an elevator is, or the condition that a specialist is available.
/faculteit technologie management
PN-42
Role of a transition
an event: for example, starting an operation, the death of a patient, a change seasons or the switching of a traffic light from red to green; a transformation of an object, like adapting a product, updating a database, or updating a document; a transport of an object: for example, transporting goods, or sending a file.
Causality
Parallelism
Parallelism: AND-split
Parallelism: AND-join
Choice: XOR-split
Choice: XOR-join
g1
g2
r1
go1
go2
r2
o1
o2
or2
PN-56
subassembly2
2 chair
chassis
/faculteit technologie management
p
/faculteit technologie management
PN-58
Solution
Only works if place is N-bounded
N input and output arcs
t p
p
/faculteit technologie management
PN-59
t1
?
t2
/faculteit technologie management
A bit of theory
Extensions have been proposed to tackle these problems, e.g., inhibitor arcs. These extensions extend the modeling power (Turing completeness*). Without such an extension not Turing complete. Still certain questions are difficult/expensive to answer or even undecidable (e.g., equivalence of two nets).
* Turing completeness corresponds to the ability to execute any computation.
/faculteit technologie management
PN-61
p
Tricks only work if p is bounded
/faculteit technologie management
PN-66
incr1
incr2
incr3
incr4
incr5
bike
wheel
bell
steering wheel
frame
decr1
decr2
decr3
decr4
decr5
l1
l2
l3
l4
l5
claim_track
claim_track
claim_track
g1
g2
r1
go1
go2
r2
o1
o2
or2
PN-69
g1
g2
r1
go1
go2
r2
o1
o2
or1
or2
PN-70
For the time being be do not choose a concrete language but focus on the main concepts. Later we focus on a concrete language: CPN. These concepts are supported by many variants of CPN including ExSpect, CPN AMI, etc.
/faculteit technologie management
PN-71
busy
waiting patients
/faculteit technologie management
patient/ employees
served patients
PN-72
The value of the token produced for place sum is the sum of the values of the consumed tokens.
PN-75
done
record Name:string * record Name:string * Address:string * Address:string * busy DateOfBirth:str * record Name:string * DateOfBirth:str * Gender:string Address:string * Gender:string DateOfBirth:str * Gender:string * EmpNo:int * /faculteit technologie management Experience:int
PN-77
done
start is enabled
/faculteit technologie management
PN-78
done
busy
stop is enabled
/faculteit technologie management
PN-79
done
New values are created by simply spliting the record into two parts.
/faculteit technologie management
PN-80
positive
test sample
negative
{sample_number=931101023, measurement_outcomes="VXY"}
positive
test sample
negative
The number of tokens produced for each output place is between 0 and 3 and the sum should be 3.
/faculteit technologie management
PN-82
r1
r2
r3
r4
r5
Example
incr1 incr2 incr3 incr4 incr5
bike
wheel
bell
steering wheel
frame
decr1
decr2
decr3
decr4
decr5
l1
l2
l3
l4
l5
in {prod="bell", num=2}
Product and quantity are in the value of the token The entire stock is represented by the value of a single token, i.e., a list of records.
/faculteit technologie management
increase
stock
[{prod="bike", num=4}, {prod="wheel", num=2}, {prod="bell", number=3}, {prod="steering wheel", num=3}, {prod="frame", num=2}]
decrease
out
PN-84
in
Types
increase
{prod="bell", num=2}
StockItem
stock
Stock
decrease
[{prod="bike", num=4}, {prod="wheel", num=2}, {prod="bell", number=3}, {prod="steering wheel", num=3}, {prod="frame", num=2}]
StockItem
out
PN-85
4 busy
/faculteit technologie management
PN-88
4
/faculteit technologie management
busy
PN-89
5 c y @+2 4
/faculteit technologie management
PN-91
Instead of
rg1
rg2
g1
g2
r1
go1
go2
r2
o1
o2
or1
or2
tl1 x
tl2
rg1
rg2
g1
g2
r1
go1 x x
go2
r2
o1
o2
or1
or2
Reuse
Reuse saves design efforts. Hierarchy can have any number of levels Transition refinement can be used for top-down and bottom-up design
/faculteit technologie management
tl1 x
tl2
rg
go x
or
PN-96
free
done
busy
Questions raised when considering the an intersection with multiple traffic lights
How much traffic can be handled per hour? Give some volume of traffic, what is the probability to get a red light? Is the intersection safe, i.e., crossing flows have never a green light at the same time? Can a light go from yellow to green? Is the intersection fair (i.e., a traffic light cannot turn green twice while cars are waiting on the other side)?
/faculteit technologie management
PN-101
Analysis
Analysis is typically modeldriven to allow e.g. what-if questions. Models of both operational processes and/or the information systems can be analyzed. Types of analysis: validation verification
Operational process
Information System
Model
performance analysis
/faculteit technologie management
PN-104
Reachability graph
rg1 rg2
(0,0,1,1,0,0,0)
g1 g2
(1,0,0,0,0,1,0)
r1
go1
go2
r2
(1,0,0,1,0,0,1)
o1
o2
(0,1,0,1,0,0,0)
or1 or2
(1,0,0,0,1,0,0)
Alternative notation
rg1 rg2
o1+r2
g1 g2
r1+o2
r1
go1
go2
r2
r1+r2+x
o1
o2
g1+r2
or1 or2
r1+g2
g1
g2
r1
go1
go2
r2
o1
o2
or1
or2
wait
enter
before
make_picture
after
leave
gone
occupied
Place invariant
man
woman
Assigns a weight to each place. The weight of a token depends on the weight of the place. The weighted token sum is invariant, i.e., no transition can change it
PN-115
Other invariants
man
woman
1 man + 0 woman + 1 couple (Also denoted as: man + couple) 2 man + 3 woman + 5 couple -2 man + 3 woman + couple man woman woman man (Any linear combination of invariants is an invariant.)
g1
g2
r1
go1
go2
r2
r1 + g1 + o1 r2 + g2 + o2 r1 + r2 + g1 + g2 + o1 + o2 x + g1 + o1 + g2 + o2 r1 + r2 - x
o1
o2
or1
or2
free
producer
wait
consumer
product
end_production
/faculteit technologie management
end_consumption
PN-118
Transition invariant
man
woman
2 marriage + 2 divorce
/faculteit technologie management
Assigns a weight to each transition. If each transition fires the number of times indicated, the system is back in the initial state. I.e. transition invariants indicate potential firing sets without any net effect.
PN-119
Other invariants
man
woman
1 marriage + 1 divorce (Also denoted as: marriage + divorce) 20 marriage + 20 divorce Any linear combination of invariants is an invariant, but transition invariants with negative weights have no obvious meaning. Invariants may be not be realizable.
PN-120
g1
g2
r1
go1
go2
r2
rg1 + go1 + or1 rg2 + go2 + or2 rg1 + rg2 + go1 + go2 + or1 + or2 4 rg1 + 3 rg2 + 4 go1 + 3 go2 + 4 or1 + 3 or2
o1
o2
or1
or2
free
producer
wait
consumer
product
end_production
/faculteit technologie management
end_consumption
PN-122
c1 e2 se2 t2 c2 st2
man
couple divorce
woman
1 1 N 1 1 1 1
PN-125
man
Example
man
woman
marriage
woman
1 1 N 1 1 1 1
couple divorce
PN-126
Place invariant
Let N be the incidence matrix of a net with n places and m transitions Any solution of the equation X.N = 0 is a transition invariant
X is a row vector (i.e., 1 x n matrix) O is a row vector (i.e., 1 x m matrix)
Note that (0,0,... 0) is always a place invariant. Basis can be calculated in polynomial time.
Example
man
woman
1 1 X 1 1 (0,0) 1 1
Solutions: (0,0,0) 1 1 (1,0,1) (man, woman, couple) 1 1 (0,0) (0,1,1) 1 1 (1,1,2) (1,-1,0)
/faculteit technologie management
PN-128
Transition invariant
Let N be the incidence matrix of a net with n places and m transitions Any solution of the equation N.X = 0 is a place invariant
X is a column vector (i.e., m x 1 matrix) 0 is a column vector (i.e., n x 1 matrix)
Note that (0,0,... 0)T is always a place invariant. Basis can be calculated in polynomial time.
Example
man
woman
1 1 0 1 1 X 0 1 1 0
Solutions: (0,0)T (1,1)T (32,32)T
PN-130
1 1 0 marriage 1 1 divorce 0 0 1 1
/faculteit technologie management
start_production
start_consumption
Exercise
free producer wait consumer
product
end_production
end_consumption
Simulation
Most widely used analysis technique. From a technical point of view just a "walk" in the reachability graph. By making many "walks" (in case of transient behavior) or a very "long walk" (in case of steady-state) behavior, it is possible to make reliable statements about properties/ performance indicators. Used for validation and performance analysis. Cannot be used to prove correctness!
/faculteit technologie management
PN-132
Stochastic process
Simulation of a deterministic system is not very interesting. Simulation of an untimed system is not interesting. In a timed and non-deterministic system, durations and probabilities are described by some probability distribution. In other words, we simulate a stochastic process! CPN allows for the use of distributions using some internal random generator.
/faculteit technologie management
PN-133
Uniform distribution
cumulative
Normal distribution
Example
() trigger BT
() ()
Dice.ran()
throw_dice outcome Dice
Example(2)
color INT = int; color TINT = int timed; color Dice = int with 1..6; color Delay = int with 0..99; trigger TINT 0
throw_dice
Dice.ran()
outcome Dice
(x+1)@+(Delay.ran())
arrive
Car
HS
environment
gas_station
drive_on
Car
depart
/faculteit technologie management
Car
PN-142
In
arrive
Subpage gas_station
color Car = string; color Pump = unit; color TCar = Car timed; color Queue = list Car; var c:Car; var q:Queue; fun len(q:Queue) = if q=[] then 0 else 1+len(tl(q));
c@+uniform(2,5)
() pump_free () Pump ()
fill_up
TCar c end c
Out
Out
depart
Car
drive_on
Car
PN-143
Assuming pages for the environment and measurements the last two pages allow for ...
Calculation of flow time (average, variance, maximum, minimum, service level, etc.). Calculation of waiting times (average, variance, maximum, minimum, service level, etc.). Calculation of lost sales (average). Probability of no space left. Probability of no cars waiting. For each of these metrics, it is possible to formulate a confidence interval given sufficient observations.
/faculteit technologie management
PN-144
In
arrive
Alternatives
color Car = string; color Pump = unit; color TCar = Car timed; color Queue = list Car; var c:Car; var q:Queue; fun len(q:Queue) = if q=[] then 0 else 1+len(tl(q));
fill_up
TCar c end c
Out
Pump ()
Out
depart
Car
drive_on
Car
PN-145
A B C
/faculteit technologie management
PN-146
Use distributions
Data
A B C
X 2 3 4
Y 5 6 7
Z 8 9 1
X Y Z
2 3 4
Processing times
A B C
2 1 2
A B C
2 1 1
A B C
7 9 8
6 resources_Z INT
Prod kanban4
HS
Prod
HS
supplier
work_ center_ Z
customer
Prod
Prod
Prod
processing_ time_X
processing_ time_Y
processing_ time_Z
c_ia_time
work_center processing_time = processing_time_X resources = resources_X kanban_in = kanban2 product_in = product1 kanban_out = kanban1 product_out = product2
work_center processing_time = processing_time_Y resources = resources_Y kanban_in = kanban3 product_in = product2 kanban_out = kanban2 product_out = product3
work_center processing_time = processing_time_Z resources = resources_Z kanban_in = kanban4 product_in = product3 kanban_out = kanban3 product_out = product4
PN-148
kanban_in
Prod
(p,t)
io_lead_time
PT
oip
PTimed p p
Out
deliver_order
product_out
Prod
place_order p
kanban_out
Prod (p,t)@+t
(p,t)
In/Out
c_ia_time
In
PTTimed
p Prod consume
product_in
kanban_out
Out
Prod
p end_proc p
product_out
Prod p i
i+1
In/Out
wip
In
[i>=1] p Prod p
resources
INT
kanban_in
In
start_proc (p,t)
(p,t)
In/Out
PT
Overview
Results: response time utilization % backorders average stock etc.
accept_order p (p,t) p@+t
In/Out
color INT = int; color Prod = string; color PT = product Prod * INT; color PTimed = Prod timed; color PTTimed = PT timed; var p:Prod; var t:INT; var i:INT; resources_X 2`"A"++ 1`"B"++ 1`"C"
HS
6 resources_Z INT
Prod kanban4
HS
Prod
HS
supplier
work_ center_ Z
customer
Prod
Prod
Prod
processing_ time_X
processing_ time_Y
processing_ time_Z
c_ia_time
work_center processing_time = processing_time_X resources = resources_X kanban_in = kanban2 product_in = product1 kanban_out = kanban1 product_out = product2
work_center processing_time = processing_time_Y resources = resources_Y kanban_in = kanban3 product_in = product2 kanban_out = kanban2 product_out = product3
work_center processing_time = processing_time_Z resources = resources_Z kanban_in = kanban4 product_in = product3 kanban_out = kanban3 product_out = product4
Out
In
kanban_out
Prod
p end_proc p
Out
place_order p
kanban_in
Prod
Out
(p,t)
product_out Prod p i
kanban_out
i+1
Prod (p,t)@+t
(p,t)
In/Out
io_lead_time
PT
In/Out
oip
PTimed p p
Out
In
resources
INT
In
PTTimed
deliver_order
product_out
Prod
kanban_in
In
start_proc (p,t)
(p,t)
In/Out
product_in
PT
Sometimes abstraction from color is possible to derive invariants (consider previous example).
Change the model such that philosophers can take one chopstick at a time but avoid deadlocks and a fixed ordering of philosophers.
Give place invariants Give transition invariants
/faculteit technologie management
PN-154
Top-level page
()
HS philosopher left = CS2 right = CS1
CS1 BlackToken
CS2
()
PH1 BlackToken
HS philosopher left = CS1 right = CS5
PH5
PH2
HS philosopher left = CS3 right = CS2
CS5 BlackToken
()
CS3 BlackToken
()
CS4 PH4
HS philosopher left = CS5 right = CS4
() PH3
HS philosopher left = CS4 right = CS3
BlackToken
Page philosopher
think BlackToken b take_chopsticks b () eat BlackToken b b put_down_chopsticks
b b left BlackToken
/faculteit technologie management
b b right
In/Out
In/Out
BlackToken
PN-156
CS1 BlackToken
()
HS
CS2
()
PH1 BlackToken
HS philosopher left = CS1 right = CS5
PH5
PH2
HS philosopher left = CS3 right = CS2
CS5 BlackToken
()
CS3 BlackToken
()
CS4 PH4
HS philosopher left = CS5 right = CS4
() PH3
HS philosopher left = CS4 right = CS3
BlackToken
b b left BlackToken
In/Out
b b right
In/Out
BlackToken
Repeat 5 times...
PN-157
Alternative page
()
b left BlackToken
b right
In/Out In/Out
BlackToken