This appendix details the (plain text) file formats used by PRISM for exporting and importing models that have already been constructed, i.e., they comprise an explicit list of states, transitions, etc. making up the model, rather than a high-level model description in the PRISM modelling language. Below, we describe:
These contain an explicit list of the reachable states of a model. The first line is of the form
(v1,...,vn), listing the names of all the variables in the model in the order that they appear in the PRISM model. Subsequent lines list the values of the
n variables in each state of the model. Each line is of the form
i is the index of the state (starting from 0) and
x1,...,xn are the values of each variable in the state. States are ordered by their index, or, equivalently, lexicographically according to the tuple of variable values.
For the example PRISM model poll2.sm, the states file looks like:
These contain an explicit list of the transitions making up a probabilistic model, i.e. they are essentially a sparse matrix representation of the transition probability/rate matrix. The first line of the file contains information about the size of the model, the remaining lines contain information about transitions, one per line.
DTMCs and CTMCs
For Markov chains the first line take the form "
n m", giving the number of states (
n) and the number of transitions (
m). The remaining lines are of the form "
i j x", where
j are the row (source) and column (destination) indices of the transition, and
x is the probability (for a DTMC) or rate (for a CTMC) of the transition. Row/column state indices are zero-indexed (i.e. between
n-1). Probability/rate values are written as (positive) floating point numbers (examples:
Often, the transition lines in the file are ordered by row index and then column index, but this is optional. For a DTMC, the probabilities for the outgoing transitions of each state should sum to 1.
MDPs (or PAs)
For MDPs, the format is an extension of the above To clarify terminology: each state of the MDP contains (nondeterministic) choices, each of which is essentially a probability distribution over successor states that we can view as a set of transitions. Optionally, each choice can be labelled with an action.
The first line of the file take the form "
n c m", giving the number of states (
n), the total number of choices (
c) and the total number of transitions (
m). The remaining lines are of the form "
i k j x" or "
i k j x a", where
j are the row (source) and column (destination) indices of the transition,
k is the index of the choice that it belongs to, and
x is the probability of the transition.
a is optional and gives the action label for the choice of the transition. Action labels can be present for some, all or no states but, in slightly redundant fashion, the action labels, if present, must be the same for all transitions belonging to the same choice.
Row/column state indices and choice indices are all zero-indexed. Probability values (as above) are written as (positive) floating point numbers and should sum to 1 for each choice. Often, the transition lines in the file are ordered by row index, then choice index and then column index, but this is optional.
There is alternative format for transition matrices (see the -exportrows switch) where transitions for each state/choice are collated on a single line.
Here is the result for the lec3.pm example from above (a DTMC):
for the lec12mdp.nm example (an MDP):
and for the lec12mdpa.nm example (an MDP with actions):
These contain an explicit list of the (non-zero) state rewards for a particular reward structure of a model. The first line of the file is of the form
n m where
n is the number of states in the model and
m is the number of non-zero state rewards. The following
m lines are of the form
i r, denoting that the state reward for state
For the lec3.pm (6-state) DTMC example from above, we get rewards in 3 states (0, 4 and 5):
Files containing transition rewards are formatted identically to transitions files (see above), except that probabilities/rates are replaced with reward values, and the number of transitions (the last number on the first line) is replaced with the number of non-zero transition rewards.
For the lec3.pm (6-state) DTMC example from above, we get non-zero transition rewards on 4 transitions:
And or the lec12mdpa.nm (4-state) MDP example, we get non-zero transition rewards on 4 transitions: