-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release' into release-github
# Conflicts: # pm4py/algo/conformance/alignments/process_tree/util/__init__.py # pm4py/algo/transformation/__init__.py # pm4py/meta.py # pm4py/objects/bpmn/__init__.py # pm4py/objects/bpmn/obj.py # pm4py/objects/bpmn/util/__init__.py # pm4py/objects/ocel/__init__.py # pm4py/objects/ocel/util/__init__.py # pm4py/objects/petri_net/utils/reduction.py # requirements_stable.txt
- Loading branch information
Showing
122 changed files
with
6,700 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import os | ||
import pm4py | ||
import pandas as pd | ||
from pm4py.algo.transformation.ocel.features.objects import algorithm as objects_feature_extraction | ||
from pm4py.algo.transformation.ocel.features.events import algorithm as events_feature_extraction | ||
|
||
|
||
def execute_script(): | ||
ocel = pm4py.read_ocel(os.path.join("..", "tests", "input_data", "ocel", "example_log.jsonocel")) | ||
# extracts some features on the objects and embed them in a Pandas dataframe | ||
data_objects, feature_names_objects = objects_feature_extraction.apply(ocel) | ||
objects_features_df = pd.DataFrame(data_objects, columns=feature_names_objects) | ||
print(objects_features_df) | ||
# extracts some features on the events and embed them in a Pandas dataframe | ||
data_events, feature_names_events = events_feature_extraction.apply(ocel) | ||
events_features_df = pd.DataFrame(data_events, columns=feature_names_events) | ||
print(events_features_df) | ||
|
||
|
||
if __name__ == "__main__": | ||
execute_script() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from pm4py.objects.ocel.validation import jsonocel, xmlocel | ||
import os | ||
|
||
|
||
def execute_script(): | ||
# validate a JSONOCEL file against the corresponding schema | ||
validation_result = jsonocel.apply(os.path.join("..", "tests", "input_data", "ocel", "example_log.jsonocel"), os.path.join("..", "tests", "input_data", "ocel", "validation", "schema.json")) | ||
print(validation_result) | ||
# validate an XMLOCEL file against the corresponding schema | ||
validation_result = xmlocel.apply(os.path.join("..", "tests", "input_data", "ocel", "example_log.xmlocel"), os.path.join("..", "tests", "input_data", "ocel", "validation", "schema.xml")) | ||
print(validation_result) | ||
|
||
|
||
if __name__ == "__main__": | ||
execute_script() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pm4py | ||
import os | ||
from pm4py.algo.conformance.alignments.process_tree.util import search_graph_pt_frequency_annotation | ||
from pm4py.visualization.process_tree import visualizer as pt_visualizer | ||
|
||
|
||
def execute_script(): | ||
log = pm4py.read_xes(os.path.join("..", "tests", "input_data", "receipt.xes")) | ||
tree = pm4py.discover_process_tree_inductive(log) | ||
aligned_traces = pm4py.conformance_diagnostics_alignments(log, tree) | ||
tree = search_graph_pt_frequency_annotation.apply(tree, aligned_traces) | ||
gviz = pt_visualizer.apply(tree, parameters={"format": "svg"}, variant=pt_visualizer.Variants.FREQUENCY_ANNOTATION) | ||
pt_visualizer.view(gviz) | ||
|
||
|
||
if __name__ == "__main__": | ||
execute_script() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pm4py | ||
from pm4py.objects.process_tree.obj import ProcessTree, Operator | ||
|
||
|
||
def execute_script(): | ||
root = ProcessTree(operator=Operator.SEQUENCE) | ||
|
||
choice = ProcessTree(operator=Operator.XOR, parent=root) | ||
parallel = ProcessTree(operator=Operator.PARALLEL, parent=root) | ||
|
||
root.children.append(choice) | ||
root.children.append(parallel) | ||
|
||
leaf_A = ProcessTree(label="A", parent=choice) | ||
leaf_B = ProcessTree(label="B", parent=choice) | ||
leaf_C = ProcessTree(label="C", parent=choice) | ||
|
||
choice.children.append(leaf_A) | ||
choice.children.append(leaf_B) | ||
choice.children.append(leaf_C) | ||
|
||
leaf_D = ProcessTree(label="D", parent=parallel) | ||
leaf_E = ProcessTree(label="E", parent=parallel) | ||
leaf_F = ProcessTree(label="F", parent=parallel) | ||
|
||
parallel.children.append(leaf_D) | ||
parallel.children.append(leaf_E) | ||
parallel.children.append(leaf_F) | ||
|
||
pm4py.view_process_tree(root, format="svg") | ||
|
||
# remove leaf_C from choice | ||
choice.children.remove(leaf_C) | ||
|
||
# remove the leaf with label "E" from parallel | ||
parallel.children.remove( | ||
[parallel.children[i] for i in range(len(parallel.children)) if parallel.children[i].label == "E"][0]) | ||
|
||
pm4py.view_process_tree(root, format="svg") | ||
|
||
|
||
if __name__ == "__main__": | ||
execute_script() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from pm4py.util.business_hours import BusinessHours | ||
import datetime | ||
from workalendar.europe import Italy | ||
|
||
|
||
def execute_script(): | ||
ts1 = 100000000 | ||
ts2 = 110000000 | ||
d1 = datetime.datetime.fromtimestamp(ts1) | ||
d2 = datetime.datetime.fromtimestamp(ts2) | ||
print(ts2-ts1) | ||
# default business hours: all the days of the week except Saturday and Sunday are working days. | ||
bh1 = BusinessHours(d1, d2, worktiming=[[7, 12.5], [13, 17]]) | ||
print(bh1.getseconds()) | ||
# let's calculate the business hours using a proper work calendar. | ||
bh2 = BusinessHours(d1, d2, worktiming=[[7, 12.25], [13.25, 17]], workcalendar=Italy()) | ||
print(bh2.getseconds()) | ||
|
||
|
||
if __name__ == "__main__": | ||
execute_script() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
pm4py/algo/conformance/alignments/process_tree/util/search_graph_pt_frequency_annotation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
''' | ||
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/>. | ||
''' | ||
from pm4py.objects.process_tree.obj import ProcessTree | ||
from typing import Optional, Dict, Any, Union | ||
from pm4py.util import typing, exec_utils | ||
from enum import Enum | ||
from collections import Counter | ||
from pm4py.objects.process_tree.utils import bottomup | ||
|
||
|
||
class Parameters(Enum): | ||
NUM_EVENTS_PROPERTY = "num_events_property" | ||
NUM_CASES_PROPERTY = "num_cases_property" | ||
|
||
|
||
def apply(pt: ProcessTree, align_result: Union[typing.AlignmentResult, typing.ListAlignments], | ||
parameters: Optional[Dict[Any, Any]] = None) -> ProcessTree: | ||
""" | ||
Annotate a process tree with frequency information (number of events / number of cases), | ||
given the results of an alignment performed on the process tree. | ||
Parameters | ||
---------------- | ||
pt | ||
Process tree | ||
parameters | ||
Parameters of the algorithm, including: | ||
- Parameters.NUM_EVENTS_PROPERTY => number of events | ||
- Parameters.NUM_CASES_PROPERTY => number of cases | ||
Returns | ||
---------------- | ||
pt | ||
Annotated process tree | ||
""" | ||
if parameters is None: | ||
parameters = {} | ||
|
||
num_events_property = exec_utils.get_param_value(Parameters.NUM_EVENTS_PROPERTY, parameters, "num_events") | ||
num_cases_property = exec_utils.get_param_value(Parameters.NUM_CASES_PROPERTY, parameters, "num_cases") | ||
bottomup_nodes = bottomup.get_bottomup_nodes(pt, parameters=parameters) | ||
|
||
all_paths_open_enabled_events = [] | ||
all_paths_open_enabled_cases = [] | ||
for trace in align_result: | ||
state = trace["state"] | ||
paths = [] | ||
while state.parent is not None: | ||
if state.path: | ||
paths.append(state.path) | ||
state = state.parent | ||
paths.reverse() | ||
paths_enabled = [y[0] for x in paths for y in x if y[1] is ProcessTree.OperatorState.ENABLED] | ||
paths_open = [y[0] for x in paths for y in x if y[1] is ProcessTree.OperatorState.OPEN if | ||
y[0] not in paths_enabled] | ||
all_paths_open_enabled_events = all_paths_open_enabled_events + paths_enabled + paths_open | ||
all_paths_open_enabled_cases = all_paths_open_enabled_cases + list(set(paths_enabled + paths_open)) | ||
all_paths_open_enabled_events_counter = Counter(all_paths_open_enabled_events) | ||
all_paths_open_enabled_cases_counter = Counter(all_paths_open_enabled_cases) | ||
|
||
for node in bottomup_nodes: | ||
node._properties[num_events_property] = all_paths_open_enabled_events_counter[node] | ||
node._properties[num_cases_property] = all_paths_open_enabled_cases_counter[node] | ||
|
||
return pt |
Oops, something went wrong.