-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.py
More file actions
69 lines (51 loc) · 2.24 KB
/
debug.py
File metadata and controls
69 lines (51 loc) · 2.24 KB
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
68
69
"""Step-by-step Split Miner runs against the paper's running example."""
from __future__ import annotations
from collections import Counter
from bpmn_export import save_bpmn_png, save_bpmn_xml, to_bpmn
from bpmn_init import build_initial_bpmn
from concurrency import discover_concurrency
from dfg_builder import build_dfg, discover_loops, preprocess_traces, strip_self_loops
from filtering import filter_pdfg
from joins import discover_joins
from log_loader import PAPER_EXAMPLE_LOG
from or_minimize import minimize_or_joins
from splits import discover_splits
def _summarise(wg) -> str:
kinds = Counter(n.kind for n in wg.nodes.values())
return (
f"nodes={len(wg.nodes)} ({dict(kinds)}), "
f"edges={len(wg.edges())}"
)
def step_through_paper_example() -> None:
print("== Paper running example (10 distinct traces, ×10 each) ==")
print(f"raw traces: {len(PAPER_EXAMPLE_LOG)}")
preprocessed = preprocess_traces(PAPER_EXAMPLE_LOG)
dfg, labels = build_dfg(preprocessed)
print(f"DFG: {len(dfg)} arcs, {len(labels)} labels")
loops = discover_loops(dfg, preprocessed)
print(f"self-loops: {sorted(loops.self_loops)}")
print(f"short-loops: {[sorted(p) for p in loops.short_loops]}")
dfg_no_self = strip_self_loops(dfg)
conc = discover_concurrency(dfg_no_self, loops, eps=0.2)
print(f"concurrent pairs (eps=0.2): {[sorted(p) for p in conc.concurrent_pairs]}")
print(f"PDFG: {len(conc.pdfg)} arcs")
filt = filter_pdfg(conc.pdfg, eta=0)
print(f"filtered PDFG: {len(filt.edges)} arcs "
f"(source={filt.source}, sink={filt.sink})")
wg = build_initial_bpmn(filt, conc.concurrent_pairs, loops.self_loops)
print(f"after init : {_summarise(wg)}")
discover_splits(wg)
print(f"after splits : {_summarise(wg)}")
discover_joins(wg)
print(f"after joins : {_summarise(wg)}")
minimize_or_joins(wg)
print(f"after OR-min : {_summarise(wg)}")
bpmn = to_bpmn(wg)
save_bpmn_xml(bpmn, "paper_example.bpmn")
try:
save_bpmn_png(bpmn, "paper_example.png")
print("wrote paper_example.bpmn + paper_example.png")
except Exception as exc:
print(f"PNG export skipped: {exc}")
if __name__ == "__main__":
step_through_paper_example()