Skip to content

Commit 1f38c85

Browse files
Merge branch 'integration' into 212-process-tree-to-powl-converter-utility
2 parents e752a47 + c227811 commit 1f38c85

16 files changed

Lines changed: 141 additions & 23 deletions

File tree

pm4py/algo/discovery/powl/inductive/cuts/concurrency.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from abc import ABC
2-
from typing import Any, Optional, Dict, Generic
2+
from typing import Any, Optional, Dict, Generic, Tuple, List
33

44
from pm4py.algo.discovery.inductive.cuts.concurrency import ConcurrencyCut, ConcurrencyCutUVCL, T
55
from pm4py.algo.discovery.inductive.dtypes.im_ds import IMDataStructureUVCL
@@ -10,7 +10,16 @@ class POWLConcurrencyCut(ConcurrencyCut, ABC, Generic[T]):
1010

1111
@classmethod
1212
def operator(cls, parameters: Optional[Dict[str, Any]] = None) -> StrictPartialOrder:
13-
return StrictPartialOrder([])
13+
raise Exception("This function should not be called!")
14+
15+
@classmethod
16+
def apply(cls, obj: T, parameters: Optional[Dict[str, Any]] = None) -> Optional[Tuple[StrictPartialOrder, List[T]]]:
17+
g = cls.holds(obj, parameters)
18+
if g is None:
19+
return g
20+
else:
21+
children = cls.project(obj, g, parameters)
22+
return StrictPartialOrder(children), children
1423

1524

1625
class POWLConcurrencyCutUVCL(ConcurrencyCutUVCL, POWLConcurrencyCut[IMDataStructureUVCL]):

pm4py/algo/discovery/powl/inductive/cuts/loop.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
from abc import ABC
2-
from typing import Optional, Any, Dict, Generic
2+
from typing import Optional, Any, Dict, Generic, List, Tuple
33

44
from pm4py.algo.discovery.inductive.cuts.loop import LoopCut, LoopCutUVCL, T
55
from pm4py.algo.discovery.inductive.dtypes.im_ds import IMDataStructureUVCL
6-
from pm4py.objects.powl.obj import OperatorPOWL
6+
from pm4py.objects.powl.obj import OperatorPOWL, POWL
77
from pm4py.objects.process_tree.obj import Operator
88

99

1010
class POWLLoopCut(LoopCut, ABC, Generic[T]):
1111

1212
@classmethod
1313
def operator(cls, parameters: Optional[Dict[str, Any]] = None) -> OperatorPOWL:
14-
return OperatorPOWL(Operator.LOOP, [])
14+
raise Exception("This function should not be called!")
15+
16+
@classmethod
17+
def apply(cls, obj: T, parameters: Optional[Dict[str, Any]] = None) -> Optional[Tuple[POWL, List[T]]]:
18+
g = cls.holds(obj, parameters)
19+
if g is None:
20+
return g
21+
else:
22+
children = cls.project(obj, g, parameters)
23+
return OperatorPOWL(Operator.LOOP, children), children
1524

1625

1726
class POWLLoopCutUVCL(LoopCutUVCL, POWLLoopCut[IMDataStructureUVCL]):

pm4py/algo/discovery/powl/inductive/cuts/sequence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class POWLSequenceCut(SequenceCut, ABC, Generic[T]):
1212

1313
@classmethod
1414
def operator(cls, parameters: Optional[Dict[str, Any]] = None) -> Sequence:
15-
return Sequence([])
15+
raise Exception("This function should not be called!")
1616

1717
@classmethod
1818
def apply(cls, obj: T, parameters: Optional[Dict[str, Any]] = None) -> Optional[Tuple[Sequence, List[T]]]:

pm4py/algo/discovery/powl/inductive/cuts/xor.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
from abc import ABC
2-
from typing import Optional, Any, Dict, Generic
2+
from typing import Optional, Any, Dict, Generic, Tuple, List
33

44
from pm4py.algo.discovery.inductive.cuts.xor import ExclusiveChoiceCut, ExclusiveChoiceCutUVCL, T
55
from pm4py.algo.discovery.inductive.dtypes.im_ds import IMDataStructureUVCL
6-
from pm4py.objects.powl.obj import OperatorPOWL
6+
from pm4py.objects.powl.obj import OperatorPOWL, POWL
77
from pm4py.objects.process_tree.obj import Operator
88

99

1010
class POWLExclusiveChoiceCut(ExclusiveChoiceCut, ABC, Generic[T]):
1111

1212
@classmethod
1313
def operator(cls, parameters: Optional[Dict[str, Any]] = None) -> OperatorPOWL:
14-
return OperatorPOWL(Operator.XOR, [])
14+
raise Exception("This function should not be called!")
15+
16+
@classmethod
17+
def apply(cls, obj: T, parameters: Optional[Dict[str, Any]] = None) -> Optional[Tuple[POWL, List[T]]]:
18+
g = cls.holds(obj, parameters)
19+
if g is None:
20+
return g
21+
else:
22+
children = cls.project(obj, g, parameters)
23+
return OperatorPOWL(Operator.XOR, children), children
1524

