pub struct PsoConfig {
pub pop_size: usize,
pub genome_dim: usize,
pub bounds: Bounds,
pub inertia: f32,
pub c1: f32,
pub c2: f32,
pub v_max: f32,
pub variant: PsoVariant,
}Expand description
Static configuration for a ParticleSwarm run.
Fields§
§pop_size: usizeNumber of particles in the swarm.
genome_dim: usizeGenome (position) dimensionality.
bounds: BoundsSearch-space bounds for initialization and position clamping.
inertia: f32Inertia weight (only used by PsoVariant::Inertia).
c1: f32Cognitive coefficient (personal-best pull).
c2: f32Social coefficient (global-best pull).
v_max: f32Per-dimension velocity clamp. Classical PSO literature recommends ~half the search-space extent.
variant: PsoVariantVariant.
Implementations§
Source§impl PsoConfig
impl PsoConfig
Sourcepub fn default_for(pop_size: usize, genome_dim: usize) -> Self
pub fn default_for(pop_size: usize, genome_dim: usize) -> Self
Default configuration matching Shi & Eberhart’s canonical settings
(ω = 0.7298, c1 = c2 = 1.49618) — the constriction-equivalent
values so Inertia and Constriction variants agree in behaviour
under the same default.
The default variant is PsoVariant::Inertia. To switch to the
constriction form, set variant = PsoVariant::Constriction and
update c1 and c2 so that c1 + c2 > 4 (the Clerc & Kennedy
requirement — the default c1 = c2 = 1.49618 gives φ ≈ 2.99,
which violates this); a canonical choice is c1 = c2 = 2.05.
Sourcepub fn constriction_chi(&self) -> f32
pub fn constriction_chi(&self) -> f32
Computes the constriction factor χ = 2 / |2 − φ − √(φ² − 4φ)|
where φ = c1 + c2.
Clerc & Kennedy (2002) require φ > 4 for the closed form to be
real-valued. If φ ≤ 4 the discriminant is clamped to zero and
χ falls back to 1.0 (no contraction) so the strategy remains
numerically well-defined. A debug_assert! fires in debug builds
when this fallback is triggered; it is silent in release builds.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PsoConfig
impl RefUnwindSafe for PsoConfig
impl Send for PsoConfig
impl Sync for PsoConfig
impl Unpin for PsoConfig
impl UnsafeUnpin for PsoConfig
impl UnwindSafe for PsoConfig
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