Presentation is loading. Please wait.

Presentation is loading. Please wait.

Kurt Jensen Lars M. Kristensen 1 Coloured Petri Nets Department of Computer Science Coloured Petri Nets Kurt Jensen & Lars Michael Kristensen (Edited by.

Similar presentations


Presentation on theme: "Kurt Jensen Lars M. Kristensen 1 Coloured Petri Nets Department of Computer Science Coloured Petri Nets Kurt Jensen & Lars Michael Kristensen (Edited by."— Presentation transcript:

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

2 Kurt Jensen Lars M. Kristensen 2 Coloured Petri Nets Department of Computer Science Coloured Petri Nets  Graphical modelling language for concurrent systems.  Combination of Petri Nets and programming language. Petri Nets: graphical notation concurrency communication synchronisation CPN ML (Standard ML): data manipulation compact modelling parameterisable models www.cs.au.dk/CPnets/cpnbook/

3 Kurt Jensen Lars M. Kristensen 3 Coloured Petri Nets Department of Computer Science CPN Tools userinterface

4 Kurt Jensen Lars M. Kristensen 4 Coloured Petri Nets Department of Computer Science Non-hierarchical Coloured Petri Nets

5 Kurt Jensen Lars M. Kristensen 5 Coloured Petri Nets Department of Computer Science Simple protocol

6 Kurt Jensen Lars M. Kristensen 6 Coloured Petri Nets Department of Computer Science Informal description SenderNetworkReceiver No loss of packets No overtaking

7 Kurt Jensen Lars M. Kristensen 7 Coloured Petri Nets Department of Computer Science Coloured Petri Net Place Transition Arc Net inscriptions Nodes

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

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

10 Kurt Jensen Lars M. Kristensen 10 Coloured Petri Nets Department of Computer Science Transitions and arcs Arc expression Name (no formal meaning) 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 *) Binding of variables: Evaluation of expressions: (n,d)  (3, " CPN " ) : NOxDATA n  3 : NO

11 Kurt Jensen Lars M. Kristensen 11 Coloured Petri Nets Department of Computer Science Enabling of transition Two variables: var n : NO; (* integers *) var d : DATA; (* strings *) Binding: 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 NO DATA ? ?

12 Kurt Jensen Lars M. Kristensen 12 Coloured Petri Nets Department of Computer Science Enabling of SendPacket One token with value 1 Binding: 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

13 Kurt Jensen Lars M. Kristensen 13 Coloured Petri Nets Department of Computer Science Binding: Enabling of SendPacket Six different tokens Binding: 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 Arc expression

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

15 Kurt Jensen Lars M. Kristensen 15 Coloured Petri Nets Department of Computer Science Occurrence of SendPacket in binding (1,"COL") Remove: (1,"COL") Add a new token: (1,"COL") Remove: 1 1 (1,"COL")

16 Kurt Jensen Lars M. Kristensen 16 Coloured Petri Nets Department of Computer Science New marking after occurrence of SendPacket in binding The first packet has been removed A copy of the first packet has been put on A No token on this place Transition is no longer enabled (thin border line)

17 Kurt Jensen Lars M. Kristensen 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 Kurt Jensen Lars M. Kristensen 18 Coloured Petri Nets Department of Computer Science New marking M 1 Transition enabled

19 Kurt Jensen Lars M. Kristensen 19 Coloured Petri Nets Department of Computer Science Binding: Binding of TransmitPacket Current marking Arc expression Binding:

20 Kurt Jensen Lars M. Kristensen 20 Coloured Petri Nets Department of Computer Science Occurrence of TransmitPacket in binding Remove: (1,"COL") (1, "COL") Add a new token: (1,"COL")

21 Kurt Jensen Lars M. Kristensen 21 Coloured Petri Nets Department of Computer Science New marking M 2 Binding: 1 1`2 XXXX 1 1`(1,"COL")

22 Kurt Jensen Lars M. Kristensen 22 Coloured Petri Nets Department of Computer Science Binding: 1 1`2 XXX New marking M 3

23 Kurt Jensen Lars M. Kristensen 23 Coloured Petri Nets Department of Computer Science Binding: 1 1`2 XXX New marking M 4

24 Kurt Jensen Lars M. Kristensen 24 Coloured Petri Nets Department of Computer Science We have successfully transmitted the first packet and the acknow- ledgement for it We are ready to start transmission of packet number two New marking M 5

25 Kurt Jensen Lars M. Kristensen 25 Coloured Petri Nets Department of Computer Science 1 (SendPacket, ) 2 (TransmitPacket, ) 3 (ReceivePacket, ) 4 (TransmitAck, ) 5 (ReceiveAck, ) TransitionBinding (, ) Binding element First five steps

26 Kurt Jensen Lars M. Kristensen 26 Coloured Petri Nets Department of Computer Science Binding: 1 1`(2,"OUR") 4 New marking M 5

27 Kurt Jensen Lars M. Kristensen 27 Coloured Petri Nets Department of Computer Science Binding: 1 1`(2,"OUR") 1 4 New marking M 6

28 Kurt Jensen Lars M. Kristensen 28 Coloured Petri Nets Department of Computer Science Binding: 1 1`(2,"OUR") 2 1 1`3 4 New marking M 7

