Skip to content

Commit 63bb8d2

Browse files
merging branches
2 parents d58d34f + a5a2409 commit 63bb8d2

File tree

19 files changed

+140
-60
lines changed

19 files changed

+140
-60
lines changed

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
# PM4Py Changelog
22

3+
## PM4Py 2.2.13.1
4+
5+
### Fixed
6+
7+
* 816fb4ad
8+
* Fixed a bug in the Pandas case size filter (the constraints were not applied correctly).
9+
* 40f142c4
10+
* Fixed a bug in the format_dataframe function (columns were duplicated if already existing with the same name).
11+
* 00d1a7de
12+
* Reverted stream converter to old variant (in a slightly slower but safer way).
13+
14+
### Removed
15+
16+
### Deprecated
17+
18+
### Changed
19+
* 991a09d4
20+
* Introduce a time limit in the DFG playout.
21+
* ae5d2a07
22+
* Return the state of the process tree along with the alignment for the process tree alignments.
23+
* 8b77384f
24+
* Refactoring of the calculation of the fitness for Petri net alignments (scattered code).
25+
26+
### Added
27+
28+
### Other
29+
* d58d34fd
30+
* Upgraded Dockerfile to Python 3.9
31+
* 50114175
32+
* Resolved issue with the upcoming Python 3.10 release
33+
* 89314905
34+
* Security issue in requirements
35+
336
## PM4Py 2.2.13 (2021.09.03)
437

538
### Fixed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN apt-get -y install libtool flex bison pkg-config g++ libssl-dev automake
1313
RUN apt-get -y install libjemalloc-dev libboost-dev libboost-filesystem-dev libboost-system-dev libboost-regex-dev python3-dev autoconf flex bison cmake
1414
RUN apt-get -y install libxml2-dev libxslt-dev libfreetype6-dev libsuitesparse-dev
1515
RUN pip install -U wheel six pytest
16-
RUN pip install backcall==0.2.0 colorama==0.4.4 cycler==0.10.0 decorator==5.0.9 deprecation==2.1.0 graphviz==0.17 intervaltree==3.1.0 ipython==7.27.0 jedi==0.18.0 jinja2==3.0.1 joblib==1.0.1 jsonpickle==2.0.0 kiwisolver==1.3.2 lxml==4.6.3 MarkupSafe==2.0.1 matplotlib==3.5.0b1 matplotlib-inline==0.1.3 mpmath==1.2.1 networkx==2.6.2 numpy==1.21.2 packaging==21.0 pandas==1.3.2 parso==0.8.2 pickleshare==0.7.5 pillow==8.3.2 prompt-toolkit==3.0.20 pulp==2.1 pydotplus==2.0.2 pygments==2.10.0 pyparsing==3.0.0b3 python-dateutil==2.8.2 pytz==2021.1 pyvis==0.1.9 scikit-learn==1.0rc1 scipy==1.7.1 setuptools==58.0.3 six==1.16.0 sortedcontainers==2.4.0 stringdist==1.0.9 sympy==1.8 threadpoolctl==2.2.0 tqdm==4.62.2 traitlets==5.1.0 wcwidth==0.2.5
16+
RUN pip install backcall==0.2.0 colorama==0.4.4 cycler==0.10.0 decorator==5.1.0 deprecation==2.1.0 graphviz==0.17 intervaltree==3.1.0 ipython==7.27.0 jedi==0.18.0 jinja2==3.0.1 joblib==1.0.1 jsonpickle==2.0.0 kiwisolver==1.3.2 lxml==4.6.3 MarkupSafe==2.0.1 matplotlib==3.5.0b1 matplotlib-inline==0.1.3 mpmath==1.2.1 networkx==2.6.3 numpy==1.21.2 packaging==21.0 pandas==1.3.3 parso==0.8.2 pickleshare==0.7.5 pillow==8.3.2 prompt-toolkit==3.0.20 pulp==2.1 pydotplus==2.0.2 pygments==2.10.0 pyparsing==3.0.0rc1 python-dateutil==2.8.2 pytz==2021.1 pyvis==0.1.9 scikit-learn==1.0rc2 scipy==1.7.1 setuptools==58.0.4 six==1.16.0 sortedcontainers==2.4.0 stringdist==1.0.9 sympy==1.8 threadpoolctl==2.2.0 tqdm==4.62.2 traitlets==5.1.0 wcwidth==0.2.5
1717
RUN pip install cvxopt
1818

1919
COPY . /app

README.THIRD_PARTY.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ libraries are added/removed.
1010
| colorama | https://pypi.org/project/colorama | BSD License (BSD) | 0.4.4 |
1111
| cvxopt | https://pypi.org/project/cvxopt | GNU General Public License v3 (GPLv3) (GNU GPL version 3) | 1.2.6 |
1212
| cycler | https://pypi.org/project/cycler | BSD | 0.10.0 |
13-
| decorator | https://pypi.org/project/decorator | BSD License (new BSD License) | 5.0.9 |
13+
| decorator | https://pypi.org/project/decorator | BSD License (new BSD License) | 5.1.0 |
1414
| deprecation | https://pypi.org/project/deprecation | Apache Software License (Apache 2) | 2.1.0 |
1515
| graphviz | https://pypi.org/project/graphviz | MIT License (MIT) | 0.17 |
1616
| intervaltree | https://pypi.org/project/intervaltree | Apache Software License (Apache License, Version 2.0) | 3.1.0 |
@@ -25,24 +25,24 @@ libraries are added/removed.
2525
| matplotlib | https://pypi.org/project/matplotlib | Python Software Foundation License (PSF) | 3.5.0b1 |
2626
| matplotlib-inline | https://pypi.org/project/matplotlib-inline | BSD 3-Clause | 0.1.3 |
2727
| mpmath | https://pypi.org/project/mpmath | BSD License (BSD) | 1.2.1 |
28-
| networkx | https://pypi.org/project/networkx | BSD License | 2.6.2 |
28+
| networkx | https://pypi.org/project/networkx | BSD License | 2.6.3 |
2929
| numpy | https://pypi.org/project/numpy | BSD License (BSD) | 1.21.2 |
3030
| packaging | https://pypi.org/project/packaging | Apache Software License, BSD License (BSD-2-Clause or Apache-2.0) | 21.0 |
31-
| pandas | https://pypi.org/project/pandas | BSD License (BSD-3-Clause) | 1.3.2 |
31+
| pandas | https://pypi.org/project/pandas | BSD License (BSD-3-Clause) | 1.3.3 |
3232
| parso | https://pypi.org/project/parso | MIT License (MIT) | 0.8.2 |
3333
| pickleshare | https://pypi.org/project/pickleshare | MIT License (MIT) | 0.7.5 |
3434
| pillow | https://pypi.org/project/pillow | Historical Permission Notice and Disclaimer (HPND) (HPND) | 8.3.2 |
3535
| prompt-toolkit | https://pypi.org/project/prompt-toolkit | BSD License | 3.0.20 |
3636
| pulp | https://pypi.org/project/pulp | BSD License | 2.1 |
3737
| pydotplus | https://pypi.org/project/pydotplus | MIT License (UNKNOWN) | 2.0.2 |
3838
| pygments | https://pypi.org/project/pygments | BSD License (BSD License) | 2.10.0 |
39-
| pyparsing | https://pypi.org/project/pyparsing | MIT License (MIT License) | 3.0.0b3 |
39+
| pyparsing | https://pypi.org/project/pyparsing | MIT License (MIT License) | 3.0.0rc1 |
4040
| python-dateutil | https://pypi.org/project/python-dateutil | Apache Software License, BSD License (Dual License) | 2.8.2 |
4141
| pytz | https://pypi.org/project/pytz | MIT License (MIT) | 2021.1 |
4242
| pyvis | https://pypi.org/project/pyvis | BSD | 0.1.9 |
43-
| scikit-learn | https://pypi.org/project/scikit-learn | OSI Approved (new BSD) | 1.0rc1 |
43+
| scikit-learn | https://pypi.org/project/scikit-learn | OSI Approved (new BSD) | 1.0rc2 |
4444
| scipy | https://pypi.org/project/scipy | BSD License (BSD) | 1.7.1 |
45-
| setuptools | https://pypi.org/project/setuptools | MIT License | 58.0.3 |
45+
| setuptools | https://pypi.org/project/setuptools | MIT License | 58.0.4 |
4646
| six | https://pypi.org/project/six | MIT License (MIT) | 1.16.0 |
4747
| sortedcontainers | https://pypi.org/project/sortedcontainers | Apache Software License (Apache 2.0) | 2.4.0 |
4848
| stringdist | https://pypi.org/project/stringdist | MIT License (MIT) | 1.0.9 |

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# The short X.Y version
2727
version = '2.2'
2828
# The full version, including alpha/beta/rc tags
29-
release = '2.2.13'
29+
release = '2.2.13.1'
3030

3131
# -- General configuration ---------------------------------------------------
3232

examples/alignment_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ def execute_script():
3939
else:
4040
model_cost_function[t] = 1
4141

42-
alignments = ali.petri_net.algorithm.apply(log, net, marking, fmarking)
43-
print(alignments)
42+
alignments = []
43+
for trace in log:
44+
alignments.append(align(trace, net, marking, fmarking, model_cost_function, sync_cost_function))
45+
4446
pretty_print_alignments(alignments)
4547

4648

pm4py/algo/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@
1414
You should have received a copy of the GNU General Public License
1515
along with PM4Py. If not, see <https://www.gnu.org/licenses/>.
1616
'''
17-
from pm4py.algo import discovery, conformance, reduction, analysis, evaluation, simulation, comparison, decision_mining, organizational_mining, transformation
17+
from pm4py.algo import discovery, conformance, reduction, analysis, evaluation, simulation, comparison, organizational_mining, transformation
1818

19+
import pkgutil
20+
21+
if pkgutil.find_loader("sklearn"):
22+
from pm4py.algo import decision_mining

pm4py/algo/conformance/alignments/petri_net/algorithm.py

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class Parameters(Enum):
6060
VARIANTS_IDX = "variants_idx"
6161
SHOW_PROGRESS_BAR = "show_progress_bar"
6262
CORES = 'cores'
63+
BEST_WORST_COST_INTERNAL = "best_worst_cost_internal"
64+
FITNESS_ROUND_DIGITS = "fitness_round_digits"
6365

6466

6567
DEFAULT_VARIANT = Variants.VERSION_STATE_EQUATION_A_STAR
@@ -116,9 +118,43 @@ def apply_trace(trace, petri_net, initial_marking, final_marking, parameters=Non
116118
"""
117119
if parameters is None:
118120
parameters = copy({PARAMETER_CONSTANT_ACTIVITY_KEY: DEFAULT_NAME_KEY})
119-
return exec_utils.get_variant(variant).apply(trace, petri_net, initial_marking, final_marking,
121+
122+
parameters = copy(parameters)
123+
best_worst_cost = exec_utils.get_param_value(Parameters.BEST_WORST_COST_INTERNAL, parameters,
124+
__get_best_worst_cost(petri_net, initial_marking, final_marking, variant, parameters))
125+
126+
ali = exec_utils.get_variant(variant).apply(trace, petri_net, initial_marking, final_marking,
120127
parameters=parameters)
121128

129+
trace_cost_function = exec_utils.get_param_value(Parameters.PARAM_TRACE_COST_FUNCTION, parameters, [])
130+
# Instead of using the length of the trace, use the sum of the trace cost function
131+
trace_cost_function_sum = sum(trace_cost_function)
132+
133+
ltrace_bwc = trace_cost_function_sum + best_worst_cost
134+
135+
fitness = 1 - (ali['cost'] // align_utils.STD_MODEL_LOG_MOVE_COST) / (
136+
ltrace_bwc // align_utils.STD_MODEL_LOG_MOVE_COST) if ltrace_bwc > 0 else 0
137+
138+
# other possibility: avoid integer division but proceed to rounding.
139+
# could lead to small differences with respect to the adopted-since-now fitness
140+
# (since it is rounded)
141+
142+
"""
143+
initial_trace_cost_function = exec_utils.get_param_value(Parameters.PARAM_TRACE_COST_FUNCTION, parameters, None)
144+
initial_model_cost_function = exec_utils.get_param_value(Parameters.PARAM_MODEL_COST_FUNCTION, parameters, None)
145+
initial_sync_cost_function = exec_utils.get_param_value(Parameters.PARAM_SYNC_COST_FUNCTION, parameters, None)
146+
uses_standard_cost_function = initial_trace_cost_function is None and initial_model_cost_function is None and \
147+
initial_sync_cost_function is None
148+
149+
fitness = 1 - ali['cost'] / ltrace_bwc if ltrace_bwc > 0 else 0
150+
fitness_round_digits = exec_utils.get_param_value(Parameters.FITNESS_ROUND_DIGITS, parameters, 3)
151+
fitness = round(fitness, fitness_round_digits)
152+
"""
153+
154+
ali["fitness"] = fitness
155+
156+
return ali
157+
122158

123159
def apply_log(log, petri_net, initial_marking, final_marking, parameters=None, variant=DEFAULT_VARIANT):
124160
"""
@@ -161,6 +197,7 @@ def apply_log(log, petri_net, initial_marking, final_marking, parameters=None, v
161197
best_worst_cost = __get_best_worst_cost(petri_net, initial_marking, final_marking, variant, parameters)
162198
variants_idxs, one_tr_per_var = __get_variants_structure(log, parameters)
163199
progress = __get_progress_bar(len(one_tr_per_var), parameters)
200+
parameters[Parameters.BEST_WORST_COST_INTERNAL] = best_worst_cost
164201

165202
all_alignments = []
166203
for trace in one_tr_per_var:
@@ -172,7 +209,6 @@ def apply_log(log, petri_net, initial_marking, final_marking, parameters=None, v
172209
progress.update()
173210

174211
alignments = __form_alignments(log, variants_idxs, all_alignments)
175-
__assign_fitness(log, alignments, best_worst_cost)
176212
__close_progress_bar(progress)
177213

178214
return alignments
@@ -207,6 +243,7 @@ def apply_multiprocessing(log, petri_net, initial_marking, final_marking, parame
207243

208244
best_worst_cost = __get_best_worst_cost(petri_net, initial_marking, final_marking, variant, parameters)
209245
variants_idxs, one_tr_per_var = __get_variants_structure(log, parameters)
246+
parameters[Parameters.BEST_WORST_COST_INTERNAL] = best_worst_cost
210247

211248
all_alignments = []
212249
with ProcessPoolExecutor(max_workers=num_cores) as executor:
@@ -229,7 +266,6 @@ def apply_multiprocessing(log, petri_net, initial_marking, final_marking, parame
229266
__close_progress_bar(progress)
230267

231268
alignments = __form_alignments(log, variants_idxs, all_alignments)
232-
__assign_fitness(log, alignments, best_worst_cost)
233269

234270
return alignments
235271

@@ -281,15 +317,6 @@ def __form_alignments(log, variants_idxs, all_alignments):
281317
return alignments
282318

283319

284-
def __assign_fitness(log, alignments, best_worst_cost):
285-
for index, align in enumerate(alignments):
286-
ltrace_bwc = len(log[index]) + best_worst_cost
287-
if ltrace_bwc > 0:
288-
align['fitness'] = 1 - ((align['cost'] // align_utils.STD_MODEL_LOG_MOVE_COST) / ltrace_bwc)
289-
else:
290-
align['fitness'] = 0
291-
292-
293320
def __close_progress_bar(progress):
294321
if progress is not None:
295322
progress.close()

pm4py/algo/conformance/alignments/petri_net/variants/dijkstra_less_memory.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ def get_best_worst_cost(petri_net, initial_marking, final_marking, parameters=No
9696

9797
best_worst = apply(trace, petri_net, initial_marking, final_marking, parameters=parameters)
9898

99-
if best_worst['cost'] > 0:
100-
return best_worst['cost'] // align_utils.STD_MODEL_LOG_MOVE_COST
101-
return 0
99+
return best_worst['cost']
102100

103101

104102
def apply_from_variants_list_petri_string(var_list, petri_net_string, parameters=None):

pm4py/algo/conformance/alignments/petri_net/variants/dijkstra_no_heuristics.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ def get_best_worst_cost(petri_net, initial_marking, final_marking, parameters=No
7575

7676
best_worst = apply(trace, petri_net, initial_marking, final_marking, parameters=parameters)
7777

78-
if best_worst['cost'] > 0:
79-
return best_worst['cost'] // utils.STD_MODEL_LOG_MOVE_COST
80-
return 0
78+
return best_worst['cost']
8179

8280

8381
def apply(trace: Trace, petri_net: PetriNet, initial_marking: Marking, final_marking: Marking, parameters: Optional[Dict[Union[str, Parameters], Any]] = None) -> typing.AlignmentResult:
@@ -106,7 +104,6 @@ def apply(trace: Trace, petri_net: PetriNet, initial_marking: Marking, final_mar
106104
if parameters is None:
107105
parameters = {}
108106

109-
parameters = copy(parameters)
110107
activity_key = exec_utils.get_param_value(Parameters.ACTIVITY_KEY, parameters, DEFAULT_NAME_KEY)
111108
trace_cost_function = exec_utils.get_param_value(Parameters.PARAM_TRACE_COST_FUNCTION, parameters, None)
112109
model_cost_function = exec_utils.get_param_value(Parameters.PARAM_MODEL_COST_FUNCTION, parameters, None)

pm4py/algo/conformance/alignments/petri_net/variants/state_equation_a_star.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ def get_best_worst_cost(petri_net, initial_marking, final_marking, parameters=No
9999

100100
best_worst = apply(trace, petri_net, initial_marking, final_marking, parameters=parameters)
101101

102-
if best_worst['cost'] > 0:
103-
return best_worst['cost'] // utils.STD_MODEL_LOG_MOVE_COST
104-
return 0
102+
return best_worst['cost']
105103

106104

107105
def apply(trace: Trace, petri_net: PetriNet, initial_marking: Marking, final_marking: Marking, parameters: Optional[Dict[Union[str, Parameters], Any]] = None) -> typing.AlignmentResult:
@@ -130,7 +128,6 @@ def apply(trace: Trace, petri_net: PetriNet, initial_marking: Marking, final_mar
130128
if parameters is None:
131129
parameters = {}
132130

133-
parameters = copy(parameters)
134131
activity_key = exec_utils.get_param_value(Parameters.ACTIVITY_KEY, parameters, DEFAULT_NAME_KEY)
135132
trace_cost_function = exec_utils.get_param_value(Parameters.PARAM_TRACE_COST_FUNCTION, parameters, None)
136133
model_cost_function = exec_utils.get_param_value(Parameters.PARAM_MODEL_COST_FUNCTION, parameters, None)

0 commit comments

Comments
 (0)