Title: I.S. Behaviour Using Petri Nets
1I.S. Behaviour Using Petri Nets
- Some Problems with statecharts
- They do not represent the resources (data,
objects or message instances). - They lack of mathematical semantics for computing
on them (analysis, verification, ..) - They cope more on state changes and not on object
dynamics.
2Petri Nets (PNs)
- Model introduced by C.A. Petri in 1962
- Ph.D. Thesis Communication with Automata
- Applications distributed computing,
manufacturing, control, information systems,
communication networks, transportation - PNs describe explicitly and graphically
- sequencing/causality
- conflict/non-deterministic choice
- concurrency
3Simple Petri Nets Introduction
- General phylosophy under Petri nets
- In any software (information) system, we have
ressources (e.g. data, objects, events, real
ressources printers, buffers, ...) . - There is generally, a number of instances for
each kind of ressource. - Actions (behaviour, dynamics) in the system
allows - consuming (using) some ressources and
producing new ones or changing existing ones
(under some conditions).
4Simple Petri Nets Introduction
- With each kind of ressource, a PLACE graphically
as circle is associated. - Ressource instances are included as BLACK DOTS
(called TOKENS) within the corresponding
ressource kind place. - Actions called TRANSITIONS are graphically
represented as a BOX or RECTANGLE. - Ressources consumption are captured by (INPUT)
ARCS---valuted or inscribed by the numbers of
required ressouces--- From the corresponding
ressource place to the associated action box.
5Simple Petri Nets Introduction
- Ressources production or changes are captured by
(OUTPUT) ARCS---valuted or inscribed by the
numbers of produced ressouces--- From the
corresponding ressource place to the associated
action box. - THAT IS, PETRI NETS ARE BIPARTITE GRAPHS.
6Simple Petri Nets Introduction
p1
p2
3
1
t1
p1 Budgetary items p2 personne to be
recruted p3 employees.
1
p3
214
7Simple Petri Nets Basic definitions
- A Petri nets in a five tuples PN (P, T, W, M0)
- P p1,p2, ....,pn is a finite sets of places
(as circles) - T t1, t2, ...,tq is a finite set of
transitions (as boxes) - F ? (P x T) ? (T X P) is a finite set of arcs.
An input (resp. output) ) arc joins a place to
transition (resp. transition to place). NEVER
PLACE TO PLACE or TRANSITION TO TRANSITION. - W P ? 1,2,... is a weight function attached
to the arcs. If the weight in missing it is
implicitly one. - M0 P ? 0,1,2,.... is the intial marking.
M0(p), p ? P is the marking (i.e. numbers of
tokens) of the place p.
8Graphical representation of a classical Petri net.
9Simple Petri Nets Basic definitions
- Notations
- ? t the set of input places of transition t.
that is the set of places p such that (p,t) ? F. - t? the set of output places of transition t.
That is, p such that (t,p) ? F. - ?p the set of input transitions of place p.
that is the set of transitions such that (t,p) ?
F. - p? the set of output places of transition t.
That is, t such that (p,t) ? F.
10Simple Petri Nets Basic definitions
- Dynamics of Petri nets
- A transtion t is said to be enabled if, whatever
p ? ? t , p contains a number of tokens greater
of equal to W(p,t) (i.e. M(p) ? W(p,t)) - Firing an enabled transition t, consists in
- Removing W(p,t) tokens from each p ? ? t
- Adding W(t, p) tokens from each p ?t?
- That is, M(p) M(p) W(p,t) W(t,p)
- A sequence of transitions firing is generally
represented by ? ltti1, ti2 , ....., tikgt, and
the corresponding resulting marking by M0 --
?--Mk
11Modeling with Petri Nets
12Modeling with Petri Nets
13Communication Protocol
Send msg
Receive msg
P1
P2
Send Ack
Receive Ack
14Producer-Consumer Problem
Produce
Buffer
Consume
15Simple Petri Nets Basic definitions
- Incidence matrix
- A aij
- is an n ? m matrix of integers and its typical
- entry is given by
- aij aij - aij-
- Where aij w(i,j) is the weight of the arc from
transition - i to its output place j and aij- w(j.i) is the
weight of the - arc to transition i from its input place j.
16Simple Petri Nets Basic definitions
- Given an initial marking M0, let ? be a firiable
sequence of transitions which applies to M0. - The counting vector V? of is the vector V?
v1,v2,..,vq is the numbers of times tj is
included in ?. - If M is the marking obtained by firing ?, then
Mt M0t AV?t . With t denotes the transpose.
17Simple Petri Nets Basic definitions
t4
t1
t2
p2
p1
4
2
t3
p3
2
2
p4
18Simple Petri Nets Basic definitions
- 1 -2 -1 0
- A 0 4 0 -1
- 0 0 1 -1
- 0 0 -2 2
- Let M0 3,0,0,2 and ? ltt2,t3,t4gt, that is
- V? 0,1,1,1 . Then M 0, 3, 0, 2 using the
formulas.
19PN 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
20Reachability
- Marking M is reachable from marking M0 if there
exists a sequence of firings s 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)
t1
p1
p4
t3
p3
M0 (1,0,1,0) M (1,1,0,0)
21Liveness
- Liveness from any marking any transition can
become fireable - Liveness implies deadlock freedom, not viceversa
Not live
22Boundedness
- 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
23Conservation
- Conservation the total number of tokens in the
net is constant
Not conservative
24Analysis techniques
- Structural analysis techniques
- Incidence matrix
- T- and S- Invariants
- State Space Analysis techniques
- Coverability Tree
- Reachability Graph
25Incidence Matrix
t2
p1
p2
p3
t1
t1
t2
t3
p1
t3
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
26State equations
- E.g. reachability of M 0 0 1T from M0 1 0
0T
t2
but also v2 1 1 2 T or any vk 1 (k)
(k1) T
27State 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
p2
p3
t1
t3
28Application 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
29State 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
p2
p3
t1
-1 1 0 0 1 -1 0 -1 1
AT
t3
30Application 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
31Reachability graph
t2
p1
p2
p3
t1
100
t1
010
t3
t2
t3
001
- For bounded nets the Coverability Tree is called
Reachability Tree since it contains all possible
reachable markings