pub trait SearchAlgorithm:
Send
+ Sync
+ Debug {
// Required methods
fn name(&self) -> &'static str;
fn initialize(
&mut self,
population: Vec<Chromosome>,
gene_pool: &GenePool,
rng: &mut StdRng,
);
fn request_evaluations(
&mut self,
n: usize,
rng: &mut StdRng,
) -> Vec<EvalCandidate>;
fn submit_evaluations(&mut self, results: Vec<(u64, OracleVerdict)>);
fn should_terminate(&self, stats: &SearchStats, budget: &Budget) -> bool;
fn best(&self) -> Option<&Chromosome>;
fn checkpoint(&self) -> Result<Vec<u8>, EvolutionError>;
fn restore(&mut self, bytes: &[u8]) -> Result<(), EvolutionError>;
fn clone_box(&self) -> Box<dyn SearchAlgorithm>;
// Provided method
fn population_snapshot(&self) -> Vec<Chromosome> { ... }
}Expand description
Core trait implemented by all search algorithms.
Each algorithm manages its own internal state (population, archive,
temperature, tabu list, etc.). The EvolutionEngine
handles caching, budgeting, and batching on top of this trait.
Required Methods§
Sourcefn initialize(
&mut self,
population: Vec<Chromosome>,
gene_pool: &GenePool,
rng: &mut StdRng,
)
fn initialize( &mut self, population: Vec<Chromosome>, gene_pool: &GenePool, rng: &mut StdRng, )
Initialize the algorithm with a seed population.
Sourcefn request_evaluations(
&mut self,
n: usize,
rng: &mut StdRng,
) -> Vec<EvalCandidate>
fn request_evaluations( &mut self, n: usize, rng: &mut StdRng, ) -> Vec<EvalCandidate>
Request up to n candidates for parallel evaluation.
Returns candidates with stable IDs. The caller evaluates them and
later calls submit_evaluations.
Sourcefn submit_evaluations(&mut self, results: Vec<(u64, OracleVerdict)>)
fn submit_evaluations(&mut self, results: Vec<(u64, OracleVerdict)>)
Submit evaluation results.
The ID in each tuple must match an ID previously returned by
request_evaluations.
Sourcefn should_terminate(&self, stats: &SearchStats, budget: &Budget) -> bool
fn should_terminate(&self, stats: &SearchStats, budget: &Budget) -> bool
Check whether the algorithm thinks search should stop.
Sourcefn best(&self) -> Option<&Chromosome>
fn best(&self) -> Option<&Chromosome>
Get the best chromosome found so far.
Sourcefn checkpoint(&self) -> Result<Vec<u8>, EvolutionError>
fn checkpoint(&self) -> Result<Vec<u8>, EvolutionError>
Serialize internal state to bytes.
Sourcefn restore(&mut self, bytes: &[u8]) -> Result<(), EvolutionError>
fn restore(&mut self, bytes: &[u8]) -> Result<(), EvolutionError>
Restore internal state from bytes.
Sourcefn clone_box(&self) -> Box<dyn SearchAlgorithm>
fn clone_box(&self) -> Box<dyn SearchAlgorithm>
Deep-clone this algorithm into a fresh trait object.
Audit (2026-05-10): pre-fix the trait had a default impl that
panicked with “must override”. That panic was reachable from
any out-of-tree algorithm that forgot to override; calling
clone_box from the proxy path then aborted the whole evade
pipeline. The fix removes the default — the compiler now
enforces the override at build time instead.
Provided Methods§
Sourcefn population_snapshot(&self) -> Vec<Chromosome>
fn population_snapshot(&self) -> Vec<Chromosome>
Snapshot the algorithm’s current “live” chromosomes — the set the engine is actively searching from.
Population-based algorithms (NoveltySearch, MapElites)
return their full pool. Single-state algorithms (HillClimbing,
SimulatedAnnealing, TabuSearch) return the singleton
current/best so the engine sees len() == 1 and reports
“no pairwise diversity yet” rather than zero.
Used by EvolutionEngine::diversity_score
to drive adaptive mutation pressure. Cloning is acceptable here
because callers run it at engine-tick rate, not per-evaluation.