pm4py.objects.petri_net.utils 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.petri_net.utils.align_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.petri_net.utils.align_utils.search_path_among_sol(sync_net: PetriNet, ini: Marking, fin: Marking, activated_transitions: List[Transition], skip='>>') Tuple[List[Transition], bool, int][source]#

(Efficient method) Searches a firing sequence among the X vector that is the solution of the (extended) marking equation

Parameters#

sync_net

Synchronous product net

ini

Initial marking of the net

fin

Final marking of the net

activated_transitions

Transitions that have non-zero occurrences in the X vector

skip

Skip transition

Returns#

firing_sequence

Firing sequence

reach_fm

Boolean value that tells if the final marking is reached by the firing sequence

explained_events

Number of explained events

pm4py.objects.petri_net.utils.align_utils.construct_standard_cost_function(synchronous_product_net, skip)[source]#

Returns the standard cost function, which is: * event moves: cost 1000 * model moves: cost 1000 * tau moves: cost 1 * sync moves: cost 0 :param synchronous_product_net: :param skip: :return:

pm4py.objects.petri_net.utils.align_utils.pretty_print_alignments(alignments)[source]#
Takes an alignment and prints it to the console, e.g.:

A | B | C | D |

Returns:

Nothing

pm4py.objects.petri_net.utils.align_utils.add_markings(curr, add)[source]#
class pm4py.objects.petri_net.utils.align_utils.SearchTuple(f, g, h, m, p, t, x, trust)[source]#

Bases: object

class pm4py.objects.petri_net.utils.align_utils.DijkstraSearchTuple(g, m, p, t, l)[source]#

Bases: object

class pm4py.objects.petri_net.utils.align_utils.DijkstraSearchTupleForAntiAndMulti(g, m, r)[source]#

Bases: object

class pm4py.objects.petri_net.utils.align_utils.TweakedSearchTuple(f, g, h, m, p, t, x, trust, virgin)[source]#

Bases: object

pm4py.objects.petri_net.utils.align_utils.get_visible_transitions_eventually_enabled_by_marking(net, marking)[source]#

Get visible transitions eventually enabled by marking (passing possibly through hidden transitions) Parameters ———- net

Petri net

marking

Current marking

pm4py.objects.petri_net.utils.align_utils.discountedEditDistance(s1, s2, exponent=2, modeled=True)[source]#

Fast implementation of the discounted distance Inspired from the faster version of the edit distance

pm4py.objects.petri_net.utils.align_utils.levenshtein(seq1, seq2)[source]#

Edit distance without substitution

pm4py.objects.petri_net.utils.check_soundness 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.petri_net.utils.check_soundness.check_source_and_sink_reachability(net, unique_source, unique_sink)[source]#

Checks reachability of the source and the sink place from all simulation nodes (places/transitions) of the Petri net

Parameters#

net

Petri net

unique_source

Unique source place of the Petri net

unique_sink

Unique sink place of the Petri net

Returns#

boolean

Boolean value that is true if each node is in a path from the source place to the sink place

pm4py.objects.petri_net.utils.check_soundness.check_source_place_presence(net)[source]#

Check if there is a unique source place with empty connections

Parameters#

net

Petri net

Returns#

place

Unique source place (or None otherwise)

pm4py.objects.petri_net.utils.check_soundness.check_sink_place_presence(net)[source]#

Check if there is a unique sink place with empty connections

Parameters#

net

Petri net

Returns#

place

Unique source place (or None otherwise)

pm4py.objects.petri_net.utils.check_soundness.check_wfnet(net)[source]#

Check if the Petri net is a workflow net

Parameters#

net

Petri net

Returns#

boolean

Boolean value that is true when the Petri net is a workflow net

pm4py.objects.petri_net.utils.check_soundness.check_source_sink_place_conditions(net)[source]#

Check some conditions on the source/sink place important for a sound workflow net

Parameters#

net

Petri net

Returns#

boolean

Boolean value (True is good)

pm4py.objects.petri_net.utils.check_soundness.check_easy_soundness_net_in_fin_marking(net, ini, fin)[source]#

Checks the easy soundness of a Petri net having the initial and the final marking

Parameters#

net

Petri net

ini

Initial marking

fin

Final marking

Returns#

boolean

Boolean value

pm4py.objects.petri_net.utils.check_soundness.check_easy_soundness_of_wfnet(net)[source]#

Checks the easy soundness of a workflow net

Parameters#

net

Petri net

Returns#

boolean

Boolean value

pm4py.objects.petri_net.utils.consumption_matrix 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/>.

class pm4py.objects.petri_net.utils.consumption_matrix.ConsumptionMatrix(net: PetriNet)[source]#

Bases: object

property places: Dict[Place, int]#

Gets the places in the order in which they have been inserted in the consumption matrix

Returns#

place_indices

Dictionary associating to each place an incremental number

property transitions: Dict[Transition, int]#

Gets the transitions in the order in which they have been inserted in the consumption matrix

Returns#

trans_indices

Dictionary associating to each transition an incremental number

property c_matrix: ndarray#

Gets the Numpy representation of the consumption matrix

Returns#

C

C matrix

pm4py.objects.petri_net.utils.consumption_matrix.construct(net: PetriNet) ConsumptionMatrix[source]#

Construct a consumption matrix given a Petri net

Parameters#

net

Petri net

Returns#

cons_mat

Consumption matrix object

pm4py.objects.petri_net.utils.decomposition 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.petri_net.utils.decomposition.get_graph_components(places, inv_trans, trans_dup_label, tmap)[source]#
pm4py.objects.petri_net.utils.decomposition.decompose(net, im, fm)[source]#
pm4py.objects.petri_net.utils.decomposition.merge_comp(comp1, comp2)[source]#
pm4py.objects.petri_net.utils.decomposition.merge_sublist_nets(list_nets)[source]#

pm4py.objects.petri_net.utils.embed_stochastic_map 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.petri_net.utils.embed_stochastic_map.apply(smap, parameters=None)[source]#

Embed the stochastic map into the Petri net

Parameters#

smap

Stochastic map

parameters

Possible parameters of the algorithm

Returns#

void

pm4py.objects.petri_net.utils.embed_stochastic_map.extract(net, parameters=None)[source]#

Extract the stochastic map from the Petri net

Parameters#

net

Petri net

parameters

Possible parameters of the algorithm

Returns#

void

pm4py.objects.petri_net.utils.explore_path 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.petri_net.utils.final_marking 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.petri_net.utils.final_marking.discover_final_marking(petri)[source]#

Discovers final marking from a Petri net

Parameters#

petri

Petri net

Returns#

final_marking

Final marking

pm4py.objects.petri_net.utils.incidence_matrix 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/>.

class pm4py.objects.petri_net.utils.incidence_matrix.IncidenceMatrix(net)[source]#

Bases: object

encode_marking(marking)[source]#
property a_matrix#
property places#
property transitions#
pm4py.objects.petri_net.utils.incidence_matrix.construct(net)[source]#

pm4py.objects.petri_net.utils.initial_marking 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.petri_net.utils.initial_marking.discover_initial_marking(petri)[source]#

Discovers initial marking from a Petri net

Parameters#

petri

Petri net

Returns#

initial_marking

Initial marking of the Petri net

pm4py.objects.petri_net.utils.murata 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.petri_net.utils.murata.apply_reduction(net: PetriNet, im: Marking, fm: Marking) Tuple[PetriNet, Marking, Marking][source]#

Apply the Murata reduction to an accepting Petri net, removing the structurally redundant places.

The implementation follows the Berthelot algorithm as in: https://svn.win.tue.nl/repos/prom/Packages/Murata/Trunk/src/org/processmining/algorithms/BerthelotAlgorithm.java

Parameters#

net

Petri net

im

Initial marking

fm

Final marking

Returns#

net

Petri net

im

Initial marking

fm

Final marking

pm4py.objects.petri_net.utils.networkx_graph 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.petri_net.utils.networkx_graph.create_networkx_undirected_graph(net, unique_source, unique_sink)[source]#

Create a NetworkX undirected graph from a Petri net, returning also correspondences for the unique source and the unique sink places that were discovered

Parameters#

net

Petri net

unique_source

Unique source place

unique_sink

Unique sink place

Returns#

graph

NetworkX graph

unique_source_corr

Correspondence in the NetworkX graph of the unique source place

unique_sink_corr

Correspondence in the NetworkX graph of the unique sink place

inv_dictionary

Correspondence between NetworkX nodes and Petri net entities

pm4py.objects.petri_net.utils.networkx_graph.create_networkx_directed_graph(net, weight=None)[source]#

Create a NetworkX directed graph from a Petri net

Parameters#

net

Petri net

Returns#

graph

NetworkX digraph

inv_dictionary

Correspondence between NetworkX nodes and Petri net entities

pm4py.objects.petri_net.utils.networkx_graph.create_networkx_directed_graph_ret_dict_both_ways(net, weight=None)[source]#

Create a NetworkX directed graph from a Petri net

Parameters#

net

Petri net

Returns#

graph

NetworkX digraph

dictionary

dict mapping Petri net nodes to NetworkX nodes

inv_dictionary

dict mapping NetworkX nodes to Petri net nodes

pm4py.objects.petri_net.utils.obj_marking 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/>.

class pm4py.objects.petri_net.utils.obj_marking.ObjMarking(*args, **kwargs)[source]#

Bases: dict

update([E, ]**F) None.  Update D from dict/iterable E and F.[source]#

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

class pm4py.objects.petri_net.utils.obj_marking.ObjMarkingAccessor(obj_marking, key)[source]#

Bases: object

pm4py.objects.petri_net.utils.performance_map 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.petri_net.utils.performance_map.calculate_annotation_for_trace(trace, net, initial_marking, act_trans, activity_key, ht_perf_method='last')[source]#

Calculate annotation for a trace in the variant, in order to retrieve information useful for calculate frequency/performance for all the traces belonging to the variant

Parameters#

trace

Trace

net

Petri net

initial_marking

Initial marking

act_trans

Activated transitions during token replay of the given trace

activity_key

Attribute that identifies the activity (must be specified if different from concept:name)

ht_perf_method

Method to use in order to annotate hidden transitions (performance value could be put on the last possible point (last) or in the first possible point (first)

Returns#

annotation

Statistics annotation for the given trace

pm4py.objects.petri_net.utils.performance_map.single_element_statistics(log, net, initial_marking, aligned_traces, variants_idx, activity_key='concept:name', timestamp_key='time:timestamp', ht_perf_method='last', parameters=None)[source]#

Get single Petrinet element statistics

Parameters#

log

Log

net

Petri net

initial_marking

Initial marking

aligned_traces

Result of the token-based replay

variants_idx

Variants along with indexes of belonging traces

activity_key

Activity key (must be specified if different from concept:name)

timestamp_key

Timestamp key (must be specified if different from time:timestamp)

ht_perf_method

Method to use in order to annotate hidden transitions (performance value could be put on the last possible point (last) or in the first possible point (first)

parameters

Possible parameters of the algorithm

Returns#

statistics

Petri net element statistics (frequency, unaggregated performance)

pm4py.objects.petri_net.utils.performance_map.find_min_max_trans_frequency(statistics)[source]#

Find minimum and maximum transition frequency

Parameters#

statistics

Element statistics

Returns#

min_frequency

Minimum transition frequency (in the replay)

max_frequency

Maximum transition frequency (in the replay)

pm4py.objects.petri_net.utils.performance_map.find_min_max_arc_frequency(statistics)[source]#

Find minimum and maximum arc frequency

Parameters#

statistics

Element statistics

Returns#

min_frequency

Minimum arc frequency

max_frequency

Maximum arc frequency

pm4py.objects.petri_net.utils.performance_map.aggregate_stats(statistics, elem, aggregation_measure)[source]#

Aggregate the statistics

Parameters#

statistics

Element statistics

elem

Current element

aggregation_measure

Aggregation measure (e.g. mean, min) to use

Returns#

aggr_stat

Aggregated statistics

pm4py.objects.petri_net.utils.performance_map.find_min_max_arc_performance(statistics, aggregation_measure)[source]#

Find minimum and maximum arc performance

Parameters#

statistics

Element statistics

aggregation_measure

Aggregation measure (e.g. mean, min) to use

Returns#

min_performance

Minimum performance

max_performance

Maximum performance

pm4py.objects.petri_net.utils.performance_map.aggregate_statistics(statistics, measure='frequency', aggregation_measure=None, stat_locale: dict = {})[source]#

Gets aggregated statistics

Parameters#

statistics

Individual element statistics (including unaggregated performances)

measure

Desidered view on data (frequency or performance)

aggregation_measure

Aggregation measure (e.g. mean, min) to use

stat_locale

Dict to locale the stat strings

Returns#

aggregated_statistics

Aggregated statistics for arcs, transitions, places

pm4py.objects.petri_net.utils.performance_map.get_transition_performance_with_token_replay(log, net, im, fm)[source]#

Gets the transition performance through the usage of token-based replay

Parameters#

log

Event log

net

Petri net

im

Initial marking

fm

Final marking

Returns#

transition_performance

Dictionary where each transition label is associated to performance measures

pm4py.objects.petri_net.utils.performance_map.get_idx_exceeding_specified_acti_performance(log, transition_performance, activity, lower_bound)[source]#

Get indexes of the cases exceeding the specified activity performance threshold

Parameters#

log

Event log

transition_performance

Dictionary where each transition label is associated to performance measures

activity

Target activity (of the filter)

lower_bound

Lower bound (filter cases which have a duration of the activity exceeding)

Returns#

idx

A list of indexes in the log

pm4py.objects.petri_net.utils.performance_map.filter_cases_exceeding_specified_acti_performance(log, transition_performance, activity, lower_bound)[source]#

Filter cases exceeding the specified activity performance threshold

Parameters#

log

Event log

transition_performance

Dictionary where each transition label is associated to performance measures

activity

Target activity (of the filter)

lower_bound

Lower bound (filter cases which have a duration of the activity exceeding)

Returns#

filtered_log

Filtered log

pm4py.objects.petri_net.utils.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.petri_net.utils.petri_utils.is_sub_marking(sub_marking: Marking, marking: Marking) bool[source]#
pm4py.objects.petri_net.utils.petri_utils.place_set_as_marking(places) Marking[source]#
pm4py.objects.petri_net.utils.petri_utils.get_arc_type(elem)[source]#
pm4py.objects.petri_net.utils.petri_utils.pre_set(elem, arc_type=None) Set[source]#
pm4py.objects.petri_net.utils.petri_utils.post_set(elem, arc_type=None) Set[source]#
pm4py.objects.petri_net.utils.petri_utils.remove_transition(net: PetriNet, trans: Transition) PetriNet[source]#

Remove a transition from a Petri net

Parameters#

net

Petri net

trans

Transition to remove

Returns#

net

Petri net

pm4py.objects.petri_net.utils.petri_utils.add_place(net: PetriNet, name=None) Place[source]#
pm4py.objects.petri_net.utils.petri_utils.add_transition(net: PetriNet, name=None, label=None) Transition[source]#
pm4py.objects.petri_net.utils.petri_utils.merge(trgt: Optional[PetriNet] = None, nets=None) PetriNet[source]#
pm4py.objects.petri_net.utils.petri_utils.remove_place(net: PetriNet, place: Place) PetriNet[source]#

Remove a place from a Petri net

Parameters#

net

Petri net

place

Place to remove

Returns#

net

Petri net

pm4py.objects.petri_net.utils.petri_utils.add_arc_from_to(fr, to, net: PetriNet, weight=1, type=None) Arc[source]#

Adds an arc from a specific element to another element in some net. Assumes from and to are in the net!

Parameters#

fr: transition/place from to: transition/place to net: net to use weight: weight associated to the arc

Returns#

None

pm4py.objects.petri_net.utils.petri_utils.construct_trace_net(trace, trace_name_key='concept:name', activity_key='concept:name')[source]#

Creates a trace net, i.e. a trace in Petri net form.

Parameters#

trace: list input trace, assumed to be a list of events trace_name_key: str key of the attribute that defines the name of the trace activity_key: str key of the attribute of the events that defines the activity name

Returns#

tuple: tuple of the net, initial marking and the final marking

pm4py.objects.petri_net.utils.petri_utils.construct_trace_net_cost_aware(trace, costs, trace_name_key='concept:name', activity_key='concept:name')[source]#

Creates a trace net, i.e. a trace in Petri net form mapping specific costs to transitions.

Parameters#

trace: list input trace, assumed to be a list of events costs: list list of costs, length should be equal to the length of the input trace trace_name_key: str key of the attribute that defines the name of the trace activity_key: str key of the attribute of the events that defines the activity name

Returns#

tuple: tuple of the net, initial marking, final marking and map of costs

pm4py.objects.petri_net.utils.petri_utils.acyclic_net_variants(net, initial_marking, final_marking, activity_key='concept:name')[source]#

Given an acyclic accepting Petri net, initial and final marking extracts a set of variants (in form of traces) replayable on the net. Warning: this function is based on a marking exploration. If the accepting Petri net contains loops, the method will not work properly as it stops the search if a specific marking has already been encountered.

Parameters#

type activity_key:

str

param net:

An acyclic workflow net

param initial_marking:

The initial marking of the net.

param final_marking:

The final marking of the net.

param activity_key:

activity key to use

Returns#

return:

variants: list Set of variants - in the form of Trace objects - obtainable executing the net

pm4py.objects.petri_net.utils.petri_utils.get_transition_by_name(net: PetriNet, transition_name) Optional[Transition][source]#

Get a transition by its name

Parameters#

net

Petri net

transition_name

Transition name

Returns#

transition

Transition object

pm4py.objects.petri_net.utils.petri_utils.decorate_places_preset_trans(net: PetriNet)[source]#

Decorate places with information useful for the replay

Parameters#

net

Petri net

pm4py.objects.petri_net.utils.petri_utils.decorate_transitions_prepostset(net: PetriNet)[source]#

Decorate transitions with sub and addition markings

Parameters#

net

Petri net

pm4py.objects.petri_net.utils.petri_utils.get_places_shortest_path(net, place_to_populate, current_place, places_shortest_path, actual_list, rec_depth, max_rec_depth)[source]#

Get shortest path between places lead by hidden transitions

Parameters#

net

Petri net

place_to_populate

Place that we are populating the shortest map of

current_place

Current visited place (must explore its transitions)

places_shortest_path

Current dictionary

actual_list

Actual list of transitions to enable

rec_depth

Recursion depth

max_rec_depth

Maximum recursion depth

pm4py.objects.petri_net.utils.petri_utils.get_places_shortest_path_by_hidden(net: PetriNet, max_rec_depth)[source]#

Get shortest path between places lead by hidden transitions

Parameters#

net

Petri net

max_rec_depth

Maximum recursion depth

pm4py.objects.petri_net.utils.petri_utils.invert_spaths_dictionary(spaths)[source]#

Invert the shortest paths (between places) dictionary, from target-source to source-target

Parameters#

spaths

Shortest paths dictionary

Returns#

inv_spaths

Inverted shortest paths dictionary

pm4py.objects.petri_net.utils.petri_utils.remove_unconnected_components(net: PetriNet) PetriNet[source]#

Remove unconnected components from a Petri net

Parameters#

net

Petri net

Returns#

net

Cleaned Petri net

pm4py.objects.petri_net.utils.petri_utils.get_s_components_from_petri(net, im, fm, rec_depth=0, curr_s_comp=None, visited_places=None, list_s_components=None, max_rec_depth=6)[source]#

Gets the S-components from a Petri net

Parameters#

net

Petri net

im

Initial marking

fm

Final marking

curr_s_comp

Current S component

visited_places

Visited places

list_s_components

List of S-components

max_rec_depth

Maximum recursion depth

Returns#

s_components

List of S-components

pm4py.objects.petri_net.utils.petri_utils.remove_arc(net: PetriNet, arc: Arc) PetriNet[source]#

Removes an arc from a Petri net

Parameters#

net

Petri net

arc

Arc of the Petri net

Returns#

net

Petri net

pm4py.objects.petri_net.utils.projection 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.petri_net.utils.projection.project_net_on_place(place)[source]#

Project a Petri net on a place

Parameters#

place

Place

Returns#

net

(Place) net

im

Empty initial marking

fm

Empty final marking

pm4py.objects.petri_net.utils.projection.project_net_on_matrix(net, activities, parameters=None)[source]#

Project a Petri net with: - only visible transitions - where each place preset/postset is disjoint - with unique visible transitions on a numeric matrix

Parameters#

net

Petri net

activities

List of activities

parameters

Possible parameters of the algorithm

pm4py.objects.petri_net.utils.reachability_graph 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/>.

class pm4py.objects.petri_net.utils.reachability_graph.Parameters(value)[source]#

Bases: Enum

An enumeration.

MAX_ELAB_TIME = 'max_elab_time'#
PETRI_SEMANTICS = 'petri_semantics'#
pm4py.objects.petri_net.utils.reachability_graph.staterep(name)[source]#

Creates a string representation for a state of a transition system. Necessary because graphviz does not support symbols simulation than alphanimerics and ‘_’. TODO: find a better representation.

Parameters#

name: the name of a state

Returns#

Version of the name filtered of non-alphanumerical characters (except ‘_’).

pm4py.objects.petri_net.utils.reachability_graph.marking_flow_petri(net, im, return_eventually_enabled=False, parameters=None)[source]#

Construct the marking flow of a Petri net

Parameters#

net

Petri net

im

Initial marking

return_eventually_enabled

Return the eventually enabled (visible) transitions

pm4py.objects.petri_net.utils.reachability_graph.construct_reachability_graph_from_flow(incoming_transitions, outgoing_transitions, use_trans_name=False, parameters=None)[source]#

Construct the reachability graph from the marking flow

Parameters#

incoming_transitions

Incoming transitions

outgoing_transitions

Outgoing transitions

use_trans_name

Use the transition name

Returns#

re_gr

Transition system that represents the reachability graph of the input Petri net.

pm4py.objects.petri_net.utils.reachability_graph.construct_reachability_graph(net, initial_marking, use_trans_name=False, parameters=None) TransitionSystem[source]#

Creates a reachability graph of a certain Petri net. DO NOT ATTEMPT WITH AN UNBOUNDED PETRI NET, EVER.

Parameters#

net: Petri net initial_marking: initial marking of the Petri net.

Returns#

re_gr: Transition system that represents the reachability graph of the input Petri net.

pm4py.objects.petri_net.utils.reduction 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.petri_net.utils.reduction.reduce_single_entry_transitions(net)[source]#

Reduces the number of the single entry transitions in the Petri net

Parameters#

net

Petri net

pm4py.objects.petri_net.utils.reduction.reduce_single_exit_transitions(net)[source]#

Reduces the number of the single exit transitions in the Petri net

Parameters#

net

Petri net

pm4py.objects.petri_net.utils.reduction.apply_simple_reduction(net)[source]#

Apply a simple reduction to the Petri net

Parameters#

net

Petri net

pm4py.objects.petri_net.utils.reduction.apply_fst_rule(net)[source]#

Apply the Fusion of Series Transitions (FST) rule

Parameters#

net

Reset Inhibitor net

pm4py.objects.petri_net.utils.reduction.apply_fsp_rule(net, im=None, fm=None)[source]#

Apply the Fusion of Series Places (FSP) rule

Parameters#

net

Reset Inhibitor net

pm4py.objects.petri_net.utils.reduction.apply_fpt_rule(net)[source]#

Apply the Fusion of Parallel Transitions (FPT) rule

Parameters#

net

Reset Inhibitor net

pm4py.objects.petri_net.utils.reduction.apply_fpp_rule(net, im=None)[source]#

Apply the Fusion of Parallel Places (FPP) rule

Parameters#

net

Reset Inhibitor net

pm4py.objects.petri_net.utils.reduction.apply_elt_rule(net)[source]#

Apply the Elimination of Self-Loop Transitions (ELT) rule

Parameters#

net

Reset Inhibitor net

pm4py.objects.petri_net.utils.reduction.apply_elp_rule(net, im=None)[source]#

Apply the Elimination of Self-Loop Places (ELP) rule

Parameters#

net

Reset Inhibitor net

pm4py.objects.petri_net.utils.reduction.apply_a_rule(net)[source]#

Apply the Abstraction (A) rule

Parameters#

net

Reset Inhibitor net

pm4py.objects.petri_net.utils.reduction.apply_r_rule(net)[source]#

Apply the Reset Reduction (R) rule

Parameters#

net

Reset Inhibitor net

pm4py.objects.petri_net.utils.reduction.power_set(iterable, min=0)[source]#
pm4py.objects.petri_net.utils.reduction.apply_reset_inhibitor_net_reduction(net, im=None, fm=None)[source]#

Apply a thorough reduction to the Reset Inhibitor net

Parameters#

net

Reset Inhibitor net

pm4py.objects.petri_net.utils.synchronous_product 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.petri_net.utils.synchronous_product.construct(pn1, im1, fm1, pn2, im2, fm2, skip)[source]#

Constructs the synchronous product net of two given Petri nets.

Parameters:
  • pn1 – Petri net 1

  • im1 – Initial marking of Petri net 1

  • fm1 – Final marking of Petri net 1

  • pn2 – Petri net 2

  • im2 – Initial marking of Petri net 2

  • fm2 – Final marking of Petri net 2

  • skip – Symbol to be used as skip

Returns#

return:

Synchronous product net and associated marking labels are of the form (a,>>)

pm4py.objects.petri_net.utils.synchronous_product.construct_cost_aware(pn1, im1, fm1, pn2, im2, fm2, skip, pn1_costs, pn2_costs, sync_costs)[source]#

Constructs the synchronous product net of two given Petri nets.

Parameters:
  • pn1 – Petri net 1

  • im1 – Initial marking of Petri net 1

  • fm1 – Final marking of Petri net 1

  • pn2 – Petri net 2

  • im2 – Initial marking of Petri net 2

  • fm2 – Final marking of Petri net 2

  • skip – Symbol to be used as skip

  • pn1_costs – dictionary mapping transitions of pn1 to corresponding costs

  • pn2_costs – dictionary mapping transitions of pn2 to corresponding costs

  • pn1_costs – dictionary mapping pairs of transitions in pn1 and pn2 to costs

  • sync_costs – Costs of sync moves

Returns#

return:

Synchronous product net and associated marking labels are of the form (a,>>)