Skip to content

Conversation

athikha
Copy link

@athikha athikha commented Oct 17, 2025

  1. Implemented an optional local-search hook for the Simulated Annealing implementation to allow a small, greedy/hill-climb refinement of candidate solutions before the SA acceptance step.
  2. File changed: simulated_annealing.py
  3. Added new init args: local_search: Optional[...] and local_search_iters: int.
  • Implemented [simple_local_search] — a tiny deterministic hill-climb helper (module-level, with doctest).
  • Integrated the local-search call inside [SimulatedAnnealing.optimize] so a candidate can be refined (and its cost returned) before apply the SA acceptance probability.
  • Added [_doctest_local_search_benefit] doctest which runs SA with and without a deterministic local search and asserts the local-search-enabled run is at least as good (cost2 <= cost1). The doctest is deterministic (seeded) and passes locally.
  • No other files were changed.

Why this change

  • Allows combining a fast local search with global SA exploration, which can improve solution quality while keeping the SA control flow intact.
  • The change is backwards-compatible: if [local_search] -- is None, behavior is unchanged.

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests are failing Do not merge until tests pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant