-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'PMPY-2066' into 'integration'
PMPY-2066 Insertion graph-based O2O relationships in the OCEL Closes PMPY-2066 See merge request process-mining/pm4py/pm4py-core!960
- Loading branch information
Showing
4 changed files
with
98 additions
and
1 deletion.
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
72 changes: 72 additions & 0 deletions
72
pm4py/algo/transformation/ocel/graphs/ocel20_computation.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,72 @@ | ||
from enum import Enum | ||
from pm4py.util import constants, exec_utils | ||
from pm4py.algo.transformation.ocel.graphs import object_interaction_graph, object_descendants_graph, object_inheritance_graph, object_cobirth_graph, object_codeath_graph | ||
from pm4py.objects.ocel.obj import OCEL | ||
from typing import Optional, Dict, Any | ||
from copy import copy | ||
import pandas as pd | ||
|
||
|
||
class Parameters(Enum): | ||
INCLUDED_GRAPHS = "included_graphs" | ||
|
||
|
||
def apply(ocel: OCEL, parameters: Optional[Dict[Any, Any]] = None) -> OCEL: | ||
""" | ||
Inserts the information inferred from the graph computations in the list of O2O relations of the OCEL | ||
Parameters | ||
---------------- | ||
ocel | ||
Object-centric event log | ||
parameters | ||
Possible parameters of the algorithm: | ||
- Parameters.INCLUDED_GRAPHS => graphs to include in the list of O2O relations | ||
(object_interaction_graph, object_descendants_graph, object_inheritance_graph, object_cobirth_graph, object_codeath_graph) | ||
Returns | ||
--------------- | ||
enriched_ocel | ||
Enriched object-centric event log | ||
""" | ||
if parameters is None: | ||
parameters = {} | ||
|
||
included_graphs = exec_utils.get_param_value(Parameters.INCLUDED_GRAPHS, parameters, None) | ||
if included_graphs is None: | ||
included_graphs = {"object_interaction_graph", "object_descendants_graph", "object_inheritance_graph", "object_cobirth_graph", "object_codeath_graph"} | ||
|
||
o2o = [] | ||
|
||
if "object_interaction_graph" in included_graphs: | ||
graph = object_interaction_graph.apply(ocel, parameters=parameters) | ||
for el in graph: | ||
if el[0] != el[1]: | ||
o2o.append({ocel.object_id_column: el[0], ocel.object_id_column+"_2": el[1], ocel.qualifier: "object_interaction_graph"}) | ||
o2o.append({ocel.object_id_column: el[1], ocel.object_id_column+"_2": el[0], ocel.qualifier: "object_interaction_graph"}) | ||
if "object_descendants_graph" in included_graphs: | ||
graph = object_descendants_graph.apply(ocel, parameters=parameters) | ||
for el in graph: | ||
o2o.append({ocel.object_id_column: el[0], ocel.object_id_column + "_2": el[1], | ||
ocel.qualifier: "object_descendants_graph"}) | ||
if "object_inheritance_graph" in included_graphs: | ||
graph = object_descendants_graph.apply(ocel, parameters=parameters) | ||
for el in graph: | ||
o2o.append({ocel.object_id_column: el[0], ocel.object_id_column + "_2": el[1], | ||
ocel.qualifier: "object_inheritance_graph"}) | ||
if "object_cobirth_graph" in included_graphs: | ||
graph = object_cobirth_graph.apply(ocel, parameters=parameters) | ||
for el in graph: | ||
o2o.append({ocel.object_id_column: el[0], ocel.object_id_column + "_2": el[1], | ||
ocel.qualifier: "object_cobirth_graph"}) | ||
if "object_codeath_graph" in included_graphs: | ||
graph = object_codeath_graph.apply(ocel, parameters=parameters) | ||
for el in graph: | ||
o2o.append({ocel.object_id_column: el[0], ocel.object_id_column + "_2": el[1], | ||
ocel.qualifier: "object_codeath_graph"}) | ||
|
||
ocel = copy(ocel) | ||
o2o = pd.DataFrame(o2o) | ||
ocel.o2o = pd.concat([ocel.o2o, o2o]) | ||
|
||
return ocel |
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