wasm4pm 26.6.12

High-performance process mining algorithms in WebAssembly for JavaScript/TypeScript
Documentation
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
# wasm4pm Algorithms Reference

Complete catalog of all 20+ process discovery and analytics methods.

## Discovery Algorithms (14 Methods)

### Classical Process Discovery

**DFG (Directly-Follows Graph)**

- Type: Graph-based
- Speed: Ultra-fast (< 5ms)
- Use: Quick process overview

```typescript
log.discoverDFG({ minFrequency: 1 });
```

**Alpha++**

- Type: Petri net mining
- Speed: Fast (< 50ms)
- Use: Sound models with noise tolerance

```typescript
log.discoverAlphaPlusPlus({ minSupport: 0.1 });
```

**DECLARE**

- Type: Constraint mining
- Speed: Fast (< 100ms)
- Use: Temporal constraint discovery

```typescript
log.discoverDECLARE();
```

**Heuristic Miner**

- Type: Dependency-based
- Speed: Fast (< 100ms)
- Use: Noisy/incomplete logs

```typescript
log.discoverHeuristicMiner({ dependencyThreshold: 0.5 });
```

**Inductive Miner**

- Type: Recursive structure
- Speed: Fast (< 50ms)
- Use: Well-structured processes

```typescript
log.discoverInductiveMiner();
```

### Optimization & Search-Based

**ILP (Integer Linear Programming)**

- Type: Constraint optimization
- Speed: Medium (100-500ms)
- Use: Optimal Petri nets

```typescript
log.discoverILPPetriNet();
```

**A\* Search**

- Type: Informed search
- Speed: Medium (100-300ms)
- Use: Guided optimal discovery

```typescript
log.discoverAStar({ maxIterations: 1000 });
```

**Hill Climbing**

- Type: Greedy edge pruning (start with all edges, iteratively remove non-essential)
- Speed: Fast (< 150ms @ 10K cases)
- Use: Model simplification, removes redundant edges while preserving trace replay

```typescript
log.discoverHillClimbing();
```

**Noise-Filtered DFG** (Streaming)

- Type: Frequency-based noise filtering
- Speed: Fast (< 150ms @ 10K cases)
- Use: Production streaming, denoising noisy logs, 80/20 solution
- Memory: O(E) — edge counts only, no trace storage

```typescript
const handle = pm.streaming_noise_filtered_dfg_begin();
pm.streaming_noise_filtered_dfg_add_event(handle, 'case-1', 'A');
pm.streaming_noise_filtered_dfg_close_trace(handle, 'case-1');
const dfg = JSON.parse(pm.streaming_noise_filtered_dfg_snapshot(handle));
```

### Metaheuristic Algorithms

**Genetic Algorithm**

- Type: Population evolution
- Speed: Medium (200-500ms)
- Use: Diverse solution exploration

```typescript
log.discoverGeneticAlgorithm({ populationSize: 50, generations: 20 });
```

**Particle Swarm Optimization**

- Type: Swarm intelligence
- Speed: Medium (200-500ms)
- Use: Continuous optimization

```typescript
log.discoverPSOAlgorithm({ swarmSize: 30, iterations: 50 });
```

**Ant Colony Optimization**

- Type: Pheromone-based
- Speed: Medium (100-300ms)
- Use: Distributed path discovery

```typescript
log.discoverAntColony({ numAnts: 20, iterations: 10 });
```

**Simulated Annealing**

- Type: Thermal search
- Speed: Medium (100-300ms)
- Use: Escape local optima

```typescript
log.discoverSimulatedAnnealing({ temperature: 100, coolingRate: 0.95 });
```

### Model Filtering

**Process Skeleton**

- Type: Frequency-based filtering
- Speed: Ultra-fast (< 5ms)
- Use: Minimal model extraction

```typescript
log.extractProcessSkeleton({ minFrequency: 2 });
```

**Optimized DFG**

- Type: Weighted optimization
- Speed: Fast (< 50ms)
- Use: Balance fitness vs simplicity

```typescript
log.discoverOptimizedDFG({ fitnessWeight: 0.7, simplicityWeight: 0.3 });
```

---

## Analytics Functions (20+ Methods)

