Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions pm4py/algo/discovery/genetic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
'''
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 – A Process Mining Library for Python
Copyright (C) 2026 Process Intelligence Solutions UG (haftungsbeschränkt)
Expand Down
29 changes: 2 additions & 27 deletions pm4py/algo/discovery/genetic/algorithm.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
'''
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 – A Process Mining Library for Python
Copyright (C) 2026 Process Intelligence Solutions UG (haftungsbeschränkt)
Expand All @@ -42,11 +21,12 @@
'''
from enum import Enum
from pm4py.util import exec_utils
from typing import Union, Optional, Dict, Any, Tuple
from pm4py.algo.discovery.genetic.variants import classic
from pm4py.objects.petri_net.obj import PetriNet, Marking
from pm4py.objects.log.obj import EventLog, EventStream
import pandas as pd
from pm4py.util import constants
from typing import Union, Optional, Dict, Any, Tuple


class Parameters(Enum):
Expand All @@ -59,13 +39,8 @@ class Parameters(Enum):
MUTATION_RATE = "mutation_rate"
GENERATIONS = "generations"
ELITISM_MIN_SAMPLE = "elitism_min_sample"
TOURNAMENT_TIMEOUT = "tournament_timeout"
LOG_CSV = "log_csv"


from pm4py.algo.discovery.genetic.variants import classic


class Variants(Enum):
CLASSIC = classic

Expand Down
44 changes: 30 additions & 14 deletions pm4py/algo/discovery/genetic/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'''
PM4Py – A Process Mining Library for Python
Copyright (C) 2024 Process Intelligence Solutions UG (haftungsbeschränkt)
PM4Py A Process Mining Library for Python
Copyright (C) 2026 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
Expand All @@ -25,22 +25,22 @@
import itertools

# typing
from typing import Self, Union
from collections.abc import Iterable
from typing import Dict, FrozenSet, List, Tuple
InputMap = Dict[str, List[FrozenSet]]
OutputMap = Dict[str, List[FrozenSet]]
Individual = Tuple[InputMap, OutputMap]
TransitionMap = dict[str,list[frozenset]]
InputMap = OutputMap = TransitionMap
Individual = tuple[InputMap,OutputMap]

class iset(frozenset):
"Indexable frozenset printing as set, i.e. without `frozenset(…)`"
def __repr__(self):
return "{" + repr(sorted(self))[1:-1] + "}"

@staticmethod
def flat(item: Iterable) -> "iset":
def flat(item: Iterable) -> Self:
return iset(itertools.chain(*item))

def rand_partition(pool: Iterable) -> List[iset]:
def rand_partition(pool: Iterable) -> list[Union[set,frozenset]]:
pool = set(pool)
# also ensures no activity in two partitions
# s. 4. Causal Matrix, Def. 4; https://doi.org/10.1007/11494744_5
Expand All @@ -54,7 +54,23 @@ def rand_partition(pool: Iterable) -> List[iset]:
pool -= draw
return partition

def get_src_sink_sets_for_wfnet(I: InputMap, O: OutputMap, T: List[str]) -> Tuple[List[str], List[str]]:
def add_singleton_partition(tmap: TransitionMap, key: str, t: str):
partitions = tmap.setdefault(key, []) # tmap[key] or []
if not any(t in partition for partition in partitions):
partitions.append(iset({t}))

def remove_transition_from_partitions(tmap: TransitionMap, key: str, t: str):
partitions = tmap.setdefault(key, []) # tmap[key] or []
for i,partition in enumerate(partitions):
if t in partition:
updated = iset(partition - {t})
if updated:
partitions[i] = updated
else:
del partitions[i]
return

def get_src_sink_sets_for_wfnet(I: InputMap, O: OutputMap, T: list[str]) -> tuple[list[str],list[str]]:
"""Determines input set and output set, which need to be connected by a place to create a WF-net"""
def add2graphs(graphs, t, nextT):
# find graph
Expand All @@ -70,8 +86,8 @@ def add2graphs(graphs, t, nextT):
else:
successors.extend(S)
graph += successors
# merge if end = start
for tn in successors:
# merge if path end = start
for tn in successors: # tn = end
for g2 in graphs[:]: # [:] = copy
if g2[0] == tn and g2 != graph:
graph += g2
Expand All @@ -82,6 +98,6 @@ def add2graphs(graphs, t, nextT):
for t in T:
graphsI = add2graphs(graphsI, t, I)
graphsO = add2graphs(graphsO, t, O)
first = [g[0] for g in graphsO] # ⋃first = reachable via O[∀t]
last = [g[0] for g in graphsI] # ⋃first = reachable via I[∀t]
return first, last
sources = [g[0] for g in graphsO] # ⋃sources = ∀t reachable from O[∀sources]
sinks = [g[0] for g in graphsI] # ⋃sinks = ∀t reachable from I[∀sinks]
return sources, sinks
21 changes: 0 additions & 21 deletions pm4py/algo/discovery/genetic/variants/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
'''
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 – A Process Mining Library for Python
Copyright (C) 2026 Process Intelligence Solutions UG (haftungsbeschränkt)
Expand Down
Loading
Loading