CPN Tools 4: Place-Transition Petri Nets

CPN Tools is usually known for modeling with colored Petri nets.  Colored Petri nets augment standard place-transition Petri nets (PT-nets) with data types, and as such are a real extension that can easily embed PT-nets.  PT-nets come with a couple extensions that are crucial for this lower-level formalism, but which can be emulated in colored nets without extensions.  Often, it is easier to use the lower-level formalism, however, so CPN Tools 4 adds support for much simpler use of PT-nets.  Everything shown here works with CPN Tools 3.9.3 and never – get your copy here.

PT-nets Then and Now

In previous versions of CPN Tools, users had to do a lot of book-keeping to work with PT-nets.  They basically had to assign the type UNIT to all places and add an inscription () to all arcs.  A simple PT-net model could look like this:

Screen Shot 2013-08-15 at 15.29.10

The model has a lot of visual crud, and even worse, adding all those inscriptions takes a lot of time for just constructing a simple model illustrating some simple idea.

CPN Tools 4 assumes that any place with no explicit type has type UNIT and any arc without an inscription has the inscription (). Furthermore, it allows us to just write, say, 2 for 2`() on all arcs connecting to UNIT places and all initial markings of UNIT places. This means, the same model in CPN Tools 4 looks like this:

Screen Shot 2013-08-15 at 15.34.44

This is no doubt much cleaner and easier to look at. Most arc inscriptions are gone as are all place types.

Backwards and Forwards Compatiblity

We notice that the model in CPN Tools 4 above is not neatly aligned to the grid, which is strange for a CPN Tools 4 model. This is because the model is actually imported directly from CPN Tools 3.4. CPN Tools 4 reads any CPN Tools 3.4 model and automatically simplifies it if possible.

CPN Tools 4 allows us to change the model without adding any annotations to arcs, except to indicate if more than one token should be consumed. Relayouting and making small visual and semantical changes, we obtain:

Screen Shot 2013-08-15 at 15.41.32

Now, the big advantage is that CPN Tools 4 saves the files so that CPN Tools 3.4 can import them; doing so leads to this:

Screen Shot 2013-08-15 at 15.44.29

We see that both semantical and syntactical changes have been carried over. CPN Tools 4 can exchange models with previous versions as long as only features available in earlier versions are used.

Reset and Inhibitor Arcs

Screen Shot 2013-08-15 at 15.48.42It has been possible to use design patterns to emulate the behavior of reset and inhibitor arcs (e.g., here). This is a bit cumbersome, but perfectly fine for colored nets. It is not possible to use these constructs for pure PT-nets, however.

For convenience and to allow modeling using patterns well-known to modelers familiar with PT-nets, CPN Tools 4 adds support for reset and inhibitor arcs. These are used exactly like regular arcs:

Screen Shot 2013-08-15 at 15.51.01

Now, due to the inhibitor arc, the model is forced to take the upper path first. As soon as the lower path is chosen, all tokens from the initial place are removed (if there are any).

PNML Export

While CPN Tools is arguably the only tool supporting the particular kind of colored nets used in the tool, there are many tools supporting PT-nets. To communicate with those, CPN Tools now supports exporting PT-net models to PNML. Simply change the file type to PNML in the save dialog:

Screen Shot 2013-08-15 at 15.54.41

This results in a PNML file, which can be imported into any PNML compliant tool, here ProM:

Screen Shot 2013-08-15 at 15.57.53

We see that style and semantics have been carried over (ProM shows the initial marking in very small letters and arc weights not at all).

Mix and Match

As PT-net support is purely syntactical, we can easily mix and match between PT-nets and CP-nets in the same model. For example, we could make a PT-net control flow model manipulating data as here:

Screen Shot 2013-08-15 at 16.08.04

Video Demonstration

For a quick video introduction to PT-nets in CPN Tools 4, you can watch this video (it’s using an older pre-release of CPN Tools, but otherwise everything is the same):

Inhibitor and reset arcs are demonstrated here:

PNML export can be seen here (1:30 after the start of the video):

14 thoughts on “CPN Tools 4: Place-Transition Petri Nets

  1. hi,michael.The new version is great.I am looking forward to getting it.And welcome to Beijing this month.

  2. Hi,Micheal. I’m wondering if the CPN Tools 3.9.0 is able to calculate a state space with more than 10 million nordes cause I alaways get partial state space reports.

    1. Dear Carina,

      The state-space tool has in inherent limits, but cannot in practise handle more than a couple hundred thusand states. To get around that, alter your model to have a smaller state space.

  3. Hi Micheal,
    When I’m using export to pnml file, the export goes successfully but the exported file is empty!!
    also importing pnml file made by other tools loads nothing!!
    is there anything missed?
    Thank you

    1. Hi Malek,

      CPN Tools only exports nets with a PT-net structure. No hierarchical models or colored models.

      CPN Tools also does not import PNML. This was primarily due to time constraints during the release but also based on the assumption that CPN Tools is good as making and simulating models, but not so good at analysis. Therefore it makes more sense to make the model in CPN Tools and export it elsewhere rather than the other way around.

      1. Hi Michael,

        Actually, what I’m trying to do is a mapping between BPMN model and colored Petri net! I did it and generated the pnml file but can’t import it in CPNTools to have the result simulated!!

        I got your point, but my question now is: Is there any API or libraries in CPNTools I can use to generate my model manually??

        Thank you

        1. Hi Malek,

          The easiest is to just create .cpn files directly. The CPN format is an XML format which served as inspiration for PNML, so they are very similar. You can see a bit more about the format at http://cpntools.org/documentation/old/dtd_for_net_files but the main source is just looking at the input files.

          An alternative is to use Access/CPN to generate the files. This is not really much easier than generating them directly. An important point of Access/CPN is to remember to add arcs to the page as well as to a place and a transition, or the export will not work.

          1. Thank you Michael for you reply,

            I think the best solution for me is to create .cpn file directly, which I already thought about it but was wondering if there is any library that could be used to build objects in java (e.g. color obj) then get them rendered to xml(.cpn format) directly using this library.

  4. Hi Michael

    I think there are some limitation of size when exporting the pnml file. I made PT-net at cpn-tools(size:525KB) and export to pnml file. But, the export goes successfully but the exported file is empty. I think it is related to size of PT-net. This is because when I removed the many part of PT-net, the exported file(size: 39KB) is not empty.
    I want to solve this problem, so if you have any idea of this problem,it will be very grateful for me.

    I’m sorry to bother you…

    1. Hi Minkyu,

      There should not be any issue with size, however the PNML export is rather limited, and won’t deal correctly with, e.g., hierarchical models.

      Can you reproduce the same issue with a different (large) model with just one page and “simple” places/transitions? Simple meaning they have no annotations.

      Alternatively, try saving the new, closing and re-opening CPN Tools and the model and try the export again.

  5. Hi Michael,

    I’m Stefano and I’m using CPN tools for my thesis work. I would like to ask you a couple of questions:
    1) Is it possible to read from input file which sequence transition to enable?
    2) Is there a function that returns the number of tokens in one place?
    3) I have problems when I export to pnml file. The export goes successfully but the exported file is empty.

    Best regards.

    1. Hi Stefano,

      1) there’s not really a simple way to do that. One way would be to load a script indicating the transitions to execute and load that onto a central place. Then enable transitions according to that recipe.
      2) there’s not, at least not during simulation (doing that would break the monotonicity of nets). If you need this functionality, you can simulate it using one of the inhibitor arc simulations on the CPN Tools web-site; they essentially keep track of the number of tokens
      3) the PNML export is not complete; it only allows exporting a very limited set of nets (basically, uncolored nets). It also depends on the simulator extensions being installed and working correctly.

      Hope this helps,

  6. I’m using PROM6 and CPN tools to do the simulation
    I have several question , that I hope to get answered.
    1) I have a log file and I’m forming a petri net from this file using PROM6.
    2) Prom6 allows only its export as a PNML file, how do I do to read that file in CPN tools if that is possible ?

    Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.