### Process Variants & Patterns

**Trace Variants**

- Extract unique process paths
- Rank by frequency
- Coverage analysis

```typescript
log.getTraceVariants();
// Returns: total_variants, top_variants, coverage
```

**Variant Complexity**

- Shannon entropy calculation
- Normalized diversity metric
- Top-10 path coverage

```typescript
log.getVariantComplexity();
// Returns: entropy, normalized_entropy, top_10_coverage
```

**Sequential Pattern Mining**

- Find frequent activity sequences
- Configurable pattern length
- Minimum support filtering

```typescript
log.mineSequentialPatterns({ minSupport: 0.01, patternLength: 3 });
// Returns: top patterns with support
```

**Activity Cooccurrence**

- Activities happening together
- Pairwise association
- Strength ranking

```typescript
log.getActivityCooccurrence();
// Returns: top cooccurrence pairs
```

### Temporal & Performance

**Process Speedup Analysis**

- Identify acceleration patterns
- Percentile-based speedup ranges
- Performance variance

```typescript
log.analyzeProcessSpeedup({ windowSize: 50 });
// Returns: avg_gap, p25, p75, speedup_range
```

**Temporal Bottlenecks**

- Identify slow activities
- Duration-based analysis
- Timestamp correlation

```typescript
log.getTemporalBottlenecks();
// Returns: bottleneck activities with durations
```

**Concept Drift Detection**

- Identify process changes
- Jaccard-based distance
- Time-windowed analysis

```typescript
log.detectConceptDrift({ windowSize: 50 });
// Returns: drift positions and magnitudes
```

### Relationships & Dependencies

**Activity Start/End Analysis**

- Entry point activities
- Exit point activities
- Common start-end patterns

```typescript
log.getStartEndActivities();
// Returns: top starts, ends, pairs
```

**Activity Dependencies**

- Predecessor relationships
- Successor relationships
- Dependency counts

```typescript
log.getActivityDependencies();
// Returns: predecessors and successors per activity
```

**Activity Ordering**

- Mandatory predecessor extraction
- Partial order discovery
- Sequence constraints

```typescript
log.getActivityOrdering();
// Returns: mandatory predecessors per activity
```

**Transition Matrix**

- Markov chain probabilities
- Activity flow probabilities
- Transition counts

```typescript
log.getTransitionMatrix();
// Returns: from, to, count, probability
```

### Clustering & Similarity

**Trace Clustering**

- Group similar traces
- K-means-style clustering
- Variant extraction

```typescript
log.clusterTraces({ numClusters: 5 });
// Returns: cluster sizes and composition
```

**Trace Similarity Matrix**

- Pairwise Jaccard similarity
- High-similarity pair ranking
- Distance computation

```typescript
log.getTraceSimilarityMatrix();
// Returns: similar trace pairs
```

### Quality & Deviation Analysis

**Rework Detection**

- Repeated activities in same trace
- Rework percentage
- Rework by activity

```typescript
log.detectRework();
// Returns: traces_with_rework, rework_by_activity
```

**Infrequent Paths**

- Rare process variants
- Outlier identification
- Anomaly ranking

```typescript
log.analyzeInfrequentPaths({ frequencyThreshold: 0.05 });
// Returns: infrequent paths sorted by rarity
```

**Bottleneck Detection**

- High-duration activities
- Long waiting times
- Performance hotspots

```typescript
log.detectBottlenecks();
// Returns: bottleneck activities, occurrences, avg/max duration
```

### Case-Level Analysis

**Case Attributes Analysis**

- Attribute value distribution
- Attribute-process correlation
- Categorical mapping

```typescript
log.getCaseAttributeAnalysis();
// Returns: case attributes and unique values
```

### Conformance & Fitness

**Token-Based Replay**

- Case-by-case fitness
- Deviation tracking
- Missing/remaining tokens

```typescript
log.checkConformance(petriNet);
// Returns: case_fitness, avg_fitness, conforming_cases
```

---

## Streaming DFG Builder

An IoT-oriented API that constructs a DFG incrementally without ever holding
the full event log in memory.

- Memory: O(open_traces × avg_trace_length) for buffers + O(A²) for count tables
- Events arrive in any order across interleaved cases
- `close_trace` frees the per-case buffer; counts are in compact tables

