pm4py.objects.stochastic_petri package#

This file is part of PM4Py (More Info: https://pm4py.fit.fraunhofer.de).

PM4Py is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PM4Py is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PM4Py. If not, see <https://www.gnu.org/licenses/>.

Submodules#

pm4py.objects.stochastic_petri.ctmc module#

This file is part of PM4Py (More Info: https://pm4py.fit.fraunhofer.de).

PM4Py is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PM4Py is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PM4Py. If not, see <https://www.gnu.org/licenses/>.

pm4py.objects.stochastic_petri.ctmc.get_corr_hex(num)[source]#

Gets correspondence between a number and an hexadecimal string

Parameters#

num

Number

Returns#

hex_string

Hexadecimal string

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#

color_dictionary

Dictionary of colors

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

Q-matrix 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

Q-matrix from the tangible reachability graph

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_result

Transient analysis result

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#

q_matrix

Q-matrix from the tangible reachability graph

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_result

Transient analysis 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_result

Transient analysis result

pm4py.objects.stochastic_petri.ctmc.nullspace(a_matrix, atol=1e-13, 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_matrixndarray

A should be at most 2-D. A 1-D array with length k will be treated as a 2-D with shape (1, k)

atolfloat

The absolute tolerance for a zero singular value. Singular values smaller than atol are considered to be zero.

rtolfloat

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#

nsndarray

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.

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.tangible_reachability module#

This file is part of PM4Py (More Info: https://pm4py.fit.fraunhofer.de).

PM4Py is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PM4Py is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PM4Py. If not, see <https://www.gnu.org/licenses/>.

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_reach_graph

Tangible reachability graph

pm4py.objects.stochastic_petri.utils module#

This file is part of PM4Py (More Info: https://pm4py.fit.fraunhofer.de).

PM4Py is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PM4Py is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PM4Py. If not, see <https://www.gnu.org/licenses/>.

pm4py.objects.stochastic_petri.utils.choice(a, size=None, replace=True, p=None)#

Generates a random sample from a given 1-D array

New in version 1.7.0.

Note

New code should use the ~numpy.random.Generator.choice method of a ~numpy.random.Generator instance instead; please see the random-quick-start.

Parameters#

a1-D array-like 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)

sizeint or tuple of ints, optional

Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned.

replaceboolean, optional

Whether the sample is with or without replacement. Default is True, meaning that a value of a can be selected multiple times.

p1-D array-like, optional

The probabilities associated with each entry in a. If not given, the sample assumes a uniform distribution over all entries in a.

Returns#

samplessingle item or ndarray

The generated random samples

Raises#

ValueError

If a is an int and less than zero, if a or p are not 1-dimensional, if a is an array-like 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 random.Generator.choice: which should be used in new code

Notes#

Setting user-specified 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 of p is 1 / len(a).

Sampling random rows from a 2-D 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 non-uniform 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 non-uniform 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 array-like 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')
pm4py.objects.stochastic_petri.utils.pick_transition(et, smap)[source]#

Pick a transition in a set of transitions based on the weights specified by the stochastic map

Parameters#

et

Enabled transitions

smap

Stochastic map

Returns#

trans

Transition chosen according to the weights