workflow management wvda (2002)
TRANSCRIPT
1Wil van der Aalst.
Workflow managementWvdA (2002)
1
An Introduction to Petri-Nets
2
Basic concepts (static)
• State
– e.g. state of an elevator (5,-1)– snapshot of the process/system
• State space
– set of all possible states
6
5
4
3
2
1
3
Basic concepts (dynamic)
• A process/system has a behaviour, i.e. it moves from state tostate
time
stat
e
4
Discrete dynamic systems
• We focus on discrete processes, i.e. state changes are caused by events
time
stat
e
= event
2Wil van der Aalst.
Workflow managementWvdA (2002)
5
Example: elevator
• Graphical representation of atransition system
(Abstraction from time!)
-1 0 1
6
5
4
3
2
1
Floor
Direction6
A possible path
-1 0 1
6
5
4
3
2
1
7
Example: elevator
• A possible path representedby a state/time diagram
time
stat
e
(6,0)...
(3,1)(3,0)(3,-1)(2,1)(2,0)(2,-1)(1,1)(1,0)
-1 0 1
6
5
4
3
2
1
8
Other Examples
red
green
yellow
spring winter
summer autumn
3Wil van der Aalst.
Workflow managementWvdA (2002)
9
Other Examples (2)
on
off
error
start_course
pass
follow_lecture
exercise
do_exam
drop_out
10
• Classical Petri-Nets• Modeling with Petri-Nets• Reachability Graphs• High-Level Petri-Nets
11
Lecture Objectives
In this class, you are going to learn:• Classical Petri-Nets• Modeling with Petri-Nets• Reachability Graphs• High-Level Petri-Nets
12
High-level Petri nets
• The classical Petri net was invented by Carl Adam Petri in1962.
• A lot of research has been conducted (>10,000 publications).• Until 1985 it was mainly used by theoreticians.• Since the 80-ties the practical use is increasing because of
the introduction of high-level Petri nets and the availabilityof many tools.
• High-level Petri nets are Petri nets extended with– color (for the modeling of attributes)– time (for performance analysis)– hierarchy (for the structuring of models, DFD's)
4Wil van der Aalst.
Workflow managementWvdA (2002)
13
The classical Petri net model
A Petri net is a network composed of places ( ) and transitions ( ).
t2
p1
p2
p3
p4t3
t1
Connections are directed and between a place and a transition.Tokens ( ) are the dynamic objects.The state of a Petri net is determined by the distribution of tokens
over the places.
14
Elements
(name)
(name)
place
transition
arc (directed connection)
token
t34 t43
t23 t32
t12 t21
t01 t10
p4
p3
p2
p1
p0
place
transition
token
15
Rules
• Connections are directed.• No connections between two places or two transitions.• Places may hold zero or more tokens.
wait enter before make_picture after leave gone
free
occupied
16
Transition t1 has three input places (p1, p2 and p3) and twooutput places (p3 and p4).
Place p3 is both an input and an output place of t1.
p1
p2
p3
p4t1
5Wil van der Aalst.
Workflow managementWvdA (2002)
17
Enabling condition for a Transition
Transitions are the active components and places and tokens arepassive.
A transition is enabled if each of the input places contains tokens.
t1 t2
Transition t1 is not enabled, transition t2 is enabled.
18
Enabling a Transition
wait enter before make_picture after leave gone
free
occupied
enabled Notenabled
Notenabled
19
Firing
An enabled transition may fire.Firing corresponds to consuming tokens from the input places and
producing tokens for the output places.
t2t2
Firing is atomic.
20
Firing
wait enter before make_picture after leave gone
free
occupied
fired
6Wil van der Aalst.
Workflow managementWvdA (2002)
21
Play “Token Game”
• In the new state, make_picture is enabled. It will fire, etc.
wait enter before make_picture after leave gone
free
occupied
22
Firing: Example
23
Non-determinism
Two transitions fight for the same token: conflict.Even if there are two tokens, there is still a conflict.
t1
t2
24
Non-determinism
t34 t43
t23 t32
t12 t21
t01 t10
p4
p3
p2
p1
p0
transition t23
fires
t34 t43
t23 t32
t12 t21
t01 t10
p4
p3
p2
p1
p0
Two transitions areenabled but onlyone can fire
7Wil van der Aalst.
Workflow managementWvdA (2002)
25
Remarks
• Firing is atomic.• Multiple transitions may be enabled, but only one fires at a time• 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).
26
Lecture Objectives
In this class, you are going to learn:• Classical Petri-Nets• Modeling with Petri-Nets• Reachability Graphs• High-Level Petri-Nets
27
Modeling with Petri Nets
• Place: passive element• Transition: active element• Arc: causal relation• Token: elements subject to change
The state (space) of a process/system is modeledby places and tokens.
State transitions are modeled by transitions (cf.transition systems).
28
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.
8Wil van der Aalst.
Workflow managementWvdA (2002)
29
Role of a place
• a type of communication medium, like a telephoneline, 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 aspecialist is available.
30
Role of a transition
• an event: for example, starting an operation, the deathof a patient, a change seasons or the switching of atraffic 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, transportinggoods, or sending a file.
31
Example: Single traffic lightrg
gy
yr
red
green
yellow
32
Two traffic lights
rg
gy
yr
red
green
yellow
rg
gy
yr
red
green
yellow
rg
gy
yr
red
green
yellow
OR
9Wil van der Aalst.
Workflow managementWvdA (2002)
33
Problem
34
Solution
rg1
gy1
yr1
r1
g1
y1
rg2
gy2
yr2
r2
g2
y2
x
How to makethemalternate?
35
Two safe and fair traffic lights
rg1
red1
yellow1
green1
yr1
gy1
rg2
red2
yellow2
green2
yr2
gy2
safe2
safe1
36
Example: life-cycle of a person
bachelor
child
married
puberty
marriage
divorce
death dead
10Wil van der Aalst.
Workflow managementWvdA (2002)
37
Lecture Objectives
In this class, you are going to learn:• Classical Petri-Nets• Modeling with Petri-Nets• Reachability Graphs• High-Level Petri-Nets
38
Multiple arcs connecting two nodes
• The number of arcs between an input place and a transitiondetermines the number of tokens required to be enabled.
• The number of arcs determines the number of tokens to beconsumed/produced.
wait enter before make_picture after leave gone
free
39
Example: Ball game
• The number of arcs between two objects specifies the number oftokens to be produced/consumed.
• This can be used to model (dis)assembly processes.
blackred
bbrr
br
40
• current stateThe configuration of tokens over the places.
• reachable stateA state reachable form the current state by firing a sequence ofenabled transitions.
• dead stateA state where no transition is enabled.
Some definitions
blackred
bbrr
br
11Wil van der Aalst.
Workflow managementWvdA (2002)
41
• 7 reachable states, 1 dead state.
blackred
bbrr
br (3,2)
(1,3) (3,1)
(1,2) (3,0)
(1,1)
(1,0)
rr
rr
rr
br
br
bb\br
bb\br
bb\br
42
Exercise: your life-cycle
• How many states are reachable?• Is there a dead state?
dead
sleeping
active
start stop
die
43
Exercise: readers and writers
• How many states are reachable?• Are there any dead states?• How to model the situation with 2 writers and 3 readers?• How to model a "bounded mailbox" (buffer size =4)?
rest
mail_box
receive_mail
type_mail
ready
rest
begin
send_mail
read_mail
44
Lecture Objectives
In this class, we are going to learn:• Classical Petri-Nets• Modeling with Petri-Nets• Reachability Graphs• High-Level Petri-Nets
12Wil van der Aalst.
Workflow managementWvdA (2002)
45
Problems of Classical Petri nets
In practice the classical Petri net is not very useful:• The Petri net becomes too large and too complex, since
each case has its own set of attributes and needs one Petrinet for each set of attributes..
• It is not possible to handle time and data.• There is no support for structuring large models, e.g., top-
down and bottom-up design
46
Models cannot reflect temporal aspects
rg1
go1
or1
r1
g1
o1
rg2
go2
or2
r2
g2
o2
x
Duration of eachphase is highly
relevant.
47
rg1
go1
or1
r1
g1
o1
rg2
go2
or2
r2
g2
o2
x
No support for structuring large models
48
High-level Petri nets
• To tackle the problems identified, Petri nets areextended with:– Color (i.e., data)– Time– Hierarchy
13Wil van der Aalst.
Workflow managementWvdA (2002)
49
To explain the three extensions we use the following exampleof a hairdresser's saloon.
start
waiting
finish
busy
free
ready
client waiting
hairdresser ready to begin
Note how easy it is to model the situation with multiple hairdressers.
50
The extension with colorA token often represents an object having all kinds of attributes.Therefore, each token has a value (color) which refers to specific features
of the object modelled by the token.
start
waiting
finish
busy
free
ready
name: Harryage: 28experience: 2
name: Sallyage: 28hairtype: BL
51
Extension with color
• Tokens have a color (i.e., a data value)
{Brand="BMW", RegistrationNo="GD-XW-11", Year=1993, Colour="blue", Owner= "Inge"}
{Brand="Lada", RegistrationNo="PH-14-PX", Year=1986, Color="grey", Owner="Inge"}
52
Extension with color
• Places are typed (also referred to as color set).
{Brand="BMW", RegistrationNo="GD-XW-11", Year=1993, Colour="blue", Owner= "Inge"}
{Brand="Lada", RegistrationNo="PH-14-PX", Year=1986, Color="grey", Owner="Inge"}
record Brand:string
RegistrationNo:string
Year:int
Color:string
Owner:string
14Wil van der Aalst.
Workflow managementWvdA (2002)
53
Each transition has an (in)formal specification which specifies:• the number of tokens to be produced,• the values of these tokens,• and (optionally) a precondition.
The complexity is divided over the network and the values of tokens.
This results in a compact, manageable and natural process description.
54
Examples
c := a+ba
b c
+
b := -a
b-a
if a> 0then b:= aelse c:=afi
a b
c
select
a >=0 | b := Ö a
bsqrta
Exercise:calculate Ö |a+b| using these buiding blocks
55
Example: Making punch cards
start
donewait
stop
busy
free
waitingpatients
servedpatients
free deskemployees
patient/employees
56
Tokens are colored
start
donewait
stop
busy
free
{Name="Klaas", Address="Plein 10", DateOfBirth="13-Dec-1962", Gender="M"}
{EmpNo=641112, Experience=7}
15Wil van der Aalst.
Workflow managementWvdA (2002)
57
Places are typed
start
donewait
stop
busy
free
record EmpNo:int * Experience:int
record Name:string *
Address:string *
DateOfBirth:str *
Gender:string
record Name:string *
Address:string *
DateOfBirth:str *
Gender:stringrecord Name:string *
Address:string *
DateOfBirth:str *
Gender:string *
EmpNo:int *
Experience:int58
Running example: Initial state
start
donewait
stop
busy
free
{Name="Klaas", Address="Plein 10", DateOfBirth="13-Dec-1962", Gender="M"}
{EmpNo=641112, Experience=7}
start is enabled
59
Running example: Transition start fired
stop is enabled
start
donewait
stop
busy
free
{Name="Klaas", Address="Plein 10", DateOfBirth="13-Dec-1962", Gender="M", EmpNo=641112, Experience=7}
New value is created by simply merging the two records.
60
Running example: Transition stop fired
New values are created by simply spliting the record into two parts.
start
donewait
stop
busy
free
{Name="Klaas", Address="Plein 10", DateOfBirth="13-Dec-1962", Gender="M"}
{EmpNo=641112, Experience=7}
16Wil van der Aalst.
Workflow managementWvdA (2002)
61
The number of tokens produced is no longer fixed (1)
test
samplenegative
positive
{sample_number=931101011, measurement_outcomes="XYV"}
{sample_number=931101023, measurement_outcomes="VXY"}
Note that the network structure is no longer a completespecification!
62
The number of tokens produced is no longer fixed (2)
test
samplenegative
positive
{sample_number=931101011, measurement_outcomes="XYV"}
The number of tokens produced for each output place is between0 and 3 and the sum should be 3.
63
The extension with timeFor performance analysis we need to model durations, delays, etc.Therefore, each token has a timestamp and transitions determine the delay
of a produced token.
start
waiting
finish
busy
free
ready
0
1
3 9
D=3
D=0D=0
64
Extension with time
• Each token has a timestamp.• The timestamp specifies the earliest time when it can be
consumed.
2 5
17Wil van der Aalst.
Workflow managementWvdA (2002)
65
Extension with time
• The enabling time of a transition is the maximum of the tokens to be consumed.• If there are multiple tokens in a place, the earliest ones are consumed first.• A transition with the smallest firing time will fire first.• Transitions are eager, i.e., they fire as soon as they can.• Produced token may have a delay.• The timestamp of a produced token is the firing time plus its delay.
66
Running example: Enabling time
• Transition start is enabled at time 2 = max{0,min{2,4,4}}.
start
donewait
stop
busy
free
4
2
4
0
67
Running example: Delays
• Tokens for place busy get a delay of 3• @+3 = firing time plus 3 time units
start
donewait
stop
busy
free
4
2
4
0
@+3
@+0
@+0
68
Running example: Transition start fired
• Transition start fired at time 2.
start
donewait
stop
busy
free
45
4
@+0
@+0
@+3
Continue to play (timed) token game…
18Wil van der Aalst.
Workflow managementWvdA (2002)
69
Exercise: Final state?
x
y
d
e
b
a
c
4
3
5
1
@+1
@+2
70
Extension with hierarchy
• Timed and colored Petri nets result in more compact models.• However, for complex systems/processes the model does not fit on
a single page.• Moreover, putting things at the same level does not reflect the
structure of the process/system.• Many hierarchy concepts are possible. In this course we restrict
ourselves to transition refinement.
71
rg1
go1
or1
r1
g1
o1
rg2
go2
or2
r2
g2
o2
x
Instead of
72
rg1
go1
or1
r1
g1
o1
rg2
go2
or2
r2
g2
o2
x
tl1 tl2
x
x
We can use hierarchy
19Wil van der Aalst.
Workflow managementWvdA (2002)
73
rg
go
or
r
g
tl1 tl2
x
x
o
Reuse
• Reuse saves design efforts.• Hierarchy can have any
number of levels• Transition refinement can
be used for top-down andbottom-up design
74
The extension with hierarchy• A subnet is a net composed out of places, transitions and subnets.
waiting ready
h1
h2
h3
start finishbusy
free
75
Exercise: remove hierarchy
waiting ready
h1
h2
h3
start finishbusy
free
begin endpending
begin endpending
76
Conclusions
• Petri net is a tool that allows processes to be modeledgraphically and analyzed in a formal way.
• Petri net forms the basis of many process definitiontools available in the market.
• Classical Petri net needs to be extended with color, timeand hierarchy in order to make it capable of modelingbusiness processes.
• Next, we study how workflow processes and resourcemanagement can be modeled with Petri-net.