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>;
}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.