Spaces:
Running
Running
File size: 3,007 Bytes
e60e568 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
'''
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 typing import Optional, Tuple, List, Dict, Any
from pm4py.algo.discovery.inductive.dtypes.im_ds import IMDataStructureUVCL, IMDataStructureDFG
from pm4py.algo.discovery.inductive.fall_through.abc import FallThrough
from pm4py.algo.discovery.inductive.fall_through.empty_traces import EmptyTracesUVCL
from pm4py.objects.process_tree.obj import ProcessTree, Operator
from pm4py.util.compression import util as comut
from pm4py.util.compression.dtypes import UVCL
from pm4py.objects.dfg.obj import DFG
from pm4py.algo.discovery.inductive.dtypes.im_dfg import InductiveDFG
class FlowerModelUVCL(FallThrough[IMDataStructureUVCL]):
@classmethod
def holds(cls, obj: IMDataStructureUVCL, parameters: Optional[Dict[str, Any]] = None) -> bool:
return not EmptyTracesUVCL.holds(obj, parameters)
@classmethod
def apply(cls, obj: IMDataStructureUVCL, pool=None, manager=None, parameters: Optional[Dict[str, Any]] = None) -> Optional[
Tuple[ProcessTree, List[IMDataStructureUVCL]]]:
log = obj.data_structure
uvcl_do = UVCL()
for a in sorted(list(comut.get_alphabet(log))):
uvcl_do[(a,)] = 1
uvcl_redo = UVCL()
im_uvcl_do = IMDataStructureUVCL(uvcl_do)
im_uvcl_redo = IMDataStructureUVCL(uvcl_redo)
return ProcessTree(operator=Operator.LOOP), [im_uvcl_do, im_uvcl_redo]
class FlowerModelDFG(FallThrough[IMDataStructureDFG]):
@classmethod
def holds(cls, obj: IMDataStructureDFG, parameters: Optional[Dict[str, Any]] = None) -> bool:
return True
@classmethod
def apply(cls, obj: IMDataStructureDFG, pool=None, manager=None, parameters: Optional[Dict[str, Any]] = None) -> Optional[
Tuple[ProcessTree, List[IMDataStructureDFG]]]:
activities = set(obj.dfg.start_activities).union(set(obj.dfg.end_activities)).union(set(x[0] for x in obj.dfg.graph)).union(set(x[1] for x in obj.dfg.graph))
dfg_do = DFG()
for a in activities:
dfg_do.start_activities[a] = 1
dfg_do.end_activities[a] = 1
dfg_redo = DFG()
im_dfg_do = IMDataStructureDFG(InductiveDFG(dfg_do))
im_dfg_redo = IMDataStructureDFG(InductiveDFG(dfg_redo))
return ProcessTree(operator=Operator.LOOP), [im_dfg_do, im_dfg_redo]
|