pub struct Model {
pub config: Config,
pub flat_dim: usize,
pub population: Population,
pub population_f_scores: Vec<f64>,
pub x_best: Particle,
pub f_best: f64,
/* private fields */
}Expand description
Model struct
It takes in a Config instance and fn pointer to an objective function and defines a run method for running Particle Swarm Optimization.
Fields§
§config: Config§flat_dim: usize§population: Population§population_f_scores: Vec<f64>§x_best: Particle§f_best: f64Implementations§
Source§impl Model
impl Model
Sourcepub fn new(
config: Config,
obj_f: fn(p: &Particle, flat_dim: usize, dim: &Vec<usize>) -> f64,
) -> Model
pub fn new( config: Config, obj_f: fn(p: &Particle, flat_dim: usize, dim: &Vec<usize>) -> f64, ) -> Model
Creates a new Model instance
Sourcepub fn get_f_values(&mut self) -> Vec<f64>
pub fn get_f_values(&mut self) -> Vec<f64>
Computes the value of the objective function for each particle and updates best found
Returns the objective function values for all particles
Uses the rayon crate for parallel computation
Sourcepub fn get_f_best(&self) -> f64
pub fn get_f_best(&self) -> f64
Returns the best found objective function value
Sourcepub fn get_x_best(&self) -> Particle
pub fn get_x_best(&self) -> Particle
Returns the best found minimizer
Auto Trait Implementations§
impl Freeze for Model
impl RefUnwindSafe for Model
impl Send for Model
impl Sync for Model
impl Unpin for Model
impl UnsafeUnpin for Model
impl UnwindSafe for Model
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
Mutably borrows from an owned value. Read more