pub struct Population<G: Genome> {
pub individuals: Vec<Individual<G>>,
pub generation: usize,
pub config: PopulationConfig,
}Expand description
A population of individuals.
Fields§
§individuals: Vec<Individual<G>>The individuals.
generation: usizeCurrent generation.
config: PopulationConfigConfiguration.
Implementations§
Source§impl<G: Genome> Population<G>
impl<G: Genome> Population<G>
Sourcepub fn random<R: Rng>(config: PopulationConfig, rng: &mut R) -> Self
pub fn random<R: Rng>(config: PopulationConfig, rng: &mut R) -> Self
Create a new random population.
Sourcepub fn best(&self) -> Option<&Individual<G>>
pub fn best(&self) -> Option<&Individual<G>>
Get the best individual by fitness.
Sourcepub fn top_n(&self, n: usize) -> Vec<&Individual<G>>
pub fn top_n(&self, n: usize) -> Vec<&Individual<G>>
Get the top N individuals by fitness.
Trait Implementations§
Source§impl<G: Clone + Genome> Clone for Population<G>
impl<G: Clone + Genome> Clone for Population<G>
Source§fn clone(&self) -> Population<G>
fn clone(&self) -> Population<G>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<G> Freeze for Population<G>
impl<G> RefUnwindSafe for Population<G>where
G: RefUnwindSafe,
impl<G> Send for Population<G>
impl<G> Sync for Population<G>
impl<G> Unpin for Population<G>where
G: Unpin,
impl<G> UnsafeUnpin for Population<G>
impl<G> UnwindSafe for Population<G>where
G: 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