mining.heuristic: replace the HeuristicMining class with a pure function #68

Open
opened 2026-10-09 12:21:54 +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/heuristic_mining.py:8-18 — HeuristicMining(BaseMining); the constructor sets dependency_matrix, dependency_threshold and min_edge_thickness on self.
  • app/mining_algorithms/heuristic_mining.py:20-74 — generate_graph writes all thresholds and dependency_matrix to self, then sets self.graph, self.start_nodes and self.end_nodes.
  • app/mining_algorithms/heuristic_mining.py:76-77 — get_threshold reads the threshold back.
  • app/mining_algorithms/heuristic_mining.py:79-127 — the dependency matrix and graph helpers read self.
  • app/ui/heuristic_miner_ui/heuristic_miner_controller.py:59-68, :87-102, :115-116 — the controller reads get_threshold, the edge threshold getters and edge_absolute_counts from the instance.

Problem

generate_graph keeps its input and its result on the instance. The controller then asks the instance for the thresholds it used and compares them with the UI to decide whether to mine again. So the result and the "changed" check depend on what the instance did before.

Fix

Follow the plan in #66 (code#write-simple-functional-code):

  • mine_heuristic(log, params) -> MiningResult, with params holding the SPM, node and edge frequency and dependency thresholds.
  • MiningResult holds the graph, the start and end nodes, and the effective thresholds the controller now reads through getters (including the maximum edge count it takes from edge_absolute_counts).
  • The dependency matrix and dependency graph helpers become module functions that take the matrix and return values.
  • Use the pure helpers for the shared steps of BaseMining (#66).
  • Let HeuristicMining delegate to mine_heuristic until the controller has moved, then remove it.

Check

  • A unit test calls mine_heuristic 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 HeuristicMining" 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/heuristic_mining.py:8-18` — `HeuristicMining(BaseMining)`; the constructor sets `dependency_matrix`, `dependency_threshold` and `min_edge_thickness` on `self`. - `app/mining_algorithms/heuristic_mining.py:20-74` — `generate_graph` writes all thresholds and `dependency_matrix` to `self`, then sets `self.graph`, `self.start_nodes` and `self.end_nodes`. - `app/mining_algorithms/heuristic_mining.py:76-77` — `get_threshold` reads the threshold back. - `app/mining_algorithms/heuristic_mining.py:79-127` — the dependency matrix and graph helpers read `self`. - `app/ui/heuristic_miner_ui/heuristic_miner_controller.py:59-68`, `:87-102`, `:115-116` — the controller reads `get_threshold`, the edge threshold getters and `edge_absolute_counts` from the instance. ## Problem `generate_graph` keeps its input and its result on the instance. The controller then asks the instance for the thresholds it used and compares them with the UI to decide whether to mine again. So the result and the "changed" check depend on what the instance did before. ## Fix Follow the plan in #66 (`code#write-simple-functional-code`): - `mine_heuristic(log, params) -> MiningResult`, with `params` holding the SPM, node and edge frequency and dependency thresholds. - `MiningResult` holds the graph, the start and end nodes, and the effective thresholds the controller now reads through getters (including the maximum edge count it takes from `edge_absolute_counts`). - The dependency matrix and dependency graph helpers become module functions that take the matrix and return values. - Use the pure helpers for the shared steps of `BaseMining` (#66). - Let `HeuristicMining` delegate to `mine_heuristic` until the controller has moved, then remove it. ## Check - A unit test calls `mine_heuristic` 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 HeuristicMining" 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#68
No description provided.