concurrent systems modeling using petri nets – part ii

40
(c) Wil van der Aalst, Eindhoven University of Technology PN-1 Concurrent Systems Modeling using Petri Nets – Part II Marlon Dumas (Based on lecture material by Wil van der Aalst Eindhoven University of Technology, The Netherlands http://www.workflowcourse.com)

Upload: others

Post on 30-Apr-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-1

Concurrent Systems Modeling using Petri

Nets – Part II Marlon Dumas

(Based on lecture material by Wil van der Aalst

Eindhoven University of Technology, The Netherlands http://www.workflowcourse.com)

Page 2: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-2

Classical Petri nets - Recap

•  Place: passive element •  Transition: active element •  Arc: causal relation •  Token: elements subject to change

The state (space) of a Petri net is a distribution of tokens across its places. Transition firing move the net from one state to another.

Page 3: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Today’s agenda

1.  Patterns of Petri net modeling 2.  Expressiveness limitations of Petri nets 3.  Introduction to Petri net analysis

PN-3

Page 4: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-4

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.

Page 5: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-5

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.

Page 6: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-6

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.

Page 7: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-7

Typical Petri net structures

•  Causality •  Parallelism (AND-split - AND-join) •  Choice (XOR-split – XOR-join) •  Iteration (XOR-join - XOR-split) •  Capacity constraints

– Feedback loop – Mutual exclusion – Alternating

Page 8: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-8

Causality

Page 9: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-9

Parallelism

Page 10: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-10

Parallelism: AND-split

Page 11: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-11

Parallelism: AND-join

Page 12: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-12

Choice: XOR-split

Page 13: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-13

Choice: XOR-join

Page 14: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Woped short-cuts for XOR-split/join

PN-14

Page 15: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-15

Iteration: 1 or more times

XOR-join before XOR-split

Page 16: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-16

Capacity constraints: feedback loop

Page 17: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-17

Capacity constraint: example

The room has a capacity of 2, 1 person is in the room

wait enter before make_picture after leave gone

free

Page 18: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Capacity constraint: exercise

•  Pipelined factory •  Two machines, one

robot, one buffer •  Robot moves parts

from raw line to M1 to buffer, to M2 and finally to finished line

•  Buffer can hold maximum 7 parts

PN-18

Inspired by an exercise of Prof. R. Wattenhofer, ETH Zürich

Page 19: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-19

Capacity constraints: mutual exclusion

Page 20: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-20

Capacity constraints: alternating

Page 21: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-21

Example: Mutual exclusion with alternation

rg1

go1

or1

r1

g1

o1

rg2

go2

or2

r2

g2

o2

x

How to make them alternate?

Page 22: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Not everything is possible

•  Petri nets are not Turing complete – Otherwise we wouldn’t be able to fully analyze them

(see later)

•  Limitations – Zero testing – Priority

PN-22

Page 23: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-23

Modeling problem (1): Zero testing

•  Transition t should fire if place p is empty.

t ?

p

Page 24: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-24

Solution

•  Only works if place is N-bounded

t N input and output arcs

Initially there are N tokens

p

p’

Page 25: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-25

Modeling problem (2): Priority

•  Transition t1 has priority over t2

t1

t2

?

Hint: similar to Zero testing!

Page 26: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-26

Theoretical Results

•  Extensions have been proposed to tackle these problems, e.g., inhibitor arcs.

•  These extensions extend the modeling power up to 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).

Page 27: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-27

Exercise: Witness statements

•  As part of the process of handling insurance claims, we need to handle witness statements.

•  There may any number of witnesses per claim. The number is determined when the claim is lodged. After an initialization step (one per claim), each of the witnesses is registered and contacted (N witnesses per claim in parallel). Only after all witnesses have contacted a report is made (one report per claim).

•  Can you model this using a Petri net?

Page 28: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-28

Quick Intro to Petri net analysis: Reachability Graph •  Graph containing one node for each reachable

state; an edge indicates that the system can move from the source state to the target state through one transition firing

•  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.

Page 29: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Example: How does this game end?

PN-29

red

rr

rb

bb

black

•  Hint: initially the game is in state “3 red + 2 blacks” and there are three transitions from this initial state: rr, rb and bb. Transition “rr” leads to state “1 red + 3 blacks”.

Page 30: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-30

Example: reachability graph red

rr

rb

bb

black

(3,2)

(1,3) (1,2)

(3,1) (3,0)

(1,1)

(1,0) Nodes in the reachability graph can be represented by a vector “(3,2)” or as “3 red + 2 black”.

Page 31: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

PN-31

Different types of states

•  Initial state: Initial distribution of tokens. •  Reachable state: Reachable from initial state. •  Final state (also referred to as “dead states”):

No transition is enabled. •  Home state (also referred to as home marking):

It is always possible to return (i.e., it is reachable from any reachable state).

How to recognize these states in the reachability

graph?

Page 32: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Properties of Petri nets •  A Petri net is bounded iff for every place s, there

is a number b ≥ 0 such that for every reachable marking M, the number of tokens in place s is ≤ b

PN-32

Page 33: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Not bounded è Infinite Reachability Graph

PN-33

rg1

go1

or1

r1

g1

o1

rg2

go2

or2

r2

g2

o2

x

Page 34: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Coverability graph

•  Similar to reachability graph but unbounded places can hold an “infinite” number of tokens

•  Supported by Woped

PN-34

Page 35: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Properties of Petri nets •  A Petri net is bounded iff for every place s, there

is a number b ≥ 0 such that for every reachable marking M, the number of tokens in place s is ≤ b

•  A Petri net is live iff for every reachable marking M and every transition t, there is a marking M′ reachable from M, which enables t (all reachable markings are home markings)

PN-35

Page 36: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Not live

PN-36

•  We can make this Petri net live by modifying just one arc. Which one?

Page 37: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Properties of Petri nets •  A Petri net is bounded iff for every place s, there

is a number b ≥ 0 such that for every reachable marking M, the number of tokens in place s is ≤ b

•  A Petri net is live iff for every reachable marking M and every transition t, there is a marking M′ reachable from M, which enables t (all reachable markings are home markings)

•  A Petri net is deadlock-free iff there a reachable marking M that enables no transitions? (i.e. no final states)

PN-37

Page 38: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Not deadlock-free

•  The deadlock can be eliminated by deleting one arc. Which one? PN-38

Page 39: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Is this net bounded? live? deadlock-free?

PN-39

Page 40: Concurrent Systems Modeling using Petri Nets – Part II

(c) Wil van der Aalst, Eindhoven University of Technology

Homework 5: Petri nets

•  https://courses.cs.ut.ee/2016/sm/Main/Assessment •  Can be done in teams of up to 4 students

PN-40