1625

1726
class POWLExclusiveChoiceCutUVCL(ExclusiveChoiceCutUVCL, POWLExclusiveChoiceCut[IMDataStructureUVCL], ABC):

pm4py/algo/discovery/powl/inductive/fall_through/activity_concurrent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ def apply(cls, obj: IMDataStructureUVCL, pool: Pool = None, manager: Manager = N
2222
for t in log:
2323
l_a.update({tuple(filter(lambda e: e == candidate, t)): log[t]})
2424
l_other.update({tuple(filter(lambda e: e != candidate, t)): log[t]})
25-
return StrictPartialOrder([]), [IMDataStructureUVCL(l_a), IMDataStructureUVCL(l_other)]
25+
children = [IMDataStructureUVCL(l_a), IMDataStructureUVCL(l_other)]
26+
return StrictPartialOrder(children), children
Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
1+
from collections import Counter
2+
from typing import Optional, Tuple, List, Any, Dict
3+
4+
from pm4py.algo.discovery.inductive.dtypes.im_ds import IMDataStructureUVCL
15
from pm4py.algo.discovery.inductive.fall_through.activity_once_per_trace import ActivityOncePerTraceUVCL
26
from pm4py.algo.discovery.powl.inductive.fall_through.activity_concurrent import POWLActivityConcurrentUVCL
7+
from pm4py.objects.powl.obj import StrictPartialOrder
8+
from pm4py.objects.process_tree.obj import ProcessTree, Operator
39

410

511
class POWLActivityOncePerTraceUVCL(ActivityOncePerTraceUVCL, POWLActivityConcurrentUVCL):
6-
pass
12+
@classmethod
13+
def apply(cls, obj: IMDataStructureUVCL,
14+
pool=None,
15+
manager=None,
16+
parameters: Optional[Dict[str, Any]] = None) -> Optional[Tuple[StrictPartialOrder, List[IMDataStructureUVCL]]]:
17+
18+
candidate = cls._get_candidate(obj, pool, manager, parameters)
19+
if candidate is None:
20+
return None
21+
log = obj.data_structure
22+
l_a = Counter()
23+
l_other = Counter()
24+
for t in log:
25+
l_a.update({tuple(filter(lambda e: e == candidate, t)): log[t]})
26+
l_other.update({tuple(filter(lambda e: e != candidate, t)): log[t]})
27+
children = [IMDataStructureUVCL(l_a), IMDataStructureUVCL(l_other)]
28+
return StrictPartialOrder(children), children

pm4py/algo/discovery/powl/inductive/fall_through/empty_traces.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def apply(cls, obj: IMDataStructureUVCL, pool: Pool = None, manager: Manager = N
1818
if cls.holds(obj, parameters):
1919
data_structure = copy(obj.data_structure)
2020
del data_structure[()]
21-
return OperatorPOWL(Operator.XOR, []), [IMDataStructureUVCL(Counter()),
22-
IMDataStructureUVCL(data_structure)]
21+
children = [IMDataStructureUVCL(Counter()), IMDataStructureUVCL(data_structure)]
22+
return OperatorPOWL(Operator.XOR, children), children
2323
else:
2424
return None

pm4py/algo/discovery/powl/inductive/fall_through/flower.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def apply(cls, obj: IMDataStructureUVCL, pool: Pool = None, manager: Manager = N
2121
uvcl_redo = UVCL()
2222
im_uvcl_do = IMDataStructureUVCL(uvcl_do)
2323
im_uvcl_redo = IMDataStructureUVCL(uvcl_redo)
24-
return OperatorPOWL(Operator.LOOP, []), [im_uvcl_do, im_uvcl_redo]
24+
children = [im_uvcl_do, im_uvcl_redo]
25+
return OperatorPOWL(Operator.LOOP, children), children
2526

2627

pm4py/algo/discovery/powl/inductive/fall_through/strict_tau_loop.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ def apply(cls, obj: IMDataStructureUVCL, pool: Pool = None, manager: Manager = N
1515
log = obj.data_structure
1616
proj = cls._get_projected_log(log)
1717
if sum(proj.values()) > sum(log.values()):
18-
return OperatorPOWL(Operator.LOOP, []), [IMDataStructureUVCL(proj), IMDataStructureUVCL(Counter())]
18+
children = [IMDataStructureUVCL(proj), IMDataStructureUVCL(Counter())]
19+
return OperatorPOWL(Operator.LOOP, children), children
1920

pm4py/algo/discovery/powl/inductive/variants/brute_force/bf_partial_order_cut.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class BruteForcePartialOrderCut(Cut[T], ABC, Generic[T]):
154154

155155
@classmethod
156156
def operator(cls, parameters: Optional[Dict[str, Any]] = None) -> StrictPartialOrder:
157-
return StrictPartialOrder([])
157+
raise Exception("This function should not be called!")
158158

159159
@classmethod
160160
def holds(cls, obj: T, parameters: Optional[Dict[str, Any]] = None) -> Optional[BinaryRelation]:

0 commit comments

Comments
 (0)