Petri Net Traversal

Enabled transitions should not always be fired manually. For this the SEPIA framework supports automated traversal of Petri net activities. Different from the traversal interface in the JAGAL framework, which is also implemented by all Petri nets, traversal of Petri net activities works by choosing an arbitrary enabled transition to fire. A transition to fire gets selecting randomly (RandomPNTraverser) or stochastically (StochasticPNTraverser). The random traverser fires an enabled transition randomly, where the stochastic traverser considers manually specified probabilities for the choice of enabled transitions to fire.

The following code randomly fires an enabled transition until no more transitions are available:

RandomPTTraverser t = new RandomPTTraverser(ptnet);
for (int i = 1; ptnet.hasEnabledTransitions(); i++) {
    System.out.println(i + ": " + ptnet.getEnabledTransitions().size());
    t.chooseNextTransition(ptnet.getEnabledTransitions()).fire();
}
System.out.println("no more enabled transitions");

An example for the usage of Petri net traversal can be found in the PNTraversalUtils class. It contains a method testTraces(), which simulates a given Petri net a given number of times and returns the observed sequences of activities (traces). The following method call simulates the Petri net ptnet 10 times and prints out all distinct traces. Thereby it limits the number of activities per sequence to 100.

PNTraversalUtils.testTraces(ptnet, 10, 100, true, false, false);

The output for ten simulations on the P/T-Net shown in figure 5 contains the following distinct traces:

fig5

Figure 5: P/T-Net example for the Petri net traversal.

[t1, t3]
[t2, t2, t3, t3]
[t2, t3, t2, t3]