Expand description
Host-side local-search refinement for memetic algorithms.
A memetic algorithm (MA) interleaves a population-level evolutionary
strategy with a per-individual local search that polishes promising
genomes between generations. This module defines the local-search seam —
the LocalSearch trait — together with the four reference searchers
(HillClimbing, NelderMead, SimulatedAnnealing,
RandomRestart) that a MemeticWrapper can compose with any existing
Strategy.
§Design seam
Local search here is host-side and gradient-free. Searchers operate on
a flat Vec<f32> genome and a single-member
FitnessFn, never touching device tensors or
computing gradients. This keeps refinement trivially reproducible and
independent of the Burn backend: it is pure host arithmetic plus calls to
the supplied fitness function.
§Stochasticity convention
Every searcher takes a &mut dyn Rng and all randomness flows through
it. Searchers never seed the process-wide backend RNG (B::seed +
Tensor::random) and never reach for rand::rng() / thread-local RNGs —
that would race the global Flex mutex under the parallel test runner and
destroy reproducibility (see crate::rng for the host-RNG convention).
A memetic wrapper derives a dedicated stream via
seed_stream(base, generation, SeedPurpose::LocalSearch) and threads it in
here.
§Evaluation budget
Each refine call is bounded by Params::max_iters total
FitnessFn::evaluate_one calls
(including the mandatory first re-evaluation of the input genome). The
shared BudgetedEval helper enforces this so the bound holds structurally
even on flat landscapes where no probe ever improves.
refine_with_known_fitness skips
that seeding eval when the caller already knows the input’s fitness, so the
same max_iters then buys one extra probe evaluation. The seeding eval
consumes no rng, so skipping it never shifts a searcher’s random stream.
Re-exports§
pub use hill_climbing::HillClimbVariant;pub use hill_climbing::HillClimbing;pub use hill_climbing::HillClimbingParams;pub use nelder_mead::NelderMead;pub use nelder_mead::NelderMeadParams;pub use random_restart::RandomRestart;pub use random_restart::RandomRestartParams;pub use simulated_annealing::CoolingSchedule;pub use simulated_annealing::SimulatedAnnealing;pub use simulated_annealing::SimulatedAnnealingParams;
Modules§
- hill_
climbing - Coordinate-wise hill climbing.
- nelder_
mead - Nelder–Mead downhill simplex.
- random_
restart - Random-restart meta-search.
- simulated_
annealing - Simulated annealing.
Traits§
- Local
Search - A gradient-free, host-side local search over real-valued genomes.