Skip to main content

GBestSearcher

Struct GBestSearcher 

Source
pub struct GBestSearcher<TUnit, TFit, TMover>
where TUnit: Unit, TFit: FitCalc, TMover: ParticleMover,
{ /* private fields */ }
Expand description

Global-best PSO searcher.

Implementations§

Source§

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

Source

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

RNG is OS-seeded; call Searcher::reseed for determinism.

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> GBestSearcher<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 GBestSearcher<TUnit, TFit, TMover>
where TFit: FitCalc<T = TUnit, TContext = TContext>, TMover: ParticleMover<TUnit = TUnit, TCommon = Best<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 GBestSearcher<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
Source§

impl<TUnit, TFit, TMover, TContext> Searcher for GBestSearcher<TUnit, TFit, TMover>
where TFit: FitCalc<T = TUnit, TContext = TContext>, TMover: ParticleMover<TUnit = TUnit, TCommon = Best<TUnit>, TContext = TContext>, TUnit: Unit, TContext: Copy,

Source§

type TUnit = TUnit

The particle unit this searcher iterates over.
Source§

fn init(&mut self, particles: &mut Group<Self::TUnit>)

Initial fitness pass + per-particle state seed.
Source§

fn next(&mut self, particles: &mut Group<Self::TUnit>) -> &Best<TUnit>

Advance the swarm one step; return the swarm-wide best so far.
Source§

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

Reseed the searcher’s RNG.
Source§

fn nested<TInit>( self, max_iteration: usize, particle_init: TInit, ) -> NestedMover<<Self::TUnit as SetTo>::TTarget, Self::TUnit, Self, TInit>
where Self: Sized, Self::TUnit: SetTo, TInit: ParticleInitDependent<TIn = <Self::TUnit as SetTo>::TTarget, TOut = Self::TUnit>,

Wrap this searcher in a NestedMover.
Source§

fn iter<'a>( &'a mut self, max_iteration: usize, group: &'a mut Group<Self::TUnit>, evolution: Option<&'a mut Evolution<Self::TUnit>>, ) -> SearcherIter<'a, Self::TUnit, Self>
where Self: Sized,

Drive the searcher as an Iterator<Item = Best<TUnit>> for max_iteration steps; optionally record each step’s Group snapshot into evolution.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<TUnit, TFit, TMover> UnwindSafe for GBestSearcher<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.