Skip to main content

SearchAlgorithm

Trait SearchAlgorithm 

Source
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§

Source

fn name(&self) -> &'static str

Algorithm name.

Source

fn initialize( &mut self, population: Vec<Chromosome>, gene_pool: &GenePool, rng: &mut StdRng, )

Initialize the algorithm with a seed population.

Source

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.

Source

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.

Source

fn should_terminate(&self, stats: &SearchStats, budget: &Budget) -> bool

Check whether the algorithm thinks search should stop.

Source

fn best(&self) -> Option<&Chromosome>

Get the best chromosome found so far.

Source

fn checkpoint(&self) -> Result<Vec<u8>, EvolutionError>

Serialize internal state to bytes.

Source

fn restore(&mut self, bytes: &[u8]) -> Result<(), EvolutionError>

Restore internal state from bytes.

Implementors§