pm4py.objects.stochastic_petri package¶
Submodules¶
pm4py.objects.stochastic_petri.ctmc module¶

pm4py.objects.stochastic_petri.ctmc.
get_color_from_probabilities
(prob_dictionary)[source]¶ Returns colors from a dictionary of probabilities
 Parameters
prob_dictionary – Dictionary of probabilities
 Returns
Dictionary of colors
 Return type
color_dictionary

pm4py.objects.stochastic_petri.ctmc.
get_corr_hex
(num)[source]¶ Gets correspondence between a number and an hexadecimal string
 Parameters
num – Number
 Returns
Hexadecimal string
 Return type
hex_string

pm4py.objects.stochastic_petri.ctmc.
get_q_matrix_from_tangible_exponential
(tangible_reach_graph, stochastic_info)[source]¶ Gets Q matrix from tangible reachability graph and stochastic map where the distribution type has been forced to be exponential
 Parameters
tangible_reach_graph – Tangible reachability graph
stochastic_info – Stochastic map for each transition
 Returns
Qmatrix from the tangible reachability graph
 Return type
q_matrix

pm4py.objects.stochastic_petri.ctmc.
get_tangible_reachability_and_q_matrix_from_dfg_performance
(dfg_performance, invisible_firing_rate=1000.0, parameters=None)[source]¶ Get the tangible reachability graph and the Q matrix from the performance DFG
 Parameters
dfg_performance – Performance DFG
invisible_firing_rate – Firing rate for invisible transitions
parameters – Parameters
 Returns
reachab_graph – Reachability graph
tangible_reach_graph – Tangible reachability graph
stochastic_info – Stochastic information
q_matrix – Qmatrix from the tangible reachability graph

pm4py.objects.stochastic_petri.ctmc.
get_tangible_reachability_and_q_matrix_from_log_net
(log, net, im, fm, parameters=None)[source]¶ Gets the tangible reachability graph from a log and an accepting Petri net
 Parameters
log – Event log
net – Petri net
im – Initial marking
fm – Final marking
 Returns
reachab_graph – Reachability graph
tangible_reach_graph – Tangible reachability graph
stochastic_info – Stochastic information
q_matrix – Qmatrix from the tangible reachability graph

pm4py.objects.stochastic_petri.ctmc.
nullspace
(a_matrix, atol=1e13, rtol=0)[source]¶ Compute an approximate basis for the nullspace of A.
The algorithm used by this function is based on the singular value decomposition of A.
 Parameters
a_matrix (ndarray) – A should be at most 2D. A 1D array with length k will be treated as a 2D with shape (1, k)
atol (float) – The absolute tolerance for a zero singular value. Singular values smaller than atol are considered to be zero.
rtol (float) – The relative tolerance. Singular values less than rtol*smax are considered to be zero, where smax is the largest singular value.
If both `atol` and `rtol` are positive, the combined tolerance is the
maximum of the two; that is:: – tol = max(atol, rtol * smax)
Singular values smaller than `tol` are considered to be zero.
 Returns
ns – If A is an array with shape (m, k), then ns will be an array with shape (k, n), where n is the estimated dimension of the nullspace of A. The columns of ns are a basis for the nullspace; each element in numpy.dot(A, ns) will be approximately zero.
 Return type
ndarray

pm4py.objects.stochastic_petri.ctmc.
perform_steadystate
(q_matrix, tangible_reach_graph)[source]¶ Performs steady state analysis given the :param q_matrix: :return:

pm4py.objects.stochastic_petri.ctmc.
transient_analysis_from_petri_net_and_smap
(net, im, s_map, delay, parameters=None)[source]¶ Gets the transient analysis from a Petri net, a stochastic map and a delay
 Parameters
log – Event log
delay – Time delay
parameters – Parameters of the algorithm
 Returns
Transient analysis result
 Return type
transient_result

pm4py.objects.stochastic_petri.ctmc.
transient_analysis_from_tangible_q_matrix_and_single_state
(tangible_reach_graph, q_matrix, source_state, time_diff)[source]¶ Do transient analysis from tangible reachability graph, Q matrix and a single state to start from
 Parameters
tangible_reach_graph – Tangible reachability graph
q_matrix – Q matrix
source_state – Source state to consider
time_diff – Time interval we want to investigate
 Returns
Transient analysis result
 Return type
transient_result

pm4py.objects.stochastic_petri.ctmc.
transient_analysis_from_tangible_q_matrix_and_states_vector
(tangible_reach_graph, q_matrix, states_vector, time_diff)[source]¶ Do transient analysis from tangible reachability graph, Q matrix and a vector of probability of states
 Parameters
tangible_reach_graph – Tangible reachability graph
q_matrix – Q matrix
states_vector – Vector of states probabilities to start from
time_diff – Time interval we want to investigate
 Returns
Transient analysis result
 Return type
transient_result
pm4py.objects.stochastic_petri.lp_perf_bounds module¶

class
pm4py.objects.stochastic_petri.lp_perf_bounds.
LpPerfBounds
(**kwargs)[source]¶ Bases:
object

build_preset_postset
()[source]¶ Memorize the preset and the postset of the places/transitions of the Petri net

