33
Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Modelling by Petri nets Polytechnic of Bari, ITALY

Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Embed Size (px)

Citation preview

Page 1: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Maria Pia FANTI

Dipartimento di Elettrotecnica ed Elettronica

Modelling by Petri netsModelling by Petri nets

Polytechnic of Bari, ITALY

Page 2: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

OutlineOutline

What are Petri Nets?

Definitions and basic concepts

Modelling with Petri Nets: main structures

Timed Petri nets

Conclusions

Page 3: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Petri NetsPetri Nets (PN) offer advantages because of their twofold representation: graphical and mathematical.

It is a graphical and mathematical tool for the formal description of the logical interactions and the dynamics of complex systems.

PN are particularly suited to model: Concurrency; Conflict; Sequencing; Synchronization; Sharing of limited resources;Mutual exclusion.

Page 4: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Petri NetsPetri Nets (PN) originated from the Phd thesis of Carl Adam Petri in 1962.

A web service on PN is managed at the University of Aarhus in Denmark, where a bibliography with more that 8,500 items can be found.

http://www.daimi.au.dk/PetriNets/

The main International Conference:

ATPN - Application and Theory of PN

Other conferences:

Int. IFAC conference, IEEE SMC conference, IEEE CASE, WODES, etc.

Page 5: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Main references about definitions and properties of ordinary Petri nets

Murata T., (1989), “Petri nets: properties, analysis and applications”, IEEE Proceedings, Vol. 77, no. 4, 541-580.

Peterson, J.L., (1981), Petri Net Theory and the Modeling of Systems, Prentice Hall, Englewood Cliffs, NJ, USA.

Page 6: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

DefinitionsDefinitions

A Petri net is a bipartite directed graph consisting of two kinds of nodes: places and transitions

– Places typically represent conditions within the system being modeled. They are represented by circles.

– Transitions represent events occurring in the system that may cause change in the condition of the system. They are represented by bars.

– Arcs connect places to transitions and transitions to places (never an arc from a place to a place or from a transition to a transition).

Page 7: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

DefinitionsDefinitions

Input arcs are directed arcs drawn from places to transitions, representing the conditions that need to be satisfied for the event to be activated

Output arcs are directed arcs drawn from transitions to places, representing the conditions resulting from the occurrence of the event

Page 8: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

DefinitionsDefinitions

Input places of a transition are the set of places that are connected to the transition through input arcs

Output places of a transition are the set of places to which output arcs arrive from the transition

Page 9: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Example of a PNExample of a PN

p1 – resource idle

p2 – resource busy

t1 – task arrives

t2 – task completes

p1

t2

p2

t1t1

Page 10: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

DefinitionsDefinitionsMore formally, a Petri net is described by the four-tuple PN=(P, T, Pre, Post) where:P P is the set of places and |P|=m

T is the set of transitions and |T|=n

Pre: P×TN is the pre incidence matrix, that specifies the arcs directed from places to transitionsPost: P×TN is the post incidence matrix, that specifies the arcs directed from transitions to places

Page 11: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Example of Petri netExample of Petri net

Page 12: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Incidence MatrixIncidence Matrix

Page 13: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Tokens are dots (or integers) associated with places; a place containing tokens indicates that the corresponding condition holdsMarking is a function M: PN that associates to each place a non negative number. It is a vector listing the number of tokens in each place of the net

PN DefinitionsPN Definitions

Page 14: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

M0 is the initial marking

A net system <PN, M0 > is a dynamical system

PN DefinitionsPN Definitions

Page 15: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

When input places of a transition have the required number of tokens, the transition is enabled.

An enabled transition may fire (event happens) removing one or more tokens from each input place and depositing one or more tokens in each of its output place.

PN dynamicsPN dynamics

2

p1p1

p1

p2

p2

t1

t1

3

3

2

Page 16: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Example of a PNExample of a PN

p1 – resource idle

p2 – resource busy p3 – user

t1 – task starts

t2 – task completes

p1

t2

p2

t1p3

Page 17: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Transition t2 is enabled at M0 because M0 Pre(.,t2).An enabled transition may fire (event happens) removing one token from each input place and depositing one token in each of its output place.

Enabling conditionEnabling condition

Page 18: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Firing

Page 19: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Firing

Introducing the firing vector

0

1

0

0

0

u

It holds: M=M0+ C u

Page 20: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

SequenceSequence

Modelling by Petri nets: main structuresModelling by Petri nets: main structures

Concurrency (or Parallelism)Concurrency (or Parallelism)

Page 21: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Choice (non determinism)Choice (non determinism)

Modelling by Petri nets: main structuresModelling by Petri nets: main structures

Page 22: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

SynchronizationSynchronization

Modelling by Petri nets: main structuresModelling by Petri nets: main structures

Page 23: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Limited ResourcesLimited Resources

Modelling by Petri nets: main structuresModelling by Petri nets: main structures

Page 24: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Producer/consumerProducer/consumer

Modelling by Petri netsModelling by Petri nets

Page 25: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Transmitter/receiver processTransmitter/receiver process

Modelling by Petri netsModelling by Petri nets

Page 26: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Mutual exclusion or choiceMutual exclusion or choice

Modelling by Petri nets: main structuresModelling by Petri nets: main structures

Page 27: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

A marking M’ is reachable from M if there exists a firing sequence s=t1t2..tn starting from M that results in the new marking M’

Hence: M’=M+Cu where u is the firing vector associated to s.

The reachability set of a PN system <PN,M0> is the set of all markings that are reachable from its initial marking

Reachability Analysis

Page 28: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Reachability AnalysisReachability Analysis

A reachability graph is a directed graph whose nodes are the markings in the reachability set, with directed arcs between the markings representing the marking-to-marking transitions

The directed arcs are labeled with the corresponding transition whose firing results in a change of the marking from the original marking to the new marking

7ab15e

Page 29: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Reachability AnalysisReachability Analysis

If the reachability set is infinite then the nodes of the reachability graph are infinite in number: it is necessary to build a coverability graph.

Several analysis are based on the reachability graph: behavioral analysis.

By properly identifying the frontier nodes, the generation of the reachability graph involves a finite number of steps, even if the PN is unbounded. Three type of frontier nodes: terminal (dead) nodes: no transition is enabled; duplicate nodes: already generated; infinitely reproducible nodes.

Page 30: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Reachability graphReachability graph

Page 31: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Structural properties Structural properties

The structural properties are the properties that depend on the structure of the net and on the initial marking.

Reachability

Bundness

Liveness

Conservativeness

Deadlock

Analysis may be based on the rechability graph or on the state equation

Page 32: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

Main advantage of the Petri net modeling: Main advantage of the Petri net modeling: linear algebraic structurelinear algebraic structure

While the state of a DES is non numerical the state of a Petri net is a vectorThe model of an machine that may fails:

Page 33: Maria Pia FANTI Dipartimento di Elettrotecnica ed Elettronica Modelling by Petri nets Polytechnic of Bari, ITALY

For performance and dependability analysis it is necessary to introduce the duration of the events associated to PN transitions.

Hence Petri nets are extended by associating time with the firing of transitions, resulting in timed Petri nets.

Deterministic timed transitions are typically represented by black boxes

Powerful modeling tools:Powerful modeling tools:timed Petri Netstimed Petri Nets

t1 t2

2 s