```javascript
const handle = pm.streaming_dfg_begin();

// Add events one-by-one or in batches
pm.streaming_dfg_add_event(handle, 'case-1', 'Register');
pm.streaming_dfg_add_batch(
  handle,
  JSON.stringify([
    { case_id: 'case-1', activity: 'Approve' },
    { case_id: 'case-2', activity: 'Register' },
  ])
);

// Close traces as cases complete (frees per-trace buffer)
pm.streaming_dfg_close_trace(handle, 'case-1');

// Live snapshot
const dfg = JSON.parse(pm.streaming_dfg_snapshot(handle));

// Finalize: flush + store DFG + free builder
const result = JSON.parse(pm.streaming_dfg_finalize(handle));
// result.dfg_handle → use with conformance checking, etc.
```

---

## Algorithm Comparison Matrix

| Algorithm | Type  | Speed  | Best For      | Noise | Optimality |
| --------- | ----- | ------ | ------------- | ----- | ---------- |
| DFG       | Graph | ⚡⚡⚡ | Overview      | Low   | N/A        |
| Alpha++   | Petri | ⚡⚡   | Sound         | Med   | Good       |
| Heuristic | Graph | ⚡⚡   | Noisy         | High  | Fair       |
| Inductive | Petri | ⚡⚡   | Structure     | Med   | Good       |
| ILP       | Petri || Optimal       | Low   | Excellent  |
| A\*       | Graph | ⚡⚡   | Guided        | Low   | Good       |
| Genetic   | Graph || Diverse       | High  | Fair       |
| PSO       | Graph || Continuous    | Med   | Fair       |
| ACO       | Graph || Distributed   | Med   | Fair       |
| SA        | Graph || Escape optima | High  | Fair       |

---

## Performance Benchmarks

**Real Measured Results** — Criterion benchmarks (2026-04-08) on Event Log with 10000 cases, 200000 events, 20 activities:

```
FAST ALGORITHMS (< 50ms):
  DFG:                      ~3.0 ms
  Process Skeleton:         ~2.7 ms
  Optimized DFG:            ~7.8 ms
  Heuristic Miner:          ~14 ms
  Inductive Miner:          ~25 ms
  Genetic Algorithm:        ~24 ms
  ACO:                      ~21 ms
  Simulated Annealing:      ~23 ms
  PSO Algorithm:            ~25 ms

MEDIUM ALGORITHMS (50-200ms):
  Hill Climbing:            ~135 ms (greedy edge pruning)
  Noise-Filtered DFG:       ~135 ms (streaming, frequency-based)
  A* Search:                ~77 ms
  ILP Petri Net:            ~87 ms

STREAMING (10K cases, ~20x slower than batch):
  Streaming DFG:             ~69 ms
  Streaming Alpha++:         ~155 ms
  Streaming Hill Climbing:   ~187 ms
  Streaming Noise-Filtered:  ~135 ms
  Streaming Inductive:       ~135 ms
  Streaming A*:              ~155 ms

ANALYTICS:
  All functions < 10ms (detection, bottlenecks, variants, complexity, etc.)
```

**Summary**: All algorithms scale linearly with event count. Streaming trades 1.4-23x speed for bounded memory and infinite stream support. See [Benchmark Results](../../docs/PROJECT_STATUS.md#benchmark-results-2026-04-08) for comprehensive 4-size dataset analysis.

---

## Selection Guide

### For Speed

1. Process Skeleton
2. Hill Climbing
3. DFG
4. Heuristic Miner

### For Accuracy

1. ILP
2. Alpha++
3. Inductive Miner
4. A\* Search

### For Flexibility

1. Genetic Algorithm
2. PSO
3. Ant Colony
4. Simulated Annealing

### For Noisy Logs

1. Heuristic Miner
2. Genetic Algorithm
3. Ant Colony
4. Simulated Annealing

### For Analysis

1. Trace Variants
2. Activity Dependencies
3. Concept Drift
4. Similarity Matrix

---

**Version**: 26.4.9
**Total Methods**: 20+ discovery/analytics + 8 streaming
**Lines of Code**: 2500+
**Status**: Production Ready