mining.alpha: replace the AlphaMining class with a pure function #67

Open
opened 2026-10-09 12:21:52 +00:00 by ffrauenberger · 0 comments
Owner

Severity: improvement (part of #66; the miner's result depends on the history of its instance)
Requested by: the user (2026-10-09)

Where

  • app/mining_algorithms/alpha_mining.py:9-17 — AlphaMining(BaseMining); the constructor builds the Petri net toolkit and converter and calls _calculate_filtered_model_state.
  • app/mining_algorithms/alpha_mining.py:98-145 — generate_graph writes the thresholds to self, calls recalculate_model_filters, then sets self.graph and self.petri_net, and adds to self.start_nodes and self.end_nodes in place.
  • app/mining_algorithms/alpha_mining.py:298-309 — _calculate_filtered_model_state stores direct_succession_set, causality_set, parallel_set, choice_set, xl_set, yl_set and footprint on self.
  • app/ui/alpha_miner_ui/alpha_miner_controller.py:26-27, :47, :68 — the controller builds the class, compares parameters with the instance and calls generate_graph.

Problem

The Alpha steps (succession, causality, parallel, choice, X_L, Y_L) are already almost pure static functions. But their results go through self, and generate_graph adds the extra start and end nodes from the converter to self.start_nodes and self.end_nodes. These sets come from BaseMining, so the next run starts from the grown sets.

Fix

Follow the plan in #66 (code#write-simple-functional-code, code#classes-only-where-they-pay-off):

  • mine_alpha(log, params) -> MiningResult, with params holding spm_threshold and the node frequency thresholds.
  • Make the Alpha steps module functions that take sets and return sets. Return the footprint as part of the result, where a caller needs it.
  • Build new start and end sets from the converter's extra nodes; do not change the input sets.
  • Use the pure helpers for the shared steps of BaseMining (#66).
  • Let AlphaMining delegate to mine_alpha until the controller has moved, then remove it.

Check

  • A unit test calls mine_alpha twice with the same log and params and gets equal results.
  • A test runs it with other params first, then with the first params again, and gets the same result as on a fresh call.
  • git grep -n "class AlphaMining" app returns nothing.

from a session on 2026-10-09, split from #66

**Severity:** improvement (part of #66; the miner's result depends on the history of its instance) **Requested by:** the user (2026-10-09) ## Where - `app/mining_algorithms/alpha_mining.py:9-17` — `AlphaMining(BaseMining)`; the constructor builds the Petri net toolkit and converter and calls `_calculate_filtered_model_state`. - `app/mining_algorithms/alpha_mining.py:98-145` — `generate_graph` writes the thresholds to `self`, calls `recalculate_model_filters`, then sets `self.graph` and `self.petri_net`, and adds to `self.start_nodes` and `self.end_nodes` in place. - `app/mining_algorithms/alpha_mining.py:298-309` — `_calculate_filtered_model_state` stores `direct_succession_set`, `causality_set`, `parallel_set`, `choice_set`, `xl_set`, `yl_set` and `footprint` on `self`. - `app/ui/alpha_miner_ui/alpha_miner_controller.py:26-27`, `:47`, `:68` — the controller builds the class, compares parameters with the instance and calls `generate_graph`. ## Problem The Alpha steps (succession, causality, parallel, choice, X_L, Y_L) are already almost pure static functions. But their results go through `self`, and `generate_graph` adds the extra start and end nodes from the converter to `self.start_nodes` and `self.end_nodes`. These sets come from `BaseMining`, so the next run starts from the grown sets. ## Fix Follow the plan in #66 (`code#write-simple-functional-code`, `code#classes-only-where-they-pay-off`): - `mine_alpha(log, params) -> MiningResult`, with `params` holding `spm_threshold` and the node frequency thresholds. - Make the Alpha steps module functions that take sets and return sets. Return the footprint as part of the result, where a caller needs it. - Build new start and end sets from the converter's extra nodes; do not change the input sets. - Use the pure helpers for the shared steps of `BaseMining` (#66). - Let `AlphaMining` delegate to `mine_alpha` until the controller has moved, then remove it. ## Check - A unit test calls `mine_alpha` twice with the same log and params and gets equal results. - A test runs it with other params first, then with the first params again, and gets the same result as on a fresh call. - `git grep -n "class AlphaMining" app` returns nothing. --- from a session on 2026-10-09, split from #66
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ffrauenberger/ProcessIntel#67
No description provided.