pub struct Population<P: Clone + Sync, F: Fitness + Sized + Send> {
pub population: Vec<P>,
pub generation: u32,
pub scores: Vec<F>,
}Expand description
Collection of programs
The root of each program is of type P, and fitness structures will be
represented by type F.
Fields§
§population: Vec<P>Collection of algorithms
generation: u32Generation index of this population
scores: Vec<F>Collection of fitness scores
Implementations§
Source§impl<P: Clone + Sync, F: Fitness + Sized + Send> Population<P, F>
impl<P: Clone + Sync, F: Fitness + Sized + Send> Population<P, F>
Sourcepub fn new(n: usize, generation: u32) -> Population<P, F>
pub fn new(n: usize, generation: u32) -> Population<P, F>
Create a new population with an estimated size.
This does not create programs yet but simply allocates memory.
pub fn n(&self) -> usize
Sourcepub fn score<S>(&mut self, scoring_fn: S, _: &mut dyn Rng)
pub fn score<S>(&mut self, scoring_fn: S, _: &mut dyn Rng)
Apply a scoring function to the entire population.
pub fn avg_score(&self) -> Number
pub fn best_score(&self) -> Number
Auto Trait Implementations§
impl<P, F> Freeze for Population<P, F>
impl<P, F> RefUnwindSafe for Population<P, F>where
P: RefUnwindSafe,
F: RefUnwindSafe,
impl<P, F> Send for Population<P, F>where
P: Send,
impl<P, F> Sync for Population<P, F>where
F: Sync,
impl<P, F> Unpin for Population<P, F>
impl<P, F> UnwindSafe for Population<P, F>where
P: UnwindSafe,
F: UnwindSafe,
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