Running PRISM /

Debugging Models With The Simulator

PRISM includes a simulator, a tool which can be used to generate sample paths (executions) through a PRISM model. From the GUI, the simulator allows you to explore a model by interactively generating such paths. This is particularly useful for debugging models during development and for running sanity checks on completed models. Paths can also be generated from the command-line.

Generating a path in the GUI

Once you have loaded a model into the PRISM GUI (note that it is not necessary to build the model), select the "Simulator" tab at the bottom of the main window. You can now start a new path by double-clicking in the bottom half of the window (or right-clicking and selecting "New path"). If there are undefined constants in the model (or in any currently loaded properties files) you will be prompted to give values for these. You can also specify the state from which you wish to generate a path. By default, this is the initial state of the model.

The main portion of the user interface (the bottom part) displays a path through the currently loaded model. Initially, this will comprise just a single state. The table above shows the list of available transitions from this state. Double-click one of these to extend the path with this transition. The process can be repeated to extend the path in an interactive fashion. Clicking on any state in the current path shows the transition which was taken at this stage. Click on the final state in the path to continue extending the path. Alternatively, clicking the "Simulate" button will select a transition randomly (according to the probabilities/rates of the available transitions). By changing the number in the box below this button, you can easily generate random paths of a given length with a single click. There are also options (in the accompanying drop-down menu) to allow generation of paths up until a particular length or, for CTMCs, in terms of the time taken.

The figure shows the simulator in action.


The PRISM GUI: exploring a model using the simulator

It is also possible to:

  • backtrack to an earlier point in a path
  • remove all of the states before some point in a path
  • restart a path from its first state
  • export a path to a text file

Notice that the table containing the path displays not just the value of each variable in each state but also the time spent in that state and any rewards accumulated there. You can configure exactly which columns appear by right-clicking on the path and selecting "Configure view". For rewards (and for CTMC models, for the time-values), you can can opt to display the reward/time for each individual state and/or the cumulative total up until each point in the path.

At the top-right of the interface, any labels contained in the currently loaded model/properties file are displayed, along with their value in the currently selected state of the path. In addition, the built-in labels "init" and "deadlock" are also included. Selecting a label from the list highlights all states in the current path which satisfy it.

The other tabs in this panel allow the value of path operators (taken from properties in the current file) to be viewed for the current path, as well as various other statistics.

Path generation from the command-line

It is also possible to generate random paths through a model using the command-line version of PRISM. This is achieved using the -simpath switch, which requires two arguments, the first describing the path to be generated and the second specifying the file to which the path should be output (as usual, specifying stdout sends output to the terminal). The following examples illustrate the various ways of generating paths in this way:

  • prism model.pm -simpath 10 path.txt (a path of 10 steps)
  • prism model.pm -simpath time=7.5 path.txt (a path of at most 7.5 time units)
  • prism model.pm -simpath deadlock path.txt (a path ending in deadlock)

Further options can also be appended to the first parameter. If you are only interested in the changes to certain variables of your model, use the vars=(...) option. For example:

prism model.sm -simpath 10 stdout
...
step a b c time
0 0 0 0 0.0
1 0 1 0 0.016569539535505946
2 0 1 1 0.04999280708731619
3 0 2 1 0.0637472535911344
4 0 2 2 0.243645533565261
5 0 2 3 0.5359625623773467
6 0 3 3 0.7862449420673264
7 1 3 3 0.8749262111456289
8 1 3 4 0.9472785807052686
9 1 3 5 1.040096742715008
10 1 3 6 1.2801655430222152
prism model.sm -simpath '10,vars=(a,b)' stdout
...
step a b time
0 0 0 0.0
1 0 1 0.20115547684708998
5 0 2 0.5822925951221433
7 1 2 0.9559600285257709
8 1 3 1.3395175958850654
10 1 4 1.869013176198441

Note the use of single quotes around the path description argument to prevent the shell from misinterpreting special characters such as "(".

You can also use the sep=... option to specify the column separator. Possible values are space (the default), tab and comma. For example:

prism model.sm -simpath '10,vars=(a,b),sep=comma' stdout
...
step,a,b,time
0,0,0,0.0
2,1,0,0.058443536856580006
3,1,1,0.09281024515535738
6,1,2,0.2556555786269585
7,1,3,0.284062896359802
8,1,4,1.1792064236954896

When generating paths to a deadlock state, additional repeat=... option is available which will construct multiple paths until a deadlock is found. For example:

prism model.sm -simpath 'deadlock,repeat=100' stdout

By default, the simulator detects deterministic loops in paths (e.g. if a path reaches a state from which there is a just a single self-loop leaving that state) and stops generating the path any further. You can disable this behaviour with the loopcheck=false option. For example:

prism dice.pm -simpath 10 stdout
...
Warning: Deterministic loop detected after 6 steps (use loopcheck=false option to extend path).
step s d state_reward transition_reward
0 0 0 0.0 1.0
1 1 0 0.0 1.0
2 3 0 0.0 1.0
3 1 0 0.0 1.0
4 4 0 0.0 1.0
5 7 3 0.0 0.0
6 7 3 0.0 0.0
prism dice.pm -simpath 10,loopcheck=false stdout
...
step s d state_reward transition_reward
0 0 0 0.0 1.0
1 2 0 0.0 1.0
2 6 0 0.0 1.0
3 7 6 0.0 0.0
4 7 6 0.0 0.0
5 7 6 0.0 0.0
6 7 6 0.0 0.0
7 7 6 0.0 0.0
8 7 6 0.0 0.0
9 7 6 0.0 0.0
10 7 6 0.0 0.0

One final note: the -simpath switch only generates paths up to the maximum path length setting of the simulator (the default is 10,000). If you want to generate longer paths, either change the default setting or override it temporarily from the command-line using the -simpathlen switch. You might also use the latter to decrease the setting, e.g. to look for a path leading to a deadlock state, but only within 100 steps:

prism model.sm -simpath deadlock stdout -simpathlen 100

PRISM Manual

Running PRISM

[ View all ]