Using libpepa library¶
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¶
PEPAModel object needs be provided with keyword arguments:
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.
Steady state calculation¶
pm.steady_state()
vector = pm.get_steady_state_vector()
In this case vector is a list of steady state probabilities for states [0..n].
Throughput¶
pm.steady_state()
thr = pm.get_throughput()
Here, thr
will be a list of tuples (action, throughput)
Utlisations¶
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})]
Generating dots¶
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.