160 likes | 530 Views
SE-561 Math Foundations Petri Nets - I I. Dr. Jiacun Wang Department of Software Engineering Monmouth University. Review: Petri Nets. A Petri net N is a tuple N = { P , T , I , O , M 0 }, where P is a finite set of places, graphically represented by circles
E N D
SE-561Math FoundationsPetri Nets - II Dr. Jiacun Wang Department of Software Engineering Monmouth University Jiacun Wang
Review: Petri Nets A Petri net N is a tuple N = {P, T, I, O, M0}, where • P is a finite set of places, graphically represented by circles • T is a finite set of transitions, graphically represented by boxes • Places P and transitions T are disjoint (P ∩T = f), • I: P × T N (N = {0, 1, 2, …}) is the pre-incidence function representing input arcs, • O: T × P N (N = {0, 1, 2, …}) is the post-incidence function representing output arcs, • M0 : P N is the initial marking representing the initial distribution of tokens. Jiacun Wang
t1 p1 p2 t2 t3 Review: Transition Firing • A transition t is enabled at marking Mi if and only if Mi≥ I(t) • Let E(Mi) be the set of all transitions enabled at Mi. Then t E(Mi). • Suppose that the firing of t takes the Petri net from Mi to Mj. Then Mj= Mi-I(t) + O(t) Denoted by Mi[t>Mj • Example P = {p1, p2} T = {t1, t2, t3} I(t1) = (1, 1), I(t2) = (2, 0), I(t3) = (0, 2) O(t1) = (1, 0), O(t2) = (0, 1), O(t3) = (0, 1) M0 = (2, 1) E(M0) = {t1, t2} M0[t1> M1 where M1= (3, 1) Jiacun Wang
High-Level Petri Nets: Motivation • Up to now, we allowed places to be occupied by only “black” tokens. • Traffic light example: Three lights, one color per light, one place for every light. • Suppose we have one light that can be either red or green. • Two attempts at modeling this situation: Jiacun Wang
High-Level Petri Nets: Motivation (cont.) • If we had not just black tokens, but colored ones (e.g. red, green), we could construct a more natural model: • More generally, we could allow arbitrary values as tokens, e.g. to model numeric variables: green token red token 1 5 Jiacun Wang
High-Level Petri Nets: Places • A general solution is to assign a type to every place, i.e. a set of token values that are permitted on the place: • In general, a place may contain a multiset of its type. Jiacun Wang
High-Level Petri Nets: Transitions • In meaningful models, we need transitions to reason about the values of tokens: Switching the traffic light: Increasing variable: Jiacun Wang
High-Level Petri Nets: Transitions (cont.) • Suppose we have two processes competing for a common resource. If both try to access the resource simultaneously, there is a ‘referee’ who decides which process should have priority over the other: Jiacun Wang
High-Level Petri Nets: Definition • A high-level Petri net (HL-net) is a tuple N = (P, T, I, O, V, S, C, M0), where • P, T, I, O are as usual; • V is a set of token values; • S: P 2Vis a type assignment for places; • C(t) is the firing condition of transition t (see next slide). • M0 : P × V N is the initial marking. Jiacun Wang
Transition Firing Conditions • A firing condition decides which tokens may flow out of the pre-places and into the post-places of a transition. • Formally, if we let t be the sum of the arc weights leading into and out of t, then the signature of Ct is Ct : Vt ! {false, true}. • In figures, we place variable names onto the arcs and equip transitions with boolean expressions over these variables, like this: Jiacun Wang
Transition Firing Conditions (cont.) • If a particular assignment of token values to variables evaluates to true, then the transition may fire under that assignment. • Firing under some assignment is possible if for every pre-place p, p contains the token values assigned to the variables that are on the arc from p to t. • Firing removes those tokens and puts corresponding tokens on the post-places. • The assignment must respect the types; e.g. if v is the variable on the arc from place p to transition t, then v must be assigned to some value from S(p). Jiacun Wang
Example 1 • For instance, in the following example, the transition could fire under the assignments (‘x = 1, x’ = 2), (‘x = 2, x’ = 3), (‘x = 3, x’ = 4), (‘x = 4, x’ = 5). • In the given marking, we can remove the 2 token and replace it by a 3 token. Jiacun Wang
Example 2 • In the common-resource example, suppose the prioritised process is changed after every access: Jiacun Wang
From High-Level Petri Nets to Ordinary Petri Nets: Places • High-level nets allow easier modeling, but they are equally expressive, provided that the set of token values is finite. • For each high-level place p, create an ordinary place pvfor each v S(p). • If M0(p, v) = k, then put k initial tokens on the ordinary place pv. Jiacun Wang
From High-Level Petri Nets to Ordinary Petri Nets: Transitions • For each high-level transition t, create an ordinary transition tafor each assignment under which t may fire. • If (p, t) is a high-level arc with variable x, connect pvto tain the ordinary net, where v is the value of x in a. • Arcs from transitions to places are treated analogously. Jiacun Wang
Final Exam • Open book, open slides, open … • No laptop • Set theory: Venn diagram • Functions: 1-to-1, onto. • Graph theory: Graph matrix, Euler paths/circuits, Hamilton paths/circuits • Petri nets: Given a Petri net, write its formal definition and list all reachable markings. • Petri nets: Petri net modeling according to specification Jiacun Wang