PN modelling

advertisement
Modeling based on Petri-nets.
Lecture 8
1
High-level Petri nets
• The classical Petri net was invented by Carl Adam Petri in
1962.
• 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 availability of
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)
2
The classical Petri net model
A Petri net is a network composed of places ( ) and transitions ( ).
t2
t1
p2
p1
t3
p4
p3
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.
3
p1
p4
t1
p2
p3
Transition t1 has three input places (p1, p2 and p3) and two
output places (p3 and p4).
Place p3 is both an input and an output place of t1.
4
Enabling condition
Transitions are the active components and places and tokens are passive.
A transition is enabled if each of the input places contains tokens.
t1
t2
Transition t1 is not enabled, transition t2 is enabled.
5
Firing
An enabled transition may fire.
Firing corresponds to consuming tokens from the input places and
producing tokens for the output places.
t2
t2
Firing is atomic.
6
Example
7
Non-determinism
t1
t2
Two transitions fight for the same token: conflict.
Even if there are two tokens, there is still a conflict.
8
Modeling
States of a process are modeled by tokens in places and state
transitions leading from one state to another are modeled by
transitions.
• Tokens represent objects (humans, goods, machines), information,
conditions or states of objects.
• Places represent buffers, channels, geographical locations,
conditions or states.
• Transitions represent events, transformations or transportations.
9
Example: traffic light
red
yr
yellow
rg
gy
green
10
Two traffic lights
red1
red2
yr1
yr2
yellow1
rg1
gy1
yellow2
rg2
gy2
green1
green2
11
Two safe traffic lights
red1
red2
safe
yr1
yr2
yellow1
rg1
gy1
yellow2
rg2
gy2
green1
green2
12
Two safe and fair traffic lights
red1
red2
safe2
yr1
yr2
yellow1
rg1
yellow2
gy1
rg2
gy2
safe1
green1
green2
13
Example: life-cycle of a person
child
puberty
marriage
bachelor
married
divorce
death
dead
14
br
red
black
rr
bb
• The number of arcs between two objects specifies the number of
tokens to be produced/consumed.
• This can be used to model (dis)assembly processes.
15
Some definitions
• current state
The configuration of tokens over the places.
• reachable state
A state reachable form the current state by firing a sequence of enabled
transitions.
• dead state
A state where no transition is enabled.
br
red
black
rr
bb
16
(3,2)
br
rr
red
black
bb\br
(1,3)
(3,1)
rr
br
bb\br
rr
bb
(1,2)
(3,0)
rr
bb\br
(1,1)
br
(1,0)
• 7 reachable states, 1 dead state.
17
Exercise: your life-cycle
sleeping
start
stop
active
die
dead
• How many states are reachable?
• Is there a dead state?
18
Exercise: readers and writers
begin
receive_mail
mail_box
rest
rest
type_mail
read_mail
send_mail
•
•
•
•
ready
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)?
19
High-level Petri nets
In practice the classical Petri net is not very useful:
• The Petri net becomes too large and too complex.
• It takes too much time to model a given situation.
• It is not possible to handle time and data.
Therefore, we use high-level Petri nets, i.e. Petri nets extended
with:
• color
• time
• hierarchy
20
To explain the three extensions we use the following example
of a hairdresser's saloon.
hairdresser ready to begin
free
client waiting
start
waiting
finish
busy
ready
Note how easy it is to model the situation with multiple hairdressers.
21
The extension with color
A token often represents an object having all kinds of attributes.
Therefore, each token has a value (color) with refers to specific features of
the object modeled by the token.
name: Sally
age: 28
hairtype: BL
free
start
waiting
name: Harry
age: 28
experience: 2
finish
busy
ready
22
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.
23
Examples
c := a+b
a
b := -a
+
b
a
-
b
c
a >=0 | b :=  a
a
b
select
if a> 0
then b:= a
else c:=a
fi
a
sqrt
b
c
Exercise:
calculate |a+b| using these buiding blocks
24
The extension with time
For performance analysis we need to model durations, delays, etc.
Therefore, each token has a timestamp and transitions determine the delay
of a produced token.
free
3
9
0
D=0
1
start
waiting
D=0
finish
D=3
busy
ready
25
The extension with hierarchy
• A mechanism to structure complex Petri nets comparable to DFD's.
• A subnet is a net composed out of places, transitions and subnets.
h1
h2
waiting
ready
h3
free
start
busy
finish
26
Exercise: remove hierarchy
h1
h2
waiting
ready
h3
free
begin
start
busy
pending end
finish
begin
pending end
27
Download