The 3 rd Internatonal Conference on Mathematcs and Statstcs (ICoMS-3) Insttut Pertanan Bogor, Indonesa, 5-6 August 28 MODELING TRAFFIC LIGHTS IN INTERSECTION USING PETRI NETS 1 Deky Adzkya and 2 Subono 1 Magster student of Mathematcs Department, Insttut Teknolog Sepuluh Nopember Jl. Arf Rahman Hakm, Kampus ITS Sukollo, Surabaya 6111 Indonesa 2 Lecturer of Mathematcs Department, Insttut Teknolog Sepuluh Nopember Jl. Arf Rahman Hakm, Kampus ITS Sukollo, Surabaya 6111 Indonesa e-mal : 1 adzkyadeky@telkom.net, 2 subono23@telkom.net Abstract. Petr nets are a graphcal and mathematcal modelng tool for descrbng and studyng dscrete event system. An example of such system s traffc lghts n ntersecton. Ths paper starts wth a bref revew of some defntons and termnology used n Petr nets. It then proceeds wth modelngsngle traffc lghts. Then we contnue wth modelng traffc lghts n ntersecton. The ntersecton has two lanes and two traffc lghts. We generalze the process to desgn Petr nets for traffc lghts n ntersecton conssts of arbtrary lanes. These general Petr nets are wrtten n algorthm. Keywords: Petr net, traffc lghts, ntersecton 1. Introducton Petr net graph conssts of two types of nodes. Crcles represent places and bars represent transtons. Every arc n Petr net have weght. Traffc lghts s an example of dscrete event system because the state space s a dscrete set and the state transton mechansm s event drven. In ths paper we model traffc lghts n ntersecton usng Petr net. We buld Petr net for sngle traffc lghts frst. Then we use the result to buld Petr net for traffc lghts n ntersecton. The ntersecton dscussed here has two lanes (Hanzalek, 26). There s a traffc lght n each lane. If ntersecton has more than two lanes, the prevous Petr net cannot be used. The reason s number of places, transton and arcs n Petr net depends on number of lanes n ntersecton. Next we generalze the process to buld Petr net. The purpose s to desgn general procedure to buld Petr net for traffc lghts n ntersecton conssts of arbtrary lanes. Ths general procedure s wrtten n algorthm. The output of ths algorthm s Petr net and one of ts nput s number of lanes. 2. Bref revew of petr net In early 196s, C.A. Petr developed Petr net frst tme. Petr net s a tools to model Dscrete Event System. Petr net conssts of places, transtons and arcs. Arc connects place to transton and vce versa. Each arc n Petr net have weght. Ths weght represents number of arc connectng place and transton. If no weght s shown on an arc, we wll assume t to be 1. Arc weghts s defned as a functon from set of arcs to set of postve nteger. Defnton 1 (Cassandras, 1993). A Petr net s a four-tuple (P,T,A,w) where P represents fnte set of places, T s a fnte set of transtons, A s a set of arcs, a subset of the set P T T P and w s a weght functon, w : A 1,2,3, In Petr nets, events are related wth transtons. In order for a transton to occur, several condtons may have to be satsfed. Informaton related to these condtons s represented by tokens contaned n places. Tokens n place represented by dot or a number. Number of tokens assgned to each place n Petr net defnes a markng. A markng x of a Petr net s a functon x : P,1,2,. Thus, a markng n each place defnes a state vector that contans n nonnegatve nteger where n s number of places n Petr net.
Defnton 2 (Cassandras, 1993). A marked Petr net s a fve-tuple P, T, A, w, x where (P,T,A,w) s a Petr net and x s an ntal markng. We now come to the crucal pont of defnng how a transton (.e., an event) s enabled. A transton t T n a marked Petr net s sad to be enabled f the number of tokens n p s at least as large as the weght of the arc connectng p to t for all p I t where t I represents the set of nput places to transton t. When a transton s enabled, we say that t can fre. We now defne the state transton functon through whch frng of transtons causes a change n the markng of Petr net. Defnton 3 (Cassandras, 1993). The state transton functon, f :,1,2, n T,1,2, n, of a marked Petr net P, T, A, w, x s defned for a transton t T f and only f transton t s enabled. If f x,t s defned, then we set x' f x,t p xp wp, t wt, p 1, n,, where x ' (2.1) 3. Modelng sngle traffc lghts The Petr net for traffc lghts n ntersecton conssts of some parts where each part represent traffc lghts n a lane. These parts are smlar because number of place, transton and arc are same. The dfference between each part s n arc weght. Arc weght calculated from how long red, green and yellow lght, turned on. The man dea of ths secton s to buld Petr net for sngle traffc lghts. In ths paper, we dstngush between place and transton name by uppercase and lowercase letters. Place and transton name are wrtten n uppercase and lowercase letters respectvely. Fgure 3.1 Petr net of Smple Traffc Lghts Frst we dscuss a Petr net of smple traffc lghts. Ths Petr net has 3 places and 3 transtons as shown n Fgure 3.1. Place M, H and K each represent red, green and yellow traffc lght. We call these places as lght place. Transton mh s used to change lght that turn on from red to green. Transton mh, hk and km n Fgure 3.1 s defned as change transton for smplcty. The token s used to ndcate whch traffc lght s turn on. The nformaton about how long traffc lght n each lane turns on s not ncluded n ths Petr net. We have to modfy the Petr net n Fgure 3.1 so the prevous nformaton can be handled. Frst step s to change token means. Token not only ndcates whch lght (red, green or yellow) s turn on but also shows how long the lght turns on. Number of token at ntalzaton n place M, H and K each represent how long red, green and yellow traffc lght turns on respectvely. We need a mechansm to check whether the lght place s empty. When ths place s empty, t s tme to change lght that turns on. For traffc lght n each lane we add a place and a transton. Ths new place and transton are called buffer place and buffer transton respectvely. Lght place s empty f number of token n buffer place equal wth number of token n lght place at ntalzaton.
Fgure 3.2 Petr net of Traffc Lghts wth Watng Tmes Traffc lght conssts of red, green and yellow color. Red, green and yellow lght each turns on for 8, 6 and 4 tme steps as seen n Fgure 3.2. Three token n place BH means green traffc lght has been turned on for 3 tme steps. Three token n place H means green traffc lght wll turn on for the next 3 tme steps. At ths condton, transton hn s enabled. Frng ths transton three tmes wll transfer all token n place H to BH. There are no token n place H and K so green traffc lght has been turned off but yellow traffc lght has not been turned on. Ths condton s called dle tmes, that s a stuaton where all lghts s turn off. Fgure 3.3 Petr net of Traffc Lghts Wthout Idle Tmes We can avod dle tmes by ensure there are token at the lght place. When lght place has one token, t s tme to change lght that turn on. The processes are conssts of take all token n buffer place and one token n lght place also gve some token to other lght place. We have to decrease arc weght from buffer place to change transton by 1 and add arc from traffc lghts place to change transton wth weght 1. Idle tme occur f buffer transton fred when there s one token n traffc lghts place. In order to avod dle tme we have to make buffer transton not enabled when lght place has one token so t can not be fred. We ncrease arc weght from lght place to buffer place to 2 and add arc from buffer place to lght place wth weght 1. The result n ths secton s used to buld Petr net for traffc lghts n ntersecton. In the next secton we dscuss modelng traffc lghts n ntersecton usng Petr net. 4. Modelng traffc lghts n smple ntersecton Petr net for traffc lghts n ntersecton s more complcated than Petr net dscussed n prevous secton. Modelng traffc lghts n ntersecton usng Petr net s dvded nto 3 parts. Frst part s modelng traffc lght for each lane n ntersecton. The second part s connects place represents red lght to all transton n other lanes. Fnal part s desgn arc to change served lane. In ths secton, we dscuss modelng traffc lghts n ntersecton consst of 2 lanes usng Petr net. Green and yellow lght turn on each for 6 and 4 tme steps at all lane. Below s the model of smple ntersecton that dscussed n ths secton (Hanzalek, 26).
Fgure 4.1 Smple Intersecton Model There s a man dfference between Petr net dscussed n prevous secton and ths secton. We defne how long each lght (red, green and yellow) turn on when we buld Petr net for sngle traffc lght. In ths secton, red lght n a lane turns on as long as there s green or yellow traffc lght turn on at other lane. Ths makes red traffc lght only represented by sngle place as shown n Fgure 4.2. We call ths place as red place for smplcty. Fgure 4.2 Petr net of Traffc Lghts n Lane 1 Petr net n Fgure 4.2 represents traffc lghts wth green and yellow lght each turns on for 6 and 4 tme steps. Traffc lghts n other lane can be represented by Petr net wth same number of place, transton and arc wth Petr net n Fgure 4.2. The dfference between those Petr net s ther arc weght. Arc weght depends how long green and yellow lght turn on. Fgure 4.3 Arc Connected to Place Represents Red Traffc Lght Number of token n red place shows how long ths traffc lght turns on. When we fre transton n other lane number of token n red place should decreased by 1. In order to do that we add arc from red place to all transton n other lanes wth weght 1. In ths example, there are 4 transtons at lane 2 that s hk2, hn2, kn2 and km2. In the fnal part we have to consder arc used to change served lane. When there s one token n place represents yellow lght, frng transton km makes red traffc lght n ths lane turns on and green traffc lght n next served lane turns on. We have to add arc from transton km to red place n ths lane and place represents green traffc lght n next served lane. Arc weght s how long each lght turns on.
Fgure 4.4 Transton to Change Served Lane After the fnal part s fnshed, we can combne all the result n ths secton to draw Petr net for traffc lghts n ntersecton conssts of 2 lanes completely. Ths Petr net has 1 places and 8 transtons as shown n Fgure 4.5. Fgure 4.5 Petr net of Traffc Lghts n Intersecton Conssts of 2 lanes In the next secton we generalze the process dscussed n ths secton. The result s an algorthm to buld Petr net for ntersecton conssts of arbtrary lanes. 5. Modelng general ntersecton General ntersecton means ntersecton conssts of arbtrary lanes. The result s wrtten n algorthm because number of place and transton n Petr net depends on number of lanes n ntersecton. In ths algorthm, arc defned as 3-tuple where frst element represents source place, second element represents destnaton place and thrd element represents arc weght. We used ndex n place and transton name show ts lane. Input: th, tk N, Output: P, T, Aw, x Algorthm: P {}; T {} Aw {}; x zeros5,1 for 1 to do P P M,K,H,BK,BH; Aw Aw H,hn,2, hn,h,1, T T hn,hk,kn, km hn,bh,1, H,hk,1 Aw K,kn,2, kn,k,1, kn,bk,1, K,km,1 Aw BH,hk, th 1, hk,k, tk, BK,km, tk 1 Aw Aw end for
for 1 to do for 1 to and do Aw Aw M,hn,1, M,hk,1, M,kn,1, M,km,1 end for Aw Aw km,h 1, th 1, km,m, x 1 1 end for x 1 th 1 th tk th tk In the prevous algorthm, Petr net s dentfed by P, T, Aw, x where the defnton of P, T and x same wth Defnton 1. Notaton Aw defned as Aw A w where A and w has been defned n Defnton 1. 6. Conclusons and future work Petr net for traffc lghts n ntersecton consst of 2 lanes has 1 places and 8 transtons. Generally number of place and transton n the Petr net are 5 and 4 respectvely. Number of place s dmenson of state space. We can reduce number of place n Petr net wthout lose any nformaton. After reduced, number of place n the Petr net become 4. There are some analyss we can do to Petr net lke boundedness, conservaton and coverablty state. The analyss can not be derved from Petr net drectly but we must buld coverablty tree frst. Propertes of the Petr net are bounded, not conservatve and fnte coverable state. There are two type of Petr net, that s tmed and untmed. All Petr net dscussed n ths paper are untmed Petr net. We can buld tmed Petr net for ths or other problem. 7. References Cassandras, C.G., (1993), Dscrete Event Systems: Modellng and Performance Analyss, Aksen Assocates Incorporated Publshers, Boston. Hanzalek, Z., Kutl, M., dan Cervn, A., (26), Balancng the watng tmes n a smple traffc ntersecton model, IFAC.