forked from SWISDATA/processintel
mining.genetic: replace the GeneticMining class with a pure, seeded function #72
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ffrauenberger/ProcessIntel#72
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: improvement (part of #66; the miner's result depends on the history of its instance and on the global random state)
Requested by: the user (2026-10-09)
Where
app/mining_algorithms/genetic_mining.py:31-60—GeneticMining(BaseMining); the constructor sets eight GA parameters,dependency_matrix,best_individual,start_measures,end_measuresandpetri_netonself.app/mining_algorithms/genetic_mining.py:62-169—generate_graphresets the results onself, writes all parameters toself, then fillsdependency_matrix, the measures andbest_individual.app/mining_algorithms/genetic_mining.py:422,:455,:522—best_individual,self.graphandself.petri_netare set from inside helper methods.app/mining_algorithms/genetic_mining.py:389,:480,:562-572,:613-615,:712-732,:807,:842,:871-883,:943— the module-levelrandomandnp.randomare used directly; there is no seed.app/mining_algorithms/genetic_mining.py:1067-1086— getters for the GA parameters.app/ui/genetic_miner_ui/genetic_miner_controller.py:62-83,:196-201— the controller reads the getters,fitness_thresholdandget_graph()from the instance.Problem
The genetic miner keeps its parameters, its population results and its graph on the instance, and helper methods write
best_individualand the graph as a side effect. It also draws from the global random generators. So two runs with the same input give different graphs, and a test cannot pin the result.Fix
Follow the plan in #66 (
code#write-simple-functional-code):mine_genetic(log, params) -> MiningResult, withparamsholding the GA parameters, the shared filter thresholds and aseed.random.Random(seed)and onenumpy.random.Generatorfrom the seed, and pass them to the selection, crossover, mutation and individual creation functions. Do not use the module-levelrandomornp.random.MiningResultholds the graph, the Petri net, the best individual's fitness and the effective parameters.BaseMining(#66).GeneticMiningdelegate tomine_geneticuntil the controller has moved, then remove it.Related: #17 (measures ignore trace frequencies) and #39 (runtime) touch the same code.
Check
mine_genetictwice with the same log, params and seed and gets equal results.git grep -nE "class GeneticMining|^\s*(import random|random\.|np\.random\.)" app/mining_algorithms/genetic_mining.pyreturns nothing.from a session on 2026-10-09, split from #66