1 / 58

Coloured Petri Nets

Concurrent system. Model. Coloured Petri Nets. Kurt Jensen & Lars Michael Kristensen (Edited by José Luís Silva, DI/CCTC, Universidade do Minho). Coloured Petri Nets. Petri Nets: graphical notation concurrency communication synchronisation CPN ML (Standard ML):

anila
Download Presentation

Coloured Petri Nets

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Concurrent system Model Coloured Petri Nets Kurt Jensen & Lars Michael Kristensen (Edited by José Luís Silva, DI/CCTC, Universidade do Minho) Coloured Petri Nets Department of Computer Science

  2. Coloured Petri Nets • Petri Nets: • graphical notation • concurrency • communication • synchronisation • CPN ML (Standard ML): • data manipulation • compact modelling • parameterisable models • Graphical modelling languagefor concurrent systems. • Combination of PetriNets and programminglanguage. www.cs.au.dk/CPnets/cpnbook/ Coloured Petri Nets Department of Computer Science

  3. CPN Tools userinterface Coloured Petri Nets Department of Computer Science

  4. Non-hierarchical Coloured Petri Nets Coloured Petri Nets Department of Computer Science

  5. Simple protocol Coloured Petri Nets Department of Computer Science

  6. Informal description No loss of packets No overtaking Sender Network Receiver Coloured Petri Nets Department of Computer Science

  7. Coloured Petri Net Place Arc Nodes Transition Net inscriptions Coloured Petri Nets Department of Computer Science

  8. Places represent the state of the system Initial marking (multiset of tokens) • Each place contains a number of tokens. • Each token carries a colour (data value). • The colour set specifies the set of allowed token colours. Each token in the initial marking must have a colour that belongs to the colour set Name(no formal meaning;large impact on readability) Definition of colour sets: colset NO = int; (* integers *) colset DATA = string; (* text strings *) colset NOxDATA = product NO * DATA; Colour set (type) Coloured Petri Nets Department of Computer Science

  9. Current marking during simulation Values: Token colours (multiset of actual token colours) Circle: 6 tokens Type: Colour set (set of allowed token colours) Square: Detailed token values The thick border line indicates that the transition is enabled (ready to occur) Information about current marking (changes during simulation) One token with value 1 Coloured Petri Nets Department of Computer Science

  10. Transitions and arcs Arc expression The arc expression must evaluate to a colour in the colour set of the attached place(or a multiset of such colours) Declaration of variables: var n : NO; (* integers *) var d : DATA; (* strings *) Name(no formal meaning) Binding of variables: <n=3,d="CPN"> Evaluation of expressions: (n,d)  (3,"CPN") : NOxDATA n  3 : NO Coloured Petri Nets Department of Computer Science

  11. Enabling of transition Two variables: var n : NO; (* integers *) var d : DATA; (* strings *) ? Binding: < n=? , d=? > NO DATA ? Transition is enabled if we can find a binding so that each input arc expression evaluates to one or more colours that are present on the corresponding input place Coloured Petri Nets Department of Computer Science

  12. Enabling of SendPacket Binding: < n=1, d=? > We want to find a binding for the variable n such that the arc expression n evaluates to a colour which is present on the place NextSend Arc expression One token with value 1 Coloured Petri Nets Department of Computer Science

  13. Enabling of SendPacket Six different tokens Arc expression Binding: < n=1, d=? > Binding: < n=1, d="COL"> We want to find a binding for the variable d such that the arc expression (n,d) evaluates to a colour which is present on the place PacketsToSend Coloured Petri Nets Department of Computer Science

  14. (1,"COL") 1 Enabling of SendPacket We have found a binding so that each input arc expression evaluates to a colour that is present on the corresponding input place Binding: < n=1, d="COL"> Transition is enabled (ready to occur) Coloured Petri Nets Department of Computer Science

  15. Remove: (1,"COL") (1,"COL") (1,"COL") Add a new token: (1,"COL") 1 Remove: 1 Occurrence of SendPacketin binding <n=1,d=“COL”> Coloured Petri Nets Department of Computer Science

  16. New marking after occurrence of SendPacket in binding <n=1,d=“COL”> The first packet has been removed Transition is no longer enabled (thin border line) A copy of the first packet has been put on A No token on this place Coloured Petri Nets Department of Computer Science

  17. Exercise • Simulate the previous example in the CPN Tools: • Press Right button -> New Net • Press Right button on Standard declarations -> New Decl • colset NO = int; • colset Data = string; • colset NOxData = product NO * Data; • var n:NO; var d:Data; • ToolBox -> drag drop • Create -> select and apply • Place -> press “tab” button to access PLACE TYPE and INIT MARK • Transitions • Arcs (select origin and then target) • Simulation -> select and apply • Execute a transition with a chosen binding Coloured Petri Nets Department of Computer Science

  18. New marking M1 Transition enabled Coloured Petri Nets Department of Computer Science

  19. Current marking Binding of TransmitPacket Arc expression Binding: < n=? , d=? > Binding: < n=1, d="COL"> Coloured Petri Nets Department of Computer Science

  20. Remove: (1,"COL") Add a new token: (1,"COL") (1, "COL") (1, "COL") Occurrence of TransmitPacket in binding <n=1,d=“COL”> Coloured Petri Nets Department of Computer Science

  21. 1`(1,"COL") 1 1`2 1 New marking M2 XXXX Binding: <n=1,d="COL"> Coloured Petri Nets Department of Computer Science

  22. 1`2 1 New marking M3 Binding: <n=2> XXX Coloured Petri Nets Department of Computer Science

  23. 1 1`2 New marking M4 XXX Binding: <n=2> Coloured Petri Nets Department of Computer Science

  24. New marking M5 We have successfully transmittedthe first packet and the acknow-ledgement for it We are ready to start transmission of packet number two Coloured Petri Nets Department of Computer Science

  25. Bindingelement First five steps 1 (SendPacket ,<n=1, d="COL">) 2 (TransmitPacket , <n=1, d="COL">) 3 (ReceivePacket , <n=1, d="COL">) 4 (TransmitAck , <n=2>) 5 (ReceiveAck , <n=2>) Transition Binding ( , ) Coloured Petri Nets Department of Computer Science

  26. 1`(2,"OUR") 1 New marking M5 4 Binding: <n=2,d="OUR"> Coloured Petri Nets Department of Computer Science

  27. 1`(2,"OUR") 1`(2,"OUR") 1 1 New marking M6 4 Binding: <n=2,d="OUR"> Coloured Petri Nets Department of Computer Science

  28. 1`(2,"OUR") 1 1`3 1 New marking M7 4 2 1`(2,"OUR") Binding: <n=2,d="OUR"> Coloured Petri Nets Department of Computer Science

  29. 1`3 1`3 1 1 New marking M8 4 2 1`(2,"OUR") Binding: <n=3> Coloured Petri Nets Department of Computer Science

  30. 1`3 1 New marking M9 4 2 1`(2,"OUR") 1`3 Binding: <n=3> Coloured Petri Nets Department of Computer Science

  31. New marking M10 We have successfully transmittedthe first twopackets and the acknowledgements for them We are ready to start transmission of packet number three Coloured Petri Nets Department of Computer Science

  32. Marking after 30 steps We have successfully transmitted all six packets and the acknowledgements for them There are no more packets to transmit Dead marking (no transitions are enabled) Coloured Petri Nets Department of Computer Science

  33. Double-headed arcs A double arc is a shorthand for two oppositely directed arcs with the same arc expression Constant Double-headed arc We no longer remove the tokens from the input places Double-headed arc Retransmission becomes possible Coloured Petri Nets Department of Computer Science

  34. Two enabled transitions • These binding elements need the same token • They are in conflictwith each other SP = (SendPacket, <n=1, d="COL">) TP+ = (TransmitPacket, <n=1, d="COL", success=true>) TP– = (TransmitPacket, <n=1, d="COL", success=false>) Coloured Petri Nets Department of Computer Science

  35. Two enabled transitions • These bindings elements use different tokens • They are concurrently enabledand can occur concurrently SP = (SendPacket, <n=1, d="COL">) TP+ = (TransmitPacket, <n=1, d="COL", success=true>) TP– = (TransmitPacket, <n=1, d="COL", success=false>) Coloured Petri Nets Department of Computer Science

  36. Possible marking after 50 steps This packetwill be discarded Sender is still sending packet no. 4 Receiver is waiting for packet no. 5 An acknowledgement requesting packet no. 5 is arriving When it is received, the sender will start sending packet no. 5 Coloured Petri Nets Department of Computer Science

  37. Dead marking at the end of simulation There is no packet no. 7 All packets have been received in the correct order Receiver is waiting for packet no. 7 Sender is ready to send packet no. 7 All buffer places are empty Coloured Petri Nets Department of Computer Science

  38. Transitions can have a guard • Boolean expression which must evaluate to true for the binding element to be enabled. • Additional enabling condition. Correct packets Wrong packets Guard (<> is the Inequality operator) Guard (tests whether n and kare equal) andalso and orelse represent respectively the logical conjunction and disjunction operators Coloured Petri Nets Department of Computer Science

  39. 1`"COL" Guard must evaluate to true [n=k] RN1 = (ReceiveNext, <n=1, k=2, d="COL", data="COL">) RN2 = (ReceiveNext, <n=2, k=2, d="OUR", data="COL">) false true Coloured Petri Nets Department of Computer Science

  40. 1`"COL" Guard must evaluate to true [n<>k] DP1 = (DiscardPacket, <n=1, k=2, d="COL") DP2 = (DiscardPacket, <n=2, k=2, d="OUR") true false Coloured Petri Nets Department of Computer Science

  41. Questions Coloured Petri Nets Department of Computer Science

  42. Hierarchical Coloured Petri Nets Coloured Petri NetsModelling and Validation of Concurrent Systems Kurt Jensen &Lars Michael Kristensen {kjensen,lmkristensen}@cs.au.dk Coloured Petri Nets Department of Computer Science

  43. CPN models can be divided into modules • CPN modules play a similar role as modules in ordinary programming languages. • They allow the model to be split intomanageable parts with well-defined interfaces. • CPN nets with modules are also calledhierarchical Coloured Petri Nets. Coloured Petri Nets Department of Computer Science

  44. Why do we need modules? • Impractical to draw a CPN model of a large system as a single net. • Would become very large and unhandy. • Could be printed on separate sheets and glued together,but it would be difficult to get an overview and make a nice layout. • There are often system components that are used repeatedly. • Inefficient to model these components several times. • Instead we define a module, and use the module repeatedly. • In this way there is only one description to read, and one description to modify when changes are necessary. • The human modeller needs abstractions that make it possible toconcentrate on only a few details at a time. • CPN modules can be seen as black-boxes, where the modeller(when desired) can forget about the details within the modules. • This makes it possible to work at different abstraction levels. Coloured Petri Nets Department of Computer Science

  45. Simple protocol The protocol model can be divided into three modules: • Sender. • Network. • Receiver. We “cut” the model into three parts: • Using the buffer places as interfaces between the modules. Receiver Sender Network Coloured Petri Nets Department of Computer Science

  46. Sender module Input/output portUsed to import and export tokens The module interacts with other modulesvia three port places. Output portUsed to export tokens to the environment Internal placeLocal to themodule Input portUsed to import tokens from the environment Coloured Petri Nets Department of Computer Science

  47. Receiver module Input/output portUsed to import andexport tokens Input portUsed to import tokens from the environment Internal placeLocal to the module Output portUsed to export tokens to the environment Coloured Petri Nets Department of Computer Science

  48. Network module Output port Input port Interaction with the sender Interaction with the receiver Output port Input port Coloured Petri Nets Department of Computer Science

  49. Protocol module • Provides a more abstract view of the protocol system. • “Glues” the three other modules together. Name of substitution transition Name of submodule • Three substitution transitions referring to three different modules. Coloured Petri Nets Department of Computer Science

  50. Network Receiver Sender Protocol module Coloured Petri Nets Department of Computer Science

More Related