Skip to content

Phase 3: structure hooks (crossWith, repair, guided moves) - #34

Merged
barrybecker4 merged 4 commits into
masterfrom
claude/phase3-hooks
Oct 24, 2026
Merged

barrybecker4 merged 4 commits into
masterfrom
claude/phase3-hooks

Conversation

@barrybecker4

Copy link
Copy Markdown
Member

Phase 3: structure hooks

Three additive hooks that let a problem use what it knows about its own structure. Each defaults to today's behavior, so a problem that overrides nothing runs as before (seeded runs included).

  • ParameterArray.crossWith(other, rnd) replaces the closed crossover match. The default calls the old crossover.
  • Optimizee.repair(candidate): genetic search repairs crossover children, mutants (built or found by a move) and the initial population. Return the same instance when there is nothing to fix. If a move-found mutant is repaired into a different array, it is scored again in full.
  • Optimizee.proposeGuidedMove + guidedMoveProbability (default 0) on SimulatedAnnealingConfig and GeneticSearchConfig. MoveChoice.propose falls back to a random move when the problem has no suggestion, and draws no random number at probability 0.

The budget, benchmark and delta-check wrappers forward both new methods without counting them as evaluations.

Does guiding help?

On the tour benchmark with a long-leg guide (median of 7 seeds, lower is better), at p = 0.5: annealing/200 cities 26.5 → 24.3, genetic/200 35.4 → 32.5, genetic/100 12.5 → 12.1; annealing/100 shows no gain (13.6 vs 12.9, within noise). So modest and problem dependent. Details and the "not done" list are in docs/improvement-plan.md.

Not done

Iterated local search, hill climbing and VNS do not use guided moves or repair yet. They would follow the useMoves plumbing from #33 and make most sense once the Red puzzle needs them (Phase 4).

Testing

530 tests pass; the 6 failures are the same known ones as on master. New suites: CrossWithSuite, CrossoverHookSuite, OptimizeeHooksSuite, RepairHookSuite, GuidedMovesSuite.

This branches from master, so it may need a small merge with #33 in the config files.


Generated by Claude Code

The default is ParameterCrossover.cross, so behavior is unchanged. Genetic search crosses parents with the
first parent's crossWith.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175jMLxrP7wZ3vfj6UfeDZx
…irs every candidate

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175jMLxrP7wZ3vfj6UfeDZx
@barrybecker4
barrybecker4 merged commit 51faa67 into master Oct 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants