[][src]Struct pso::swarm_config::SwarmConfig

pub struct SwarmConfig {
    pub global_behavior: GlobalBehavior,
    pub transient_behavior: TransientBehavior,
    pub wall_bounce_factor: f64,
    pub local_motion: f64,
    pub tribal_motion: f64,
    pub momentum: f64,
    pub num_particles: usize,
}

Configuration for Swarms of Particles

  • Defines the physical behavior of particles
  • Defines the number of particles in each swarm
  • Defines how a swarm uses information from other swarms

Examples

use pso::swarm_config::SwarmConfig;

// Start with a default configuration
let mut sc = SwarmConfig::new();

// Tell the swarm to collaborate with others every 25 iterations and weight the global minimum with a coefficient of 0.6
sc.synergic_behavior(0.6, 25);

// Define other motion coefficients
sc.motion_coefficients(0.7, 0.9, 0.45);

// Set the number of particles in the swarm
sc.num_particles(256);

println!("{}", sc);

Fields

global_behavior: GlobalBehaviortransient_behavior: TransientBehaviorwall_bounce_factor: f64local_motion: f64tribal_motion: f64momentum: f64num_particles: usize

Implementations

impl SwarmConfig[src]

pub fn new() -> Self[src]

pub fn synergic_behavior(
    &mut self,
    global_motion_coefficient: f64,
    collaboration_periodicity: usize
)
[src]

Set the particles in the swarm to use the global minimum to calculate their velocity each iteration

Arguments

  • global_motion_coefficient: How heavily weighted is the global minimum in the velocity calculation
  • collaboration_periodicity: How often does the swarm update its global minimum from the other swarms

pub fn solitary_behavior(&mut self)[src]

Set the swarm to ignore the global minimum and only use its own internal minimum (this is default behavior)

pub fn set_transient_behavior(&mut self, transient_behavior: TransientBehavior)[src]

Apply a custom transient behavior to the swarm configuration

pub fn wall_bounce(&mut self, wall_bounce_factor: f64)[src]

Set the wall bounce factor. This value is multiplied by a particles velocity when it goes out of bounds.

pub fn motion_coefficients(
    &mut self,
    local_motion: f64,
    tribal_motion: f64,
    momentum: f64
)
[src]

Set the motion coefficients. These describe how heavily certain parts of each particles velocity are weighted

Arguments

  • local_motion: How important is the particles best known location in the search space
  • tribal_motion: How important is the swarms best known location in the search space
  • momentum: How much of the particles current velocity is used to calculate its next velocity

pub fn num_particles(&mut self, num_particles: usize)[src]

The number of particles in the swarm. Powers of 2 are recommended

Trait Implementations

impl Clone for SwarmConfig[src]

impl Debug for SwarmConfig[src]

impl Display for SwarmConfig[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,