CPNs: Colored Petri Nets

As an extension of the P/T-Net, tokens are differentiated with respect to their type. Different types of tokens are represented by different colors. According to that the resulting Petri nets are called colored Petri nets (CPN). CPNs define a default token color which is used for creating default constraints on flow relations. Figure 3 shows an example CPN,

fig3

Figure 3: Visualization of the CPN used in the example.

where a blue token is generated by the first transition and consumed by the second. The default token color in the example is black.

This CPN can be created using the CPN class from the SEPIA framework. Note that a marking no longer contains an integer value per place, but a multiset in order to distinguish the number of tokens per token type.

Additional to the sensible structure, CPNs require flow relation effectiveness for validity. This means, that each relation must move at least one token from a place to a transition or vice versa. For the soundness property no more conditions must be met, s.th. a valid CPN is also sound.

In the same way constraints on flow relations contain a multiset of token colors which define the token colors that must flow. Firing rules make the creation of constraints more convenient. They are created per transition and contain multisets of tokens for the requirements and productions of a transition. Internally firing rules are translated into constraints. The following example creates a CPN and adds a constraint to one flow relation and uses a firing rule to set constraints to flow relations concerning a single transition.

CPN cpn = new CPN();
cpn.addPlace("p1");
cpn.addPlace("p2");
cpn.addTransition("t1");
cpn.addTransition("t2");
cpn.addFlowRelationPT("p1", "t1");
cpn.addFlowRelationTP("t1", "p2");
Multiset<String> c1 = new Multiset<String>();
c1.add("blue");

cpn.addFlowRelationPT("p2", "t2", c1);

FiringRule frT1 = new FiringRule();
frT1.addRequirement("p1", "black", 2);
frT1.addProduction("p2", "blue", 1);
cpn.addFiringRule("t1", frT1);

CPNMarking cpnmarking = new CPNMarking();
cpnmarking.set("p1", new Multiset<String>("black", "black"));
cpn.setInitialMarking(cpnmarking);

By default, all transitions consume and produce one token of the default token color, so this constraint can be omitted. Constraints with default token colors only need to be declared if more than one token should be consumed or produced.

Since p1 initially contains two black tokens and t2 requires two black tokens at its incoming places to be enabled, it can be fired.