Skip to main content

SearcherCore

Struct SearcherCore 

Source
pub struct SearcherCore<TUnit, TFit, TMover>
where TUnit: Unit, TFit: FitCalc, TMover: ParticleMover,
{ pub fit_calc: TFit, pub mover: TMover, pub swarm_best: Best<TUnit>, pub master_rng: SmallRng, pub particle_rngs: Vec<SmallRng>, }
Expand description

Shared bookkeeping for Searcher impls.

Holds the fitness function, mover, master + per-particle RNGs, and the reduced swarm best. Topology-specific state (niche partition, neighbour graph, pbest snapshot) lives on each searcher alongside a SearcherCore field.

Fields§

§fit_calc: TFit

Fitness function.

§mover: TMover

Mover.

§swarm_best: Best<TUnit>

Reduced from particle pbests. For gbest this is the social attractor; for lbest / niched it’s reporting only.

§master_rng: SmallRng

Source for the per-particle RNGs.

§particle_rngs: Vec<SmallRng>

One RNG per particle, sized lazily.

Implementations§

Source§

impl<TUnit, TFit, TMover> SearcherCore<TUnit, TFit, TMover>
where TUnit: Unit, TFit: FitCalc<T = TUnit>, TMover: ParticleMover<TUnit = TUnit>,

Source

pub fn new(fit_calc: TFit, mover: TMover) -> Self

OS-seeded master RNG; per-particle RNGs are created lazily on the first Self::sync_rngs.

Source

pub fn sync_rngs(&mut self, n: usize)

Resize particle_rngs to n, reseeding new entries from master_rng.

Source

pub fn reseed<R: Rng>(&mut self, rng: &mut R)

Reseed master_rng from rng; per-particle RNGs are cleared and re-derived on the next sync_rngs.

Trait Implementations§

Source§

impl<TUnit, TFit, TMover> Clone for SearcherCore<TUnit, TFit, TMover>
where TUnit: Unit + Clone, TFit: FitCalc + Clone, TMover: ParticleMover + Clone,

Source§

fn clone(&self) -> SearcherCore<TUnit, TFit, TMover>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<TUnit, TFit, TMover, TContext> Contextful for SearcherCore<TUnit, TFit, TMover>
where TFit: FitCalc<T = TUnit, TContext = TContext>, TMover: ParticleMover<TUnit = TUnit, TContext = TContext>, TUnit: Unit, TContext: Copy,

Source§

type TContext = TContext

Reparameterization payload.
Source§

fn set_context(&mut self, context: Self::TContext)

Replace the current context. Defaults to a no-op; override when the impl actually reads TContext.
Source§

fn set_iteration(&mut self, iteration: usize, max_iteration: usize)

iteration is 1-based; the init (fitness-only) pass runs before any call. Override for iteration-dependent schedules.
Source§

impl<TUnit, TFit, TMover> Debug for SearcherCore<TUnit, TFit, TMover>
where TUnit: Unit + Debug, TFit: FitCalc + Debug, TMover: ParticleMover + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<TUnit, TFit, TMover> Freeze for SearcherCore<TUnit, TFit, TMover>
where TFit: Freeze, TMover: Freeze, TUnit: Freeze,

§

impl<TUnit, TFit, TMover> RefUnwindSafe for SearcherCore<TUnit, TFit, TMover>
where TFit: RefUnwindSafe, TMover: RefUnwindSafe, TUnit: RefUnwindSafe,

§

impl<TUnit, TFit, TMover> Send for SearcherCore<TUnit, TFit, TMover>
where TFit: Send, TMover: Send,

§

impl<TUnit, TFit, TMover> Sync for SearcherCore<TUnit, TFit, TMover>

§

impl<TUnit, TFit, TMover> Unpin for SearcherCore<TUnit, TFit, TMover>
where TFit: Unpin, TMover: Unpin, TUnit: Unpin,

§

impl<TUnit, TFit, TMover> UnsafeUnpin for SearcherCore<TUnit, TFit, TMover>
where TFit: UnsafeUnpin, TMover: UnsafeUnpin, TUnit: UnsafeUnpin,

§

impl<TUnit, TFit, TMover> UnwindSafe for SearcherCore<TUnit, TFit, TMover>
where TFit: UnwindSafe, TMover: UnwindSafe, TUnit: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.