Large part of pypepa is libpepa library which can be used to embed PEPA calculations in your Python project. The main entry point to libpepa is PEPAModel class.
PEPAModel object needs be provided with keyword arguments:
pypepa.PEPAModel
name
- it is an optional argument. If it is not given, it will be become the basename of thefile
, otherwise it will default tomodel
(if modelstring is given)file
- a path to a file with a PEPA model definitionmodelstring
- a string with a PEPA model defintionsolver
- eithersparse
ordirect
, default issparse
Basic usage:
from pypepa import PEPAModel
pargs = {"file": "tests/simple.pepa"}
pm = PEPAModel(**pargs)
pm.derive()
After that the PEPA model is derived. Now, in order to make some calculations you need to use corresponding methods from PEPAModel
class.
pm.steady_state()
vector = pm.get_steady_state_vector()
In this case vector is a list of steady state probabilities for states [0..n].
pm.steady_state()
thr = pm.get_throughput()
Here, thr
will be a list of tuples (action, throughput)
vector = pm.transient(0, timestop)
Vector is list of probabilities.
pm.steady_state()
usabilities = pm.get_utilisations()
Here usabilities
is a list of Counter objects, each being a dict, corresponding to a component in a model, where keys are state names and values are usabilities. Example:
[Counter({'P1': 0.5, 'P': 0.49999999999999989}), Counter({'Q': 0.66666666666666652, 'Q1': 0.33333333333333337})]
pm.generate_dots(out_dir=path)
This method will generate dots in a directory specified by path
. If this argument is not supplied, by default dots will be generated in dots
directory.
get_state_names()
Returns a list of state names used for matching state number with a correponding name. Index of the list is the number of a state.
get_rates()
Returns a dict with rate names mapped to rate values.