29 Kurt Jensen Lars M. Kristensen 29 Coloured Petri Nets Department of Computer Science Binding: 2 1`(2,"OUR") 1 1`3 1 4 New marking M 8

30 Kurt Jensen Lars M. Kristensen 30 Coloured Petri Nets Department of Computer Science Binding: 2 1`(2,"OUR") 1 1`3 4 New marking M 9

31 Kurt Jensen Lars M. Kristensen 31 Coloured Petri Nets Department of Computer Science We have successfully transmitted the first two packets and the acknowledgements for them We are ready to start transmission of packet number three New marking M 10

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

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

34 Kurt Jensen Lars M. Kristensen 34 Coloured Petri Nets Department of Computer Science Two enabled transitions SP = (SendPacket, ) TP + = (TransmitPacket, ) TP – = (TransmitPacket, )  These binding elements need the same token  They are in conflict with each other

35 Kurt Jensen Lars M. Kristensen 35 Coloured Petri Nets Department of Computer Science Two enabled transitions  These bindings elements use different tokens  They are concurrently enabled and can occur concurrently SP = (SendPacket, ) TP + = (TransmitPacket, ) TP – = (TransmitPacket, )

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

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

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

39 Kurt Jensen Lars M. Kristensen 39 Coloured Petri Nets Department of Computer Science 1`"COL" Guard must evaluate to true RN 1 = (ReceiveNext, ) RN 2 = (ReceiveNext, ) false true [n=k]

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

41 Kurt Jensen Lars M. Kristensen 41 Coloured Petri Nets Department of Computer Science Questions

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

43 Kurt Jensen Lars M. Kristensen 43 Coloured Petri Nets Department of Computer Science 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 into manageable parts with well-defined interfaces.  CPN nets with modules are also called hierarchical Coloured Petri Nets.

44 Kurt Jensen Lars M. Kristensen 44 Coloured Petri Nets Department of Computer Science Why do we need modules?  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.  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.  The human modeller needs abstractions that make it possible to concentrate 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.

45 Kurt Jensen Lars M. Kristensen 45 Coloured Petri Nets Department of Computer Science Simple protocol SenderNetwork Receiver 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.

46 Kurt Jensen Lars M. Kristensen 46 Coloured Petri Nets Department of Computer Science Sender module Input port Used to import tokens from the environment Output port Used to export tokens to the environment Input/output port Used to import and export tokens Internal place Local to the module The module interacts with other modules via three port places.

47 Kurt Jensen Lars M. Kristensen 47 Coloured Petri Nets Department of Computer Science Receiver module Input port Used to import tokens from the environment Output port Used to export tokens to the environment Input/output port Used to import and export tokens Internal place Local to the module

48 Kurt Jensen Lars M. Kristensen 48 Coloured Petri Nets Department of Computer Science Network module Input port Output port Interaction with the sender Interaction with the receiver

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

50 Kurt Jensen Lars M. Kristensen 50 Coloured Petri Nets Department of Computer Science Protocol module Sender Network Receiver

51 Kurt Jensen Lars M. Kristensen 51 Coloured Petri Nets Department of Computer Science Fusion sets  Modules can exchange tokens via:  Ports.  Fusion sets.  Fusion sets allow places in different modules to be “glued” to one compound place ― across the hierarchical structure of the model.  Fusion sets are in some sense similar to global variables known from many programming languages and should therefore be used with care.

52 Kurt Jensen Lars M. Kristensen 52 Coloured Petri Nets Department of Computer Science Collecting lost packets  We collect a copy of the lost packets on place PacketsLost.  Each instance of the Transmit module collects separately.

53 Kurt Jensen Lars M. Kristensen 53 Coloured Petri Nets Department of Computer Science Collecting at a single place  All instances of the place PacketsLost are “glued together” to become a single compound place – sharing the same marking. Member of fusion set

54 Kurt Jensen Lars M. Kristensen 54 Coloured Petri Nets Department of Computer Science Marking Local Shared TransmitData TransmitAck Local

55 Kurt Jensen Lars M. Kristensen 55 Coloured Petri Nets Department of Computer Science Initialisation module  Initialisation of the CPN model is done in a specific module.  Tokens are distributed to the other modules via fusion sets. Fusion set Data to be transmitted Network properties

56 Kurt Jensen Lars M. Kristensen 56 Coloured Petri Nets Department of Computer Science Marking after initialisation Tokens to Sender module Tokens to Transmit module

57 Kurt Jensen Lars M. Kristensen 57 Coloured Petri Nets Department of Computer Science Hierarchical versus non-hierarchical nets  In theory, this implies that the hierarchy constructs of CP-nets do not add expressive power to the modelling language.  Any system that can be modelled with a hierarchical CPN model can also be modelled with a non-hierarchical CPN model.  In practice, the hierarchy constructs are very important.  They make it possible to structure large models and thereby cope with the complexity of large systems.  Hence they add modelling power.  A hierarchical CPN model can always be transformed into an equivalent non-hierarchical CPN model.

58 Kurt Jensen Lars M. Kristensen 58 Coloured Petri Nets Department of Computer Science Questions


Download ppt "Kurt Jensen Lars M. Kristensen 1 Coloured Petri Nets Department of Computer Science Coloured Petri Nets Kurt Jensen & Lars Michael Kristensen (Edited by."

Similar presentations


Ads by Google