Aside from the big new features, CPN Tools 4 also introduces a lot of useful minor features. Here is a mixed grab-bag of those. In this post, I’ll show the new model statistics, new simulation stop criteria, and the simplified state-space analysis.

## Model Statistics

It is often useful to know some statistics of a model to grasp its complexity. For this reason, model statistics are typically displayed in papers, but can also be useful for troubleshooting or just for simple interest. Previously, users had to compute this value themselves, making the statistics incomparable (for example, if a model has two fusion places in the same group, one socket place assigned to two ports, and five regular places, how is the number of places reported?

CPN Tools gives you at-your-fingertips instant statistics about your model. Just hover the mouse over the model name in the index:

Previously, you would get information about where the model file was located. You still do, but in addition, you also get information about where simulation and monitoring logs are written, and a number of model statistics.

First, we get information about the number of places, transitions, and arcs. This gives an indication of the visible complexity of a model. It counts all visible elements, but does not take reuse into account. If we have our example from before with two fusion places in the same group, one socket place assigned to two ports, and five regular places, the number of places reported would be 2 + 1 + 2 + 5 = 12.

For analysis, the number of places does not mean much, and the number of transitions do not say much about the complexity of the behavior of the model. Instead, the number of place/transition/arc instances does. This value unfolds all instances of a model, but also folds all fusion sets and port/socket assignments. The number of instances of places/arcs can be both larger and smaller than the number of places/arcs (port places and all but one fusion places do not count, and arc to/from substitution transitions do not count). In out example, two fusion places in the same group, one socket place assigned to two ports, and five regular places would yield 1 + 1 + 5 place instances (assuming all five regular places are on the top page of the model). In the previous example the number of place/arc instances was lower than the number of places/arcs; the Ring Protocol example shipping with CPN Tools reverses this:

Constraint and constraint instances give the same numbers for Declare constraints in the model. Pages and page instances count the number of different pages and the number of instances of pages respectively. Monitors counts the number of monitors in the system. Finally we get information about how many declarations the model has, how many of those are type declarations, and how many variables the model declares.

## Simulation Stop Criteria

CPN Tools 4 adds 3 new simulation stop criteria:

The number of steps is the old step counter. Total steps makes simulation stop after a maximum number of steps. For example, if you want to execute at most 1,000,000 steps, but do so in increments of 100,000, you can set number of steps to 100,000 and total steps to 1,000,000. Probably more useful is the ability to instead limit execution to the amount of time progressed. Like for steps, you can set the amount of time the simulation may progress for each application of the tool as well as the total maximum time of the simulation. You can use zero, one, or more of these criteria. Setting any criteria to 0 ignores it, and the simulation stops after the first stop criteria is reached. Here, we run a simulation with all criteria set and get information about which one is triggered. We also (new in CPN Tools 4) get information about how much time was spent:

## Simplified State-space Analysis

CPN Tools 4 simplifies state-space analysis. Prior to version 4, the state-space analysis palette looked like this:

At the top, we have enter state-space, calculate state-space, calculate SCC, and export report. A very large part of analysis consisted of executing these four from left to right. A minor part of analysis consisted of executing enter, calculate, and then using one of the tools below. A very minuscule part of analysis consisted of executing the first two or three in the first row and then some custom queries.

If the state-space was calculated without first entering the state-space tool, or a report was saved without computing the SCCs (if necessary), you got an obscure error that didn’t really explain how to solve the problem.

CPN Tools completely removed the enter state-space step, and automatically executes necessary steps. This means if you want to export a state-space report, it automatically does all steps before that. CPN Tools now also gives information about how much time was spent (without having to look in the report). Here’s an example obtained by just clicking save report on a freshly loaded model:

We see that CPN Tools has automatically entered the state-space tool, computed the state-space and SCC graph, and exported the report. Now, if I decide to recalculate the state-space, CPN Tools will do that:

CPN Tools knows, we have already entered the state-space tool, so we do not need to do that. Saving report again, yields:

The tool knows, we have computed the state-space, and only performs the two neccesary steps to save the report. If I decide to alter my model, e.g., changing the name of a transition or adding or removing structure, applying save report again, will cause the tool to automatically enter the state-space tool and do the necessary computations:

To see a live demonstration of the simplified state-space tool, check out this video: