pub struct CuckooSearch<B: Backend> { /* private fields */ }Expand description
Cuckoo Search strategy.
§Example
use burn::backend::Flex;
use rlevo_evolution::algorithms::metaheuristic::cuckoo::{CuckooConfig, CuckooSearch};
let strategy = CuckooSearch::<Flex>::new();
let params = CuckooConfig::default_for(30, 10);
let _ = (strategy, params);Implementations§
Trait Implementations§
Source§impl<B: Clone + Backend> Clone for CuckooSearch<B>
impl<B: Clone + Backend> Clone for CuckooSearch<B>
Source§fn clone(&self) -> CuckooSearch<B>
fn clone(&self) -> CuckooSearch<B>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<B: Copy + Backend> Copy for CuckooSearch<B>
Source§impl<B: Default + Backend> Default for CuckooSearch<B>
impl<B: Default + Backend> Default for CuckooSearch<B>
Source§fn default() -> CuckooSearch<B>
fn default() -> CuckooSearch<B>
Source§impl<B: Backend> Strategy<B> for CuckooSearch<B>
impl<B: Backend> Strategy<B> for CuckooSearch<B>
Source§fn init(
&self,
params: &CuckooConfig,
rng: &mut dyn Rng,
device: &<B as BackendTypes>::Device,
) -> CuckooState<B>
fn init( &self, params: &CuckooConfig, rng: &mut dyn Rng, device: &<B as BackendTypes>::Device, ) -> CuckooState<B>
Build the initial nest population by host-sampling pop_size
positions uniformly in [bounds.lo, bounds.hi].
The fitness field is left empty so the first ask → tell
pair bootstraps the fitness cache before any greedy acceptance or
abandonment logic runs. Positions are drawn from a deterministic
seed_stream; the process-wide Flex RNG is never touched.
Source§fn ask(
&self,
params: &CuckooConfig,
state: &CuckooState<B>,
rng: &mut dyn Rng,
device: &<B as BackendTypes>::Device,
) -> (Tensor<B, 2>, CuckooState<B>)
fn ask( &self, params: &CuckooConfig, state: &CuckooState<B>, rng: &mut dyn Rng, device: &<B as BackendTypes>::Device, ) -> (Tensor<B, 2>, CuckooState<B>)
Propose new egg positions via Mantegna’s Lévy-stable step.
On the first call (state.fitness is empty) returns the initial
nests unchanged so the caller can evaluate generation zero.
On subsequent calls, samples u ∼ N(0, σ_u²) and v ∼ N(0, 1)
host-side from a deterministic seed_stream, then forms
step = u / |v|^(1/β) and proposes
x'_i = x_i + α · step, clipped to params.bounds.
Source§fn tell(
&self,
params: &CuckooConfig,
population: Tensor<B, 2>,
fitness: Tensor<B, 1>,
state: CuckooState<B>,
rng: &mut dyn Rng,
) -> (CuckooState<B>, StrategyMetrics)
fn tell( &self, params: &CuckooConfig, population: Tensor<B, 2>, fitness: Tensor<B, 1>, state: CuckooState<B>, rng: &mut dyn Rng, ) -> (CuckooState<B>, StrategyMetrics)
Ingest egg fitness values, apply greedy per-slot acceptance, abandon the worst nests, and advance the generation counter.
On the first call (generation zero bootstrap) all eggs are unconditionally accepted and nest abandonment is skipped.
On subsequent calls:
- Greedy accept — egg
ireplaces nestiifffitness[i] ≤ state.fitness[i]. - Abandonment — the
⌊p_a · pop_size⌋worst nests are re-initialized fromboundsviaseed_stream; abandoned slots carry sentinel+∞fitness so the next generation’s Lévy proposal always lands on them.
Source§fn best(&self, state: &CuckooState<B>) -> Option<(Tensor<B, 2>, f32)>
fn best(&self, state: &CuckooState<B>) -> Option<(Tensor<B, 2>, f32)>
Returns the best-so-far (genome, fitness) pair, or None before
the first tell call.
Source§type Params = CuckooConfig
type Params = CuckooConfig
Source§type State = CuckooState<B>
type State = CuckooState<B>
Auto Trait Implementations§
impl<B> Freeze for CuckooSearch<B>
impl<B> RefUnwindSafe for CuckooSearch<B>
impl<B> Send for CuckooSearch<B>
impl<B> Sync for CuckooSearch<B>
impl<B> Unpin for CuckooSearch<B>
impl<B> UnsafeUnpin for CuckooSearch<B>
impl<B> UnwindSafe for CuckooSearch<B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<C> CloneExpand for Cwhere
C: Clone,
impl<C> CloneExpand for Cwhere
C: Clone,
fn __expand_clone_method(&self, _scope: &mut Scope) -> C
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more