Petri nets ee249 fall 2000
This presentation is the property of its rightful owner.
Sponsored Links
1 / 107

Petri Nets ee249 Fall 2000 PowerPoint PPT Presentation


  • 34 Views
  • Uploaded on
  • Presentation posted in: General

Petri Nets ee249 Fall 2000. Marco Sgroi Most slides borrowed from Luciano Lavagno’s lecture ee249 (1998). Models Of Computation for reactive systems. Main MOCs: Communicating Finite State Machines Dataflow Process Networks Discrete Event Codesign Finite State Machines Petri Nets

Download Presentation

Petri Nets ee249 Fall 2000

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Petri nets ee249 fall 2000

Petri Netsee249 Fall 2000

Marco Sgroi

Most slides borrowed from

Luciano Lavagno’s lecture ee249 (1998)


Models of computation for reactive systems

Models Of Computationfor reactive systems

  • Main MOCs:

    • Communicating Finite State Machines

    • Dataflow Process Networks

    • Discrete Event

    • Codesign Finite State Machines

    • Petri Nets

  • Main languages:

    • StateCharts

    • Esterel

    • Dataflow networks


Outline

Outline

  • Petri nets

    • Introduction

    • Examples

    • Properties

    • Analysis techniques

    • Scheduling


Petri nets pns

Petri Nets (PNs)

  • Model introduced by C.A. Petri in 1962

    • Ph.D. Thesis: “Communication with Automata”

  • Applications: distributed computing, manufacturing, control, communication networks, transportation…

  • PNs describe explicitly and graphically:

    • sequencing/causality

    • conflict/non-deterministic choice

    • concurrency

  • Asynchronous model (partial ordering)

  • Main drawback: no hierarchy


Petri net graph

Petri Net Graph

  • Bipartite weighted directed graph:

    • Places: circles

    • Transitions: bars or boxes

    • Arcs: arrows labeled with weights

  • Tokens: black dots

p2

t2

2

t1

p1

p4

3

t3

p3


Petri net

Petri Net

  • A PN (N,M0) is a Petri Net Graph N

    • places: represent distributed state by holding tokens

      • marking (state) M is an n-vector (m1,m2,m3…), where mi is the non-negative number of tokens in place pi.

      • initial marking (M0) is initial state

    • transitions: represent actions/events

      • enabled transition: enough tokens in predecessors

      • firing transition: modifies marking

  • …and an initial marking M0.

p2

t2

2

t1

p1

p4

3

Places/Transition: conditions/events

t3

p3


Transition firing rule

Transition firing rule

  • A marking is changed according to the following rules:

    • A transition is enabled if there are enough tokens in each input place

    • An enabled transition may or may not fire

    • The firing of a transition modifies marking by consuming tokens from the input places and producing tokens in the output places

2

2

2

2

3

3


Concurrency causality choice

Concurrency, causality, choice

t1

t2

t5

t3

t4

t6


Concurrency causality choice1

Concurrency, causality, choice

t1

Concurrency

t2

t5

t3

t4

t6


Concurrency causality choice2

Concurrency, causality, choice

t1

t2

t5

Causality, sequencing

t3

t4

t6


Concurrency causality choice3

Concurrency, causality, choice

t1

t2

t5

Choice,

conflict

t3

t4

t6


Concurrency causality choice4

Concurrency, causality, choice

t1

t2

t5

Choice,

conflict

t3

t4

t6


Confusion

Confusion

  • t1 and t2 are concurrent but their firing order is not irrelevant for conflict resolution (not local choice)

  • From (1,1,0,0,0):

    • solving a conflict (t1,t2)(0,0,0,0,1),(0,0,1,1,0)

    • not solving a conflict (t2,t1)(0,0,1,1,0)

p1

p3

t1

p5

t3

p4

p2

t2


Communication protocol

Communication Protocol

Send msg

Receive msg

P2

P1

Send Ack

Receive Ack


Communication protocol1

Communication Protocol

Send msg

Receive msg

P2

P1

Send Ack

Receive Ack


Communication protocol2

Communication Protocol

Send msg

Receive msg

P2

P1

Send Ack

Receive Ack


Communication protocol3

Communication Protocol

Send msg

Receive msg

P2

P1

Send Ack

Receive Ack


Communication protocol4

Communication Protocol

Send msg

Receive msg

P2

P1

Send Ack

Receive Ack


Communication protocol5

Communication Protocol

Send msg

Receive msg

P2

P1

Send Ack

Receive Ack


Producer consumer problem

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem1

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem2

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem3

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem4

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem5

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem6

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem7

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem8

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem9

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem10

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem11

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem12

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem13

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer problem14

Producer-Consumer Problem

Produce

Buffer

Consume


Producer consumer with priority

Producer-Consumer with priority

A

Consumer B can

consume only if

buffer A is empty

Inhibitor arcs

B


Pn properties

PN properties

  • Behavioral: depend on the initial marking (most interesting)

    • Reachability

    • Boundedness

    • Schedulability

    • Liveness

    • Conservation

  • Structural: do not depend on the initial marking (often too restrictive)

    • Consistency

    • Structural boundedness


Reachability

Reachability

  • Marking M is reachable from marking M0 if there exists a sequence of firingss = M0 t1 M1 t2 M2… M that transforms M0 to M.

  • The reachability problem is decidable.

p2

t2

M0 = (1,0,1,0)

t3

M1 = (1,0,0,1)

t2

M = (1,1,0,0)

p1

t1

p4

t3

p3

M0 = (1,0,1,0)

M = (1,1,0,0)


Liveness

Liveness

  • Liveness: from any marking any transition can become fireable

    • Liveness implies deadlock freedom, not viceversa

Not live


Liveness1

Liveness

  • Liveness: from any marking any transition can become fireable

    • Liveness implies deadlock freedom, not viceversa

Not live


Liveness2

Liveness

  • Liveness: from any marking any transition can become fireable

    • Liveness implies deadlock freedom, not viceversa

Deadlock-free


Liveness3

Liveness

  • Liveness: from any marking any transition can become fireable

    • Liveness implies deadlock freedom, not viceversa

Deadlock-free


Boundedness

Boundedness

  • Boundedness: the number of tokens in any place cannot grow indefinitely

    • (1-bounded also called safe)

    • Application: places represent buffers and registers (check there is no overflow)

Unbounded


Boundedness1

Boundedness

  • Boundedness: the number of tokens in any place cannot grow indefinitely

    • (1-bounded also called safe)

    • Application: places represent buffers and registers (check there is no overflow)

Unbounded


Boundedness2

Boundedness

  • Boundedness: the number of tokens in any place cannot grow indefinitely

    • (1-bounded also called safe)

    • Application: places represent buffers and registers (check there is no overflow)

Unbounded


Boundedness3

Boundedness

  • Boundedness: the number of tokens in any place cannot grow indefinitely

    • (1-bounded also called safe)

    • Application: places represent buffers and registers (check there is no overflow)

Unbounded


Boundedness4

Boundedness

  • Boundedness: the number of tokens in any place cannot grow indefinitely

    • (1-bounded also called safe)

    • Application: places represent buffers and registers (check there is no overflow)

Unbounded


Conservation

Conservation

  • Conservation: the total number of tokens in the net is constant

Not conservative


Conservation1

Conservation

  • Conservation: the total number of tokens in the net is constant

Not conservative


Conservation2

Conservation

  • Conservation: the total number of tokens in the net is constant

Conservative

2

2


Analysis techniques

Analysis techniques

  • Structural analysis techniques

    • Incidence matrix

    • T- and S- Invariants

  • State Space Analysis techniques

    • Coverability Tree

    • Reachability Graph


Incidence matrix

-100

11-1

0-11

A=

Incidence Matrix

t2

p1

t1

p2

p3

  • Necessary condition for marking M to be reachable from initial marking M0:

    there exists firing vector v s.t.:

    M = M0 + A v

t1

t2

t3

p1

t3

p2

p3


State equations

p1

t1

p2

p3

-100

11-1

0-11

A=

t3

1

0

1

0

0

1

1

0

0

-100

11-1

0-11

1

0

1

=

+

v1 =

State equations

t2

  • E.g. reachability of M =|0 0 1|T from M0 = |1 0 0|T

but also v2 = | 1 1 2 |T or any vk = | 1 (k) (k+1) |T


Necessary condition only

Necessary Condition only

t2

t3

t1

2

2

Firing vector: (1,2,2)

Deadlock!!


State equations and invariants

-100

11-1

0-11

A=

State equations and invariants

  • Solutions of Ax = 0 (in M = M0 + Ax, M = M0)

    T-invariants

    • sequences of transitions that (if fireable) bring back to original marking

    • periodic schedule in SDF

    • e.g. x =| 0 1 1 |T

t2

p1

t1

p2

p3

t3


Application of t invariants

Application of T-invariants

  • Scheduling

    • Cyclic schedules: need to return to the initial state

i

o

+

*k2

*k1

T-invariant: (1,1,1,1,1)

Schedule: i *k2 *k1 + o


State equations and invariants1

State equations and invariants

  • Solutions of yA = 0

    S-invariants

    • sets of places whose weighted total token count does not change after the firing of any transition (y M = y M’)

    • e.g. y =| 1 1 1 |T

t2

p1

t1

p2

p3

-110

01-1

0-11

AT=

t3


Application of s invariants

Application of S-invariants

  • Structural Boundedness: bounded for any finite initial marking M0

  • Existence of a positive S-invariant is CS for structural boundedness

    • initial marking is finite

    • weighted token count does not change


Summary of algebraic methods

Summary of algebraic methods

  • Extremely efficient

    (polynomial in the size of the net)

  • Generally provide only necessary or sufficient information

  • Excellent for ruling out some deadlocks or otherwise dangerous conditions

  • Can be used to infer structural boundedness


Coverability tree

Coverability Tree

  • Build a (finite) tree representation of the markings

    Karp-Miller algorithm

  • Label initial marking M0 as the root of the tree and tag it as new

  • While new markings exist do:

    • select a new marking M

    • if M is identical to a marking on the path from the root to M, then tag M as old and go to another new marking

    • if no transitions are enabled at M, tag M dead-end

    • while there exist enabled transitions at M do:

      • obtain the marking M’ that results from firing t at M

      • on the path from the root to M if there exists a marking M’’ such that M’(p)>=M’’(p) for each place p and M’ is different from M’’, then replace M’(p) by w for each p such that M’(p) >M’’(p)

      • introduce M’ as a node, draw an arc with label t from M to M’ and tag M’ as new.


Coverability tree1

t2

p1

t1

p2

p3

p4

t3

Coverability Tree

1000

  • Boundedness is decidable

    with coverability tree


Coverability tree2

Coverability Tree

1000

  • Boundedness is decidable

    with coverability tree

t1

0100

t2

p1

t1

p2

p3

p4

t3


Coverability tree3

Coverability Tree

1000

  • Boundedness is decidable

    with coverability tree

t1

0100

t2

p1

t1

p2

p3

t3

0011

p4

t3


Coverability tree4

Coverability Tree

1000

  • Boundedness is decidable

    with coverability tree

t1

0100

t2

p1

t1

p2

p3

t3

0011

t2

p4

0101

t3


Coverability tree5

Coverability Tree

1000

  • Boundedness is decidable

    with coverability tree

    Cannot solve the reachability and liveness problems

t1

0100

t2

p1

t1

p2

p3

t3

0011

t2

010

p4

t3


Coverability tree6

Coverability Tree

1000

  • Boundedness is decidable

    with coverability tree

    Cannot solve the reachability and liveness problems

t1

0100

t2

p1

t1

p2

p3

t3

0011

t2

010

p4

t3


Reachability graph

t2

p1

t1

p2

p3

t3

Reachability graph

  • For bounded nets the Coverability Tree is called Reachability Tree since it contains all possible reachable markings

100


Reachability graph1

Reachability graph

t2

  • For bounded nets the Coverability Tree is called Reachability Tree since it contains all possible reachable markings

p1

t1

p2

p3

100

t1

010

t3


Reachability graph2

Reachability graph

t2

  • For bounded nets the Coverability Tree is called Reachability Tree since it contains all possible reachable markings

p1

t1

p2

p3

100

t1

010

t3

t3

001


Reachability graph3

Reachability graph

t2

  • For bounded nets the Coverability Tree is called Reachability Tree since it contains all possible reachable markings

p1

t1

p2

p3

100

t1

010

t3

t2

t3

001


Subclasses of petri nets

Subclasses of Petri nets

  • Reachability analysis is too expensive

  • State equations give only partial information

  • Some properties are preserved by reduction rules

    e.g. for liveness and safeness

  • Even reduction rules only work in some cases

  • Must restrict class in order to prove stronger results


Subclasses of petri nets sms

Subclasses of Petri nets: SMs

  • State machine: every transition has at most 1 predecessor and 1 successor

  • Models only causality and conflict

    • (no concurrency, no synchronization of parallel activities)


Subclasses of petri nets mgs

Subclasses of Petri nets: MGs

  • Marked Graph: every place has at most 1 predecessor and 1 successor

  • Models only causality and concurrency (no conflict)

  • Same as underlying graph of SDF


Subclasses of petri nets fc nets

Subclasses of Petri nets: FC nets

  • Free-Choice net: every transition after choice has exactly1 predecessor


Free choice petri nets fcpn

Free-Choice Petri Nets (FCPN)

Free-Choice (FC)

t1

t2

Confusion (not-Free-Choice)

Extended Free-Choice

  • Free-Choice: the outcome of a choice depends on the value of a token (abstracted non-deterministically) rather than on its arrival time.

    • Easy to analyze


Free choice nets

Free-Choice nets

  • Introduced by Hack (‘72)

  • Extensively studied by Best (‘86) and Desel and Esparza (‘95)

  • Can express concurrency, causality and choice without confusion

  • Very strong structural theory

    • necessary and sufficient conditions for liveness and safeness, based on decomposition

    • concurrency, causality and choice relations are mutually exclusive

    • exploits duality between MG and SM


Mg sm decomposition

MG (& SM) decomposition

  • An Allocation is a control function that chooses which transition fires among several conflicting ones ( A: P T).

  • Eliminate the subnet that would be inactive if we were to use the allocation...

  • Reduction Algorithm

    • Delete all unallocated transitions

    • Delete all places that have all input transitions already deleted

    • Delete all transitions that have at least one input place already deleted

  • Obtain a Reduction(one for each allocation) that is a conflict free subnet


Mg reduction and cover

MG reduction and cover

  • Choose one successor for each conflicting place:


Mg reduction and cover1

MG reduction and cover

  • Choose one successor for each conflicting place:


Mg reduction and cover2

MG reduction and cover

  • Choose one successor for each conflicting place:


Mg reduction and cover3

MG reduction and cover

  • Choose one successor for each conflicting place:


Mg reduction and cover4

MG reduction and cover

  • Choose one successor for each conflicting place:


Mg reductions

MG reductions

  • The set of all reductions yields a cover of MG components (T-invariants)


Mg reductions1

MG reductions

  • The set of all reductions yields a cover of MG components (T-invariants)


Sm reduction and cover

SM reduction and cover

  • Choose one predecessor for each transition:


Sm reduction and cover1

SM reduction and cover

  • Choose one predecessor for each transition:


Sm reduction and cover2

SM reduction and cover

  • Choose one predecessor for each transition:

  • The set of all reductions yields a cover of SM components (S-invariants)


Hack s theorem 72

Hack’s theorem (‘72)

  • Let N be a Free-Choice PN:

    • N has a live and safe initial marking (well-formed) if and only if

      • every MG reduction is strongly connected and not empty, and

        the set of all reductions covers the net

      • every SM reduction is strongly connected and not empty, and

        the set of all reductions covers the net


Hack s theorem

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem1

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem2

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem3

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem4

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem5

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem6

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem7

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem8

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem9

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem10

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem11

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem12

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem13

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem14

Hack’s theorem

  • Example of non-live (but safe) FCN


Hack s theorem15

Hack’s theorem

  • Example of non-live (but safe) FCN

Not live


Other results for lsfc nets

Other results for LSFC nets

  • Let t1 and t2 be two transitions of a live and safe Free-Choice net.

    Then t1 and t2 are:

    • sequential if

      there exists a simple cycle to which both belong

    • concurrent if

      they are not ordered, and

      there exists an MG component to which both belong

    • conflicting otherwise


Summary of lsfc nets

Summary of LSFC nets

  • Largest class for which structural theory really helps

  • Structural component analysis may be expensive

    (exponential number of MG and SM components in the worst case)

  • But…

    • number of MG components is generally small

    • FC restriction simplifies characterization of behavior


Petri net extensions

Petri Net extensions

  • Add interpretation to tokens and transitions

    • Colored nets (tokens have value)

  • Add time

    • Time/timed Petri Nets (deterministic delay)

      • type (duration, delay)

      • where (place, transition)

    • Stochastic PNs (probabilistic delay)

    • Generalized Stochastic PNs (timed and immediate transitions)

  • Add hierarchy

    • Place Charts Nets


Summary of petri nets

Summary of Petri Nets

  • Graphical formalism

  • Distributed state (including buffering)

  • Concurrency, sequencing and choice made explicit

  • Structural and behavioral properties

  • Analysis techniques based on

    • linear algebra (only sufficient)

    • structural analysis (necessary and sufficient only for FC)


  • Login