petri nets: tutorial and applications · edward lin, university of maryland 1 petri nets: tutorial...

41
Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research University of Maryland College Park, Maryland INSTITUTE FOR SYSTEMS RESEARCH A National Science Foundation Engineering Research Center, supported by NSF, the University of Maryland, Harvard University, and Industry The 32th Annual Symposium of the Washington Operations Research - Management Science Council Washington, D.C. November 5, 1997

Upload: vandang

Post on 07-Apr-2019

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 1

Petri Nets: Tutorial and Applications

Jeffrey W. HerrmannEdward Lin

CIM LabInstitute for Systems Research

University of MarylandCollege Park, MarylandINSTITUTE FOR SYSTEMS RESEARCH

A National Science Foundation Engineering Research Center, supported by NSF, the University of Maryland, Harvard University, and Industry

The 32th Annual Symposium of the Washington Operations Research -Management Science Council

Washington, D.C.

November 5, 1997

Page 2: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 2

Outline

● Purpose

● Applications

● What is a Petri Net?

● Dynamics

● Basic Constructs

● Properties

● Analysis Methods

● Extensions of Petri Nets

● Resources for Petri Nets

● Summary

Page 3: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 3

Purpose

● To describe the fundamentals of Petri nets so thatyou begin to understand what they are and howthey are used.

● To give you resources that you can use to learnmore about Petri nets.

Page 4: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 4

Petri Net Applications

● Manufacturing, production, and scheduling systems

● Sequence controllers (Programmable LogicController, PLC)

● Communication protocols and networks

● Software -- design, specification, simulation,validation, and implementation

Page 5: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 5

Petri Nets -- Graphic Tool

● A bipartite directed graph containing places(circles), transitions (bars), and directed arcs(places <--> transitions).

Places -- buffers, locations, states

Transitions -- events, actions

Tokens -- parts

loading processing Unloading

Page 6: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 6

Petri Nets -- Mathematical Models

A Petri net is a four-tuple:PN = <P, T, I, O>P: a finite set of places, {p1, p2, ..., pn}T: a finite set of transitions, {t1, t2, ..., ts}I: an input function, (T x P) −−> {0, 1}O: an output function, (T x P) −−> {0, 1}

M0: an initial marking, P −−> N<P, T, I, O, M0> -- a marked Petri net

loading processing Unloading

Page 7: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 7

An Example

● P = {p1, p2, p3}● T = {t1, t2, t3}● I = p1 p2 p3

loading processing Unloading

p1 t1 p2 t2 p3

t

t

t

1

2

3

1 0 0

0 1 0

0 0 1

● O = p1 p2 p3

● M0 = (1, 0, 0)

t

t

t

1

2

3

0 1 0

0 0 1

1 0 0

Note:p1 is the input place of transition t1p2 is the output place of transition t1

t3

Page 8: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 8

Dynamics

● Enabling Rule:» A transition t is enabled if every input place contains at

least one token

● Firing Rule:» Firing an enabled transition

– removes one token from each input place of the transition– adds one token to each output place of the transition

loading processing Unloading

Page 9: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 9

Dynamics

loading processing Unloading

Initial State:loading processing Unloading

State after t1 is fired:

loading processing Unloading

State after t2 is fired:

loading processing Unloading

State after t3 is fired:

t1

t2

t3

Page 10: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 10

Basic Constructs

● Sequential actions

● Dependency● Conflict (decision, choice)

● Concurrency● Cycles

● Synchronization - (mutually exclusive actions,resource sharing, communication, queues)

Page 11: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 11

Sequential Actions

Each action is a transition.

Page 12: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 12

Dependency

A transition requires two inputs.

Page 13: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 13

Conflict Construct

Only one of the two transitions can fire.

Page 14: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 14

Concurrency Construct

These two sequences can occur simultaneously.

Page 15: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 15

Cycles

loading processing Unloading

Page 16: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 16

Synchronization

loading processing Unloading

Machine can process one part at once.

Page 17: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 17

Resource Sharing

loading processingpart 1

unloading

loading processingpart 2

unloading

One worker for two machines.The worker can work at one machine at a time.

resource

Page 18: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 18

Buffer (Queue)

The buffer can hold a limited number of parts.

Page 19: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 19

Communication

Program 1

Program 2

Page 20: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 20

An Example

Machine States:LoadingProcessingWaiting for unloadingUnloading

Machine 1

Machine 2

Robot

Buffer

Buffer State:Space availability

Page 21: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 21

Put It Together

Loading ProcessingWaiting

forUnloading

Unloading

Machine 1

Machine 2

Robot Buffer Available

Page 22: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 22

Properties (Questions)

Property Example

Boundedness- the number of tokens in a place is bounded

Work-in-process

Safeness- the number of tokens in a place never exceeds one

Hardware devices

Deadlock-free- none of markings in R(PN, M0) is a deadlock

Resources competing

Reachability- find R(PN, M0)

Messages delivery

Page 23: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 23

Analysis Methods

● Enumeration» Reachability Tree» Coverability Tree

● Linear Algebraic Technique» State Matrix Equation» Invariant Analysis: P-Invariant and T-invariant

● Simulation

Page 24: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 24

Reachability Tree (1)

p1

p2 p4

p3 p5

p6

t1

t2 t3

t4

Initialization: M0=(1,0,0,0,0,1)

Step 1: M0 = (1,0,0,0,0,1)

M1 = (0,1,0,1,0,1)

t1

Step 2: M0 = (1,0,0,0,0,1)

M1 = (0,1,0,1,0,1)

M2 = (0,0,1,1,0,1) M4 = (0,1,0,0,1,1)

t1

t2 t3

Page 25: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 25

Reachability Tree (2)

p1

p2 p4

p3 p5

p6

t1

t2 t3

t4

M0 = (1,0,0,0,0,1)

M1 = (0,1,0,1,0,1)

M2 = (0,0,1,1,0,1) M4 = (0,1,0,0,1,1)

M3 = (0,0,1,0,1,1)

t1

t2 t3

t3

Step 3:

Step 4: M0 = (1,0,0,0,0,1)

M1 = (0,1,0,1,0,1)

M2 = (0,0,1,1,0,1) M4 = (0,1,0,0,1,1)

M3 = (0,0,1,0,1,1)

t1

t2 t3

t3 t2

M3

Page 26: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 26

Reachability Tree (3)

M0 = (1,0,0,0,0,1)

M1 = (0,1,0,1,0,1)

M2 = (0,0,1,1,0,1) M4 = (0,1,0,0,1,1)

M3 = (0,0,1,0,1,1)

t1

t2 t3

t3 t2

t4

M0

M3

p1

p2 p4

p3 p5

p6

t1

t2 t3

t4

Step 5:

Page 27: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 27

Reachability Tree/Graph

p1

p2 p4

p3 p5

p6

t1

t2 t3

t4

M0 = (1,0,0,0,0,1)

M1 = (0,1,0,1,0,1)

M2 = (0,0,1,1,0,1) M4 = (0,1,0,0,1,1)

M3 = (0,0,1,0,1,1)

t1

t2 t3

t3 t2

t4

M0

M3

M0

M1

M2 M4

M3

t1

t2 t3

t3 t2

t4

Page 28: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 28

Reachability Tree

t1p1

t2

p3

p2

(1, 0, 0)

(1,1,0)(0,1,1)

(1,2,0) (0,2,1)(0, 0, 1)

(1,3,0) (0,3,1) (0,1,1)

t2 t1

t3 t1 t2

t3t1 t2

t3 (0,0,1)(1,4,0)

t1

(0,2,1)

t2

(0,4,1)

t2

(0,3,1)

t3

t3

Page 29: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 29

Coverability Tree (1)

t1p1

t2

p3

p2

t3

(1,0,0)

new m1 = (1,ω,0) m2 = (0,1,1) new

Step 1:t1 t2

Step 2 (m1): (1,0,0) new

new m1 = (1,ω ,0) m2 = (0,1,1) new

t1 t2

Initialization: M0 = (1,0,0) new

m1 = (1,1,0) >= (1,0,0)new

old (1,ω,0)

t1

new m3=(0,ω,1)

t2

Page 30: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 30

Coverability Tree (2)

t1p1

t2

p3

p2

t3

Step 3 (m3): (1,0,0) new

new m1=(1,ω ,0) m2=(0,1,1) new

t1 t2

old (1,ω,0)

t1

m3=(0,ω,1) new

t2

old (0,ω,1)

(1,0,0) new

new m1=(1,ω ,0) m2=(0,1,1) new

t1 t2

new (1,ω,0)

t1

m3=(0,ω,1) new

t2

old (0,ω,1)

Step 4 (m2):

m4 = (0,0,1) new

t3

t3

t3

Page 31: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 31

Coverability Tree (3)

(1,0,0) new

m1=(1,ω ,0)new

m2=(0,1,1)new

t1 t2

(1,ω,0)old

t1

m3=(0,ω,1)new

t2

old (0,ω,1)

Step 5 (m4): Coverability Tree

m4 = (0,0,1)terminate

(1, 0, 0)

(1,1,0) (0,1,1)

(1,2,0) (0,2,1) (0, 0, 1)

(1,3,0) (0,3,1) (0,1,1)

t1 t2

t3t1 t2

t3t1 t2

(0,0,1)(1,4,0)

t1

(0,2,1)

t2

(0,4,1)

t2

(0,3,1)

t3

t3

Reachability Tree

t3

t3

Page 32: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 32

Linear Algebraic Technique

● I = p1 p2 p3

loading processing Unloading

p1 t1 p2 t2 p3

t

t

t

1

2

3

1 0 0

0 1 0

0 0 1

● O = p1 p2 p3

● M0 = (1, 0, 0)

t

t

t

1

2

3

0 1 0

0 0 1

1 0 0

Incidence Matrix● A = O - I = p1 p2 p3

t

t

t

1

2

3

1 1 0

0 1 1

1 0 1

−−

State Equation: M = M0 + A, where is a vector with s elements µ µ

t3

Page 33: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 33

Linear Algebraic Technique

loading processing Unloading

p1 t1 p2 t2 p3

−−

1 1 0

0 1 1

1 0 1

[ ]1 0 0 [ ]1 0 0+=[ ]0 1 0

−−

1 1 0

0 1 1

1 0 1

[ ]1 0 0 [ ]1 1 0+=[ ]0 0 1

−−

1 1 0

0 1 1

1 0 1

[ ]1 0 0 [ ]1 1 1+=[ ]1 0 0

t1 fired

t1, t2 fired

t1 t2 t3 fired

t3

Page 34: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 34

T-Invariant

T-Invariant: YA = 0, where Y is a s element vector Y is the number of transition firings

-y1 + y3 = 0 y1 - y2 = 0 y2 - y3 = 0

−−

1 1 0

0 1 1

1 0 1= 0

y1 = y2 = y3

minimum t-invariant = (1, 1, 1)

M0

[ ]y y y1 2 3

yq → M0

Page 35: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 35

T-Invariant

loading processing Unloading

p1 t1 p2 t2 p3

(1,0,0)

(0,1,0)

(0,0,1)

(1,0,0)

(1,0,0) ---------------> (1,0,0)

(1,1,1)

t3

Page 36: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 36

P-Invariant

P-Invariant: AXT = 0, where X is a n element vector, X is the weight of each place

-x1 + x2 = 0 -x2 + x3 = 0x1 - x3 = 0

−−

1 1 0

0 1 1

1 0 1

= 0x

x

x

1

2

3

x1 = x2 = x3

minimum p-invariant = (1, 1, 1)

The quantity S = x1 M(p1) + x2 M(p2) + x3 M(p3)

Page 37: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 37

P-Invariant

loading processing Unloading

p1 t1 p2 t2 p3

(1,0,0)

(0,1,0)

(0,0,1)

(1,0,0)

The quantity S = x1 M(p1) + x2 M(p2) + x3 M(p3)

1 = 1 M(p1) + 1 M(p2) + 1 M(p3)

t3

Page 38: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 38

Simulation

● Discrete event simulation

● Same model for simulation and analysis● Need rules to resolve conflicts

● Useful for validation and visualization

Page 39: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 39

Extensions of Petri Nets

● Event Graph (marked graph, decision-free)» Each place has exactly one input transition and exactly one output transition

● Deterministic Timed Petri Nets» Deterministic time delays with transitions

● Stochastic Timed Petri Nets» Stochastic time delays with transitions

● Color Petri Nets» Tokens with different colors

● Hybrid Nets» Combine object-oriented concept into Petri nets

Page 40: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 40

Further Readings

● Petri nets home page: http://www.daimi.aau.dk/%7Epetrinet/● Petri nets mailing list: [email protected]● Coloured Petri nets: http://www.daimi.aau.dk/designCPN/● Petri nets standard: http://www.daimi.aau.dk/%7Epetrinet/standard/

● Petri Net Theory and the Modeling of Systems,by J. L. Peterson, Prentice-Hall, 1981.

● Petri Nets: An Introduction,by W. Reisig, Springer-Verlag,1985

● Petri Nets: a Tool for Design and Management of ManufacturingSystems, by J.-M. Proth, X. Xie, Wiley, 1996

● Computer Integrated Laboratory(CIM Lab) page:http://www.isr.umd.edu/Labs/CIM/

Page 41: Petri Nets: Tutorial and Applications · Edward Lin, University of Maryland 1 Petri Nets: Tutorial and Applications Jeffrey W. Herrmann Edward Lin CIM Lab Institute for Systems Research

Edward Lin, University of Maryland 41

Summary

● A graphical and mathematical tool

● Applications

● Constructs

● Properties: Boundedness, Safeness, Deadlock-free, liveness,Reachability

● Analysis Techniques:

» Reachability trees

» Coverability trees

» Linear algebraic techniques

» Simulation

● Extensions

● Resources