build_var_corr
()[source]¶ Build the correspondence between the variables of the model and the columns

get_net
()[source]¶ Get the transformed Petri net used by the simulation
 Returns
net – Petri net
initial_marking – Initial marking
final_marking – Final marking

transform_net
(net0, initial_marking0, final_marking0, s_map, avg_time_starts)[source]¶ Transform the source Petri net removing the initial and final marking, and connecting to each “initial” place a hidden timed transition mimicking the case start
 Parameters
net0 – Initial Petri net provided to the object
initial_marking0 – Initial marking of the Petri net provided to the object
final_marking0 – Final marking of the Petri net provided to the object
s_map – Stochastic map of transitions (EXPONENTIAL distribution since we assume a Markovian process)
avg_time_starts – Average time interlapsed between case starts
 Returns
net – Petri net that will be simulated
initial_marking – Initial marking of the Petri net that will be simulated (empty)
final_marking – Final marking of the Petri net that will be simulated (empty)
s_map – Stochastic map of transitions enriched by new hidden casegenerator transitions

pm4py.objects.stochastic_petri.tangible_reachability module¶

pm4py.objects.stochastic_petri.tangible_reachability.
get_tangible_reachability_from_log_net_im_fm
(log, net, im, fm, parameters=None)[source]¶ Gets the tangible reachability graph from a log and an accepting Petri net
 Parameters
log – Event log
net – Petri net
im – Initial marking
fm – Final marking
 Returns
reachab_graph – Reachability graph
tangible_reach_graph – Tangible reachability graph
stochastic_info – Stochastic information

pm4py.objects.stochastic_petri.tangible_reachability.
get_tangible_reachability_from_net_im_sinfo
(net, im, stochastic_info, parameters=None)[source]¶ Gets the tangible reacahbility graph from a Petri net, an initial marking and a stochastic map
 Parameters
net – Petri net
im – Initial marking
fm – Final marking
stochastic_info – Stochastic information
 Returns
reachab_graph – Reachability graph
tangible_reach_graph – Tangible reachability graph

pm4py.objects.stochastic_petri.tangible_reachability.
get_tangible_reachability_from_reachability
(reach_graph, stochastic_info)[source]¶ Gets the tangible reachability graph from the reachability graph and the stochastic transition map
 Parameters
reach_graph – Reachability graph
stochastic_info – Stochastic information
 Returns
Tangible reachability graph
 Return type
tangible_reach_graph
pm4py.objects.stochastic_petri.utils module¶

pm4py.objects.stochastic_petri.utils.
choice
(a, size=None, replace=True, p=None)¶ Generates a random sample from a given 1D array
New in version 1.7.0.
Note
New code should use the
choice
method of adefault_rng()
instance instead; please see the randomquickstart. Parameters
a (1D arraylike or int) – If an ndarray, a random sample is generated from its elements. If an int, the random sample is generated as if it were
np.arange(a)
size (int or tuple of ints, optional) – Output shape. If the given shape is, e.g.,
(m, n, k)
, thenm * n * k
samples are drawn. Default is None, in which case a single value is returned.replace (boolean, optional) – Whether the sample is with or without replacement. Default is True, meaning that a value of
a
can be selected multiple times.p (1D arraylike, optional) – The probabilities associated with each entry in a. If not given, the sample assumes a uniform distribution over all entries in
a
.
 Returns
samples – The generated random samples
 Return type
single item or ndarray
 Raises
ValueError – If a is an int and less than zero, if a or p are not 1dimensional, if a is an arraylike of size 0, if p is not a vector of probabilities, if a and p have different lengths, or if replace=False and the sample size is greater than the population size
See also
randint
,shuffle
,permutation
Generator.choice
which should be used in new code
Notes
Setting userspecified probabilities through
p
uses a more general but less efficient sampler than the default. The general sampler produces a different sample than the optimized sampler even if each element ofp
is 1 / len(a).Sampling random rows from a 2D array is not possible with this function, but is possible with Generator.choice through its
axis
keyword.Examples
Generate a uniform random sample from np.arange(5) of size 3:
>>> np.random.choice(5, 3) array([0, 3, 4]) # random >>> #This is equivalent to np.random.randint(0,5,3)
Generate a nonuniform random sample from np.arange(5) of size 3:
>>> np.random.choice(5, 3, p=[0.1, 0, 0.3, 0.6, 0]) array([3, 3, 0]) # random
Generate a uniform random sample from np.arange(5) of size 3 without replacement:
>>> np.random.choice(5, 3, replace=False) array([3,1,0]) # random >>> #This is equivalent to np.random.permutation(np.arange(5))[:3]
Generate a nonuniform random sample from np.arange(5) of size 3 without replacement:
>>> np.random.choice(5, 3, replace=False, p=[0.1, 0, 0.3, 0.6, 0]) array([2, 3, 0]) # random
Any of the above can be repeated with an arbitrary arraylike instead of just integers. For instance:
>>> aa_milne_arr = ['pooh', 'rabbit', 'piglet', 'Christopher'] >>> np.random.choice(aa_milne_arr, 5, p=[0.5, 0.1, 0.1, 0.3]) array(['pooh', 'pooh', 'pooh', 'Christopher', 'piglet'], # random dtype='<U11')