pub struct Population<T: Genome> { /* private fields */ }
Expand description
Module containing Population struct and Genome trait Population struct that stores the population of genomes
Implementations§
Source§impl<T: Genome> Population<T>
impl<T: Genome> Population<T>
Sourcepub fn new(size: usize) -> Self
pub fn new(size: usize) -> Self
Creates a new Population with given size and Gene type.
§Examples
// Gene type need to implement the Genome trait for this to work
let mut population: Population<Gene> = Population::new(size);
Sourcepub fn live(&mut self)
pub fn live(&mut self)
Calculates the fitness of all the members of population and displays the fittest member by calling the display method implemented in Genome trait.
Sourcepub fn next_generation(&mut self)
pub fn next_generation(&mut self)
Replaces the current generation with a new generation
§Examples
for _ in 0..num_generations {
population.live();
population.next_generation();
}
Auto Trait Implementations§
impl<T> Freeze for Population<T>
impl<T> RefUnwindSafe for Population<T>where
T: RefUnwindSafe,
impl<T> Send for Population<T>where
T: Send,
impl<T> Sync for Population<T>where
T: Sync,
impl<T> Unpin for Population<T>where
T: Unpin,
impl<T> UnwindSafe for Population<T>where
T: 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