Route combinatorial ACO/GA parallel dispatch through GenerationRunner - #125
Merged
Merged
Conversation
combinatorial/{aco,aco_mst,ga}.py each hand-rolled their own
spawn_streams/use_stream/joblib.delayed dispatch, duplicating what
continuous solvers already factored into core/parallel.GenerationRunner
(the copy-fixed-data-once path from the perf work, report item #2) --
they just never adopted it.
Each solver now builds a `fixed` tuple of its run-constant data
(distance matrix, desirability/config, individuals_per_job) and calls
GenerationRunner.run() with only the per-generation varying argument
(tau_alpha for the two ACO variants, the genome + its values for GA),
instead of re-pickling everything to workers every generation under a
manual joblib.delayed loop. Each per-individual worker function
(run_ant/run_ant_mst/run_ga) is wrapped in a new module-level
_run_*_batch helper so it stays picklable for the "processes" backend.
Purely a dispatch-mechanism change -- the per-individual logic
(run_ant/run_ant_mst/run_ga) is untouched, and GenerationRunner
provides the same per-task RNG-stream isolation the old inline
spawn_streams/use_stream did.
Verified: a 9-test determinism sweep across all three solvers
(aco-tsp, aco-mst, ga-tsp) at n_jobs in {1, 3} -- same seed reproduces
identically, different seeds diverge -- plus a manual smoke test
confirming the "processes" backend still pickles cleanly for all
three. flake8/mypy/black clean; full suite passing (185 tests).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011r9W1JZRSoayjyLin4ZBPZ
fundthmcalculus
force-pushed
the
refactor/combinatorial-generation-runner
branch
from
August 24, 2026 17:06
df63a0d to
ab659d2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
combinatorial/{aco,aco_mst,ga}.pyeach hand-rolled their ownspawn_streams/use_stream/joblib.delayeddispatch, duplicating what the continuous solvers already factored intocore/parallel.GenerationRunner(the copy-fixed-data-once path from the perf work) — they just never adopted it.fixedtuple of its run-constant data (distance matrix, desirability/config,individuals_per_job) and callsGenerationRunner.run()with only the per-generation varying argument (tau_alphafor the two ACO variants, the genome + its values for GA) instead of re-pickling everything to workers every generation.run_ant/run_ant_mst/run_ga) is wrapped in a new module-level_run_*_batchhelper so it stays picklable for the"processes"backend.GenerationRunnerprovides the same per-task RNG-stream isolation the old inlinespawn_streams/use_streamdid.Test plan
n_jobsin{1, 3}intests/test_determinism.py— same seed reproduces identically, different seeds diverge"processes"backend still pickles cleanly for all three solversflake8 ./src ./tests— cleanMYPYPATH=src mypy -p optimizers— cleanblack --check .— clean🤖 Generated with Claude Code
https://claude.ai/code/session_011r9W1JZRSoayjyLin4ZBPZ