320 likes | 983 Views
Modeling based on Petri-nets . Lecture 8. 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.
E N D
Modeling based on Petri-nets. Lecture 8
High-levelPetri 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)
The classical Petri net model A Petri net is a network composed of places ( ) and transitions ( ). t2 p2 t1 p1 p4 t3 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.
p1 p4 t1 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. p2 p3
t1 t2 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. Transition t1 is not enabled, transition t2 is enabled.
t2 t2 Firing An enabled transition may fire. Firing corresponds to consuming tokens from the input places and producing tokens for the output places. Firing is atomic.
Non-determinism t1 Two transitions fight for the same token: conflict. Even if there are two tokens, there is still a conflict. t2
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.
red yr yellow rg gy green Example: traffic light
red1 red2 yr1 yr2 yellow1 yellow2 rg1 rg2 gy1 gy2 green1 green2 Two traffic lights
red1 red2 safe yr1 yr2 yellow1 yellow2 rg1 rg2 gy1 gy2 green1 green2 Two safe traffic lights
Two safe and fair traffic lights red1 red2 safe2 yr1 yr2 yellow1 yellow2 rg1 rg2 gy1 gy2 safe1 green1 green2
Example: life-cycle of a person child puberty marriage bachelor married divorce death dead
br • 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. red black rr bb
br red black rr bb Some definitions • current stateThe configuration of tokens over the places. • reachable stateA state reachable form the current state by firing a sequence of enabled transitions. • dead stateA state where no transition is enabled.
(3,2) br rr bb\br red black (1,3) (3,1) rr br bb\br (1,2) (3,0) rr bb rr bb\br (1,1) br (1,0) • 7 reachable states, 1 dead state.
Exercise: your life-cycle sleeping • How many states are reachable? • Is there a dead state? start stop active die dead
Exercise: readers and writers begin receive_mail • 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)? mail_box rest rest type_mail read_mail send_mail ready
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
hairdresser ready to begin To explain the three extensions we use the following example of a hairdresser's saloon. free client waiting start finish waiting busy ready Note how easy it is to model the situation with multiple hairdressers.
free start finish waiting busy ready 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 name: Harry age: 28 experience: 2
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.
Examples c := a+b b := -a a + a - b b c a >=0 | b := Ö a a b a sqrt b select c if a> 0 then b:= a else c:=a fi Exercise: calculate Ö |a+b| using these buiding blocks
free 0 3 9 D=0 D=0 1 start finish D=3 waiting busy ready 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 start busy finish 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 Exercise: remove hierarchy h1 h2 waiting ready h3 begin pending end begin pending end