Generalized stochastic Petri nets GSPN Xiaolan XIE Ecole Nationale Supérieure des Mines de Saint Etienne 1 PLAN 1. Introduction to stochastic Petri nets by examples 2. Petri nets with inhibitors and priority 4. Generalized stochastic Petri nets 5. Applications 6. Extensions 2 2. Introduction to GSPN by examples 3 Example 1 : Consider an unreliable machine with: 1/ : mean time between failures (MTTF) 1/ : mean time to repair (MTTR) 1/p : mean processing time state-transition diagram of CTMC : Stochastic Petri net model : p1 p3 p2 t2 (p) t1 t3 immediate tr. 1 0 Legend: p t4 ( ) t5 ( ) p4 4 timed tr. Reachability graph : p1 p3 p2 t4 0001 1000 t1 0100 t5 t2 (p) t1 t4 ( ) t3 t5 ( ) t2 p4 0010 Removing transient states leads to an isomorphic CTMC : 0100 0001 5 p t3 Results : • • Failure rate (frequence of t4) : • Production rate (frequence of t2) : pp Remark : The conflict between t2 and t4 is solved by competition of clocks (failure models) p1 p3 p2 0100 0001 t2 (p) t1 p t4 ( ) t5 ( ) p4 6 t3 Example 2 : • Two types of products P1 and P2 are produced. • The production of each product requires two operations with - the first operation on a shared flexible machine - and the second operation on a dedicated machine. • P1 has priority to the shared machine but cannot preempt on-going operations • There is at most one product of each type in the system at all moment • When the production of a product is finished, a new one of the same type is dispatched into the system 7 Stochastic Petri net model : p1 t1 p4 p7 t4 p2 p5 t2 t5 p3 p6 t3 t6 P1 has priority to the shared machine 8 Reachability graph : Markov chain : 1001001 M1 t1 0101000 M2 t2 t3 0011001 t4 M3 t6 t6 0010100 1000100 M5 t5 M6 1000011 t1 0010011 M8 M4 t1 1000100 M5 0100010 t3 p1 0100010 M7 t2 t6 0101000 M2 t5 M4 0010100 t3 p7 p2 p5 t2 t5 p3 p6 t3 t6 M8 Convention : Immediate transitions have priority over timed transitions 9 t4 M7 0010011 p4 Results for the case i = : • • Utilization ratio of the shared machine: • Production rate of P1 (frequence of t3) : • Production rate of P1 (frequence oft6) : 0101000 M2 0010100 p1 M4 t1 1000100 M5 0100010 p4 p7 t4 p2 p5 t2 t5 p3 p6 t3 t6 M7 0010011 M8 10 Remarks : - It is not obvious to build directly the Markov chain - Stochastic Petri nets offer an elegant tool for generation of correct Markov chain models of complex systems - Immediate transitions seem a good way for representation of conflicts and priorities 11 3. Petri nets with inhibitors and priority 12 Definition PN = (P, T, I, O, M0, H, ) where : • P : set of places • T : set of transitions • I : P x T IN : PRE function, i.e. arcs from places to transitions and their weights • O : P x T IN : POST function, i.e. arcs from transitions and places their weights • M0 : P IN : initial marking • H : P x T IN : generalized inhibitor arcs • : T IN : priority degrees of transitions 13 Example : t2 p3 t1 K p1 t4 p6 t6 2 p2 t3 p4 t5 p7 t7 Effect of inhibitor : Transition t5 is not firable if M(p6) ≥ 2 . Effect of priority : Transitions t1, t6 and t7 are not allowed to fire if at least one transition of higher priority is firable. 14 Firing rules: - Let : •t : set of input places of transition t t• : set of output places of t °t : set of places linked to t by inhibitor arcs R1 : A transition t is said to have concession in marking M if M(p) ≥ I(p, t), p •t and M(p) < H(p), t), p °t. Let (M) the set of transitions that have concession in M R2 : A transition tj is said firable if tj (M) and j ≥ k, tk (M) R3 : Firing a transition t leads to the following marking : M' = M + O(t) - I(t) 15 Structures of conflicts • (Without priority) : A transition tm is said in effective conflict with tl in marking M if - tm has concession in M - tl is firable - tm no longer has concession in M' such that M(tl > M'. Example : t2, t3 and M1 obtained after firing t1. t2 p3 t1 K p1 t4 p6 t6 2 p2 t3 p4 16 t5 p7 t7 • (with priority) : A transition tk is said in indirect effective conflict with tl having the same degree of priority in M if - tk is firable in M, - tl is firable in M, - firing tl leads to a sequence of higher priority transitions such that, after , no transition of priority higher than k is firable, and - tk is not firable in M' such that M(tl > M'. Example : p3 p1 t1 t3 p2 t2 p4 17 p5 Structural properies of PN If the Markov chain of a stochastic Petri net has a finite state space and is ergodic, then - it is consistent : Y 0, CY 0 - and it is conservative : X 0, X T C 0 where C = O - I. 18 4. Generalizd Stochastic Petri nets GSPN 19 Definition : A generalized stochastic Petri net is an 8-tuples: GSPN = (P, T, I, O, M0, H, , W) where • PN = (P, T, I, O, M0, H, ), the underlying Petri net, is a Petri net with inhibitors and priority composed of: - transitions of priority 0 that are timed transitions with exponentially distributed transition firing times (timed transitions) - transitions of priority n ≥ 1 that are immediate transitions (nimmediates transitions) • W : T IR+ : is a function such that - W(t) is the rate of the exponential distribution, i.e. inverse of the mean firing time, if t is timed - W(t) is a weight associated with t if t is immediate 20 Tangibles and intangibles markings - A marking M is said tangible if no immediate transition is firable - It is said intangible if at least one immediate transition is firable. 21 Dynamics of a GSPN • To each timed transition is associated a clock initiated with the corresponding exponential distribution • For a tangible marking, - the clocks of all firable transitions tick down at the same speed - the next transition to fire is that whose clock reaches zero first 22 • For an intangible marking, - we choose one firable transition ti to fire next with probability : Pt i M W t i tE M Wt where E(M) is the set of firable transitions. Remind that all transitions in E(M) are immediate transitions of the same degree. - firing ti leads to a new marking • If the new marking is till intangible, the above is repeated. Otherwise, clocks of new transitions are generated and the system evolves in the resulting new tangible marking 23 Results : • The sequence of tangible markings is a CTMC. • the average sojourn time in a tangible marking M is exponentially distributed with mean tE M W t 1 where E(M) is the set of transition firable at M, and W(t) is the parameter of the exponential distribution of t • the probability of firing a firable transition tk in a tangible marking M is: Pt k M 24 Wt k tE M Wt Generation of the isomorphic CTMC The CTMC can be derived from the reachability graph (RG) : - by establish a one-to-one correspondence betwwen the states of the CTMC and tangible markings RG CTMC M t M* 25 - by introducing an arc (or a state-transition) u for all arc t of RG connecting two tangible markings. The rate of u is W(t) RG CTMC M W(t) M t M* M* 26 - by introducing an arc v for all path t1t2…tk of RG connecting two tangible markings M and M* via intangible markings M1,M2, …, Mk-1. The rate of v is : W(t1) P(t2 / M1) .P(t3 / M2) … P(tk / Mk-1) where W t i tE M Wt Pt i M RG CTMC M t M* 27 Performance evaluation • Steady state distribution : j : probablity of being in tangible marking Mj •Firing frequency of a timed transition tk k j : t k E M j j k Mj where k(Mj) is the firing rate of tk in Mj • Average number of tokens in place p : EM(p) M j p j j • Average sojourn time of tokens in a place p (Little's law): EM(p) E dp tp• t 28 Methodology 1. Construction of the GSPN model 2. Validation of the model. For example, the verification of the consistency and conservativeness. 3. Definition of performance measures 4. Generation of the reachability graph 5. Derive the isomorphic CTMC 6. Verification of the ergodicity of the CTMC 7. Compute the steady state distribution of the CTMC 8. Computation of the performance measures Remark : Softwares are available for automatic generation and solution of CTMC (GreatSPN, …) 29 5. Applications 1. A failure-prone production line M1 B Assumption : idle machines cannot fail Parameters : i : failure rate i : repair rate pi : production rate H : buffer capacity 30 M2 GSPN : p1 p3 p2 t2 t1 t3 p9 t7 t6 t9 t10 p4 M1 B p7 p6 t4 t5 p5 H+1 p10 p8 M2 31 t8 Structural properties : • Conservative as the GSPN is covered by three p-invariants : {p1, p2, p3, p4} {p2, p3, p9, p10} {p5, p6, p7, p8} • Consistent as the GSPN is covered by three t-invariants: {t1, t2, t3, t6, t7, t8} {t4, t5} {t9, t10} 32 Performance : - Production rate (frequency of t7) : TH t 7 j p 1 j / M j (p6)0 - Average WIP : t1 WIP M j p9 j p 4 - Utilization ratios of the machines : j UM2 j / M j (p2)0 j j j / M j (p6)0 - Idle rate of the machines : IM1 j et IM2 j / M j (p3)0 j / M j (p5)0 33 p 3 t2 t4 t5 j UM1 p 2 p 5 H+ p1 1 0 t3 p9 p 6 t6 t1 0 p 7 t7 t9 p 8 t8 2. An NC machine • The operation cycle of the machine is as follows : Phase 1 : Read informations of the product to process Phase 2 : Simultaneous execution of two commands: preparation of machining tools and preparation of NC program Phase 3 : Process the product Phase 4 : Test of the quality. If the quality is insufficient, then the machine repeats phases 2 and 3 for other treatments. Otherwise, the product is unloaded. 34 • GSPN : t9 p9 r p2 p1 t1 t2 p3 t3 p4 t4 p5 p6 t7 p8 t5 p7 t6 q t8 with r + q = 1. Phase 1 : Read the product informations Phase 2 : Simultaneous execution of two commands: tool preparation and NC program loading Phase 3 : Process the product Phase 4 : Qualit test. With probability q, the quality is insufficient, then the machine repeats phases 2 and 3 for other treatments. Otherwise, the product is unloaded. 35 Structural properties : •Conservative as covered by p-invariants : {p1, p2, p3, p5, p7, p8, p9} {p1, p2, p4, p6, p7, p8, p9} • Consistent as covered by t-invariants : {t1, t2, t3, t4, t5, t6, t7, t9} {t2, t3, t4, t5, t6, t8} t9 p9 r p2 p1 t1 t2 p3 t3 p4 t4 p5 p6 p8 t5 p7 t6 q 36 t7 t8 Reachability graph : M1 100000000 t1 M2 010000000 t2 M3 001100000 t3 000110000 t4 M4 000011000 t5 M7 000000100 t6 M8 000000010 t7 M9 M1 100000000 1 M3 t4 001001000 t3 M5 M6 000000001 Markov Chain : 001100000 000110000 M4 M7 001001000 M5 000000100 t8 t9 q 6 r 6 M9 000000001 t9 p9 r p2 p1 t1 37 p3 t2 p4 t3 t4 p5 p6 t7 p8 t5 p7 t6 q t8 • The state-transition diagam is strongly connected and the CTMC is ergodic. • Steady state distribution is solution of the system: q r M1 100000000 1 M3 001100000 000110000 M4 M7 001001000 M5 000000100 q 6 r 6 M9 38 000000001 • Performance measures : - Production rate (frequency of t9) : M1 100000000 1 TH = 9 M3 - mean production cycle : 001100000 000110000 M4 T = 1/TH 001001000 M5 - mean time of phase 2 (Little's law): M7 Nb of tokens in p3 and p5 3 4 5 d2 frequency of arrivals in p3 11 7 6 q 000000100 q 6 r 6 - Utilization ratio of the machine : M9 D = 7 000000001 t9 p9 r p2 p1 39 t1 t2 p3 t3 p4 t4 p5 p6 t7 p8 t5 p7 t6 q t8 6. Extensions: 40 1. Choice of immediate transitions with random switches • Each random switch is associated with a set S of transition and it indicates, for each marking, the probability of firing a transition of thi set • Switches which are functions of markings are particularly useful • Example : if M(p2) < M(p3) , P(t1) = 1, P(t2) =0 if M(p2) > M(p3), P(t1) = 0, P(t2) =1 if M(p2) = M(p3), P(t1) = 0.5, P(t2) = 0.5 t1 p2 p1 t2 p3 41 2. Marking dependent firing times Example :t(M) =t * Min{M(p), p •t} 42 3. Approximation of general distribution • Consider a random variable D of mean D and standard deviation D. p1 D p2 • Case : D > D. The delay of the subnetwork N1 and D have the same mean and same standard deviation if : 1 2 D n D 1 D , n(n 1) 2D n 2D n 1 n n(n 1) 2 n 2 D D D 2 n 1 1 … N1 : p1 n 43 p2 • Case : D < D. The delay of the subnetwork N2 and D have the same mean and same standard deviation if : 2 2 h 2 D D D , 2 2 2 r1 2 D D D 1 - r1 N2 : p1 h r1 44 p2