pm4py.objects.petri_net.utils.petri_utils module#

PM4Py – A Process Mining Library for Python

Copyright (C) 2024 Process Intelligence Solutions UG (haftungsbeschränkt)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program 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 Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see this software project’s root or visit <https://www.gnu.org/licenses/>.

Website: https://processintelligence.solutions Contact: info@processintelligence.solutions

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:

Petri net

Return type:

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: PetriNet | None = 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:

Petri net

Return type:

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)

Return type:

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

Return type:

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

Return type:

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:
  • 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

Return type:

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) Transition | None[source]#

Get a transition by its name

Parameters:
  • net – Petri net

  • transition_name – Transition name

Returns:

Transition object

Return type:

transition

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:

Inverted shortest paths dictionary

Return type:

inv_spaths

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:

Cleaned Petri net

Return type:

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:

List of S-components

Return type:

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:

Petri net

Return type:

net