pub struct Population<T: Allele> {
pub chromosomes: Vec<Chromosome<T>>,
pub recycling: bool,
/* private fields */
}Fields§
§chromosomes: Vec<Chromosome<T>>§recycling: boolImplementations§
Source§impl<T: Allele> Population<T>
impl<T: Allele> Population<T>
pub fn new(chromosomes: Vec<Chromosome<T>>, recycling: bool) -> Self
pub fn new_empty(recycling: bool) -> Self
pub fn size(&self) -> usize
pub fn parents_and_offspring_size(&self) -> (usize, usize)
pub fn shuffle<R: Rng>(&mut self, rng: &mut R)
pub fn reset_age(&mut self)
pub fn increment_age(&mut self)
pub fn recycled_size(&self) -> usize
Sourcepub fn new_chromosome(&mut self, source: &Chromosome<T>) -> Chromosome<T>
pub fn new_chromosome(&mut self, source: &Chromosome<T>) -> Chromosome<T>
Get a recycled chromosome or create new one by cloning source
Sourcepub fn drop_chromosome(&mut self, chromosome: Chromosome<T>)
pub fn drop_chromosome(&mut self, chromosome: Chromosome<T>)
Recycle the chromosome or just drop it
Sourcepub fn truncate(&mut self, keep_size: usize)
pub fn truncate(&mut self, keep_size: usize)
Truncate a population and add truncated chromosomes to recycling bin
Sourcepub fn truncate_external(
&mut self,
chromosomes: &mut Vec<Chromosome<T>>,
keep_size: usize,
)
pub fn truncate_external( &mut self, chromosomes: &mut Vec<Chromosome<T>>, keep_size: usize, )
Truncate a detached vector and add truncated chromosomes to recycling bin Used when chromosomes are temporarily outside the population (e.g. during selection)
Sourcepub fn extend_from_within(&mut self, amount: usize)
pub fn extend_from_within(&mut self, amount: usize)
Extend population by amount, reusing recycled chromosomes if available
Sourcepub fn best_chromosome(
&self,
fitness_ordering: FitnessOrdering,
) -> Option<&Chromosome<T>>
pub fn best_chromosome( &self, fitness_ordering: FitnessOrdering, ) -> Option<&Chromosome<T>>
fitness_score is Option and None is least, but invalid as best_chromosome, so filter it out when minimizing the fitness score, otherwise None would end up as best.
pub fn best_chromosome_index( &self, fitness_ordering: FitnessOrdering, ) -> Option<usize>
pub fn best_chromosome_indices( &self, amount: usize, fitness_ordering: FitnessOrdering, ) -> Vec<usize>
pub fn unique_chromosome_indices(&self) -> Vec<usize>
pub fn best_unique_chromosome_indices( &self, amount: usize, fitness_ordering: FitnessOrdering, ) -> Vec<usize>
pub fn age_mean(&self) -> f32
pub fn fitness_score_count(&self) -> usize
pub fn fitness_score_median(&self) -> Option<isize>
pub fn fitness_score_mean(&self) -> f32
pub fn fitness_score_stddev(&self) -> f32
pub fn fitness_score_cardinality(&self) -> Option<usize>
pub fn genes_cardinality(&self) -> Option<usize>
Trait Implementations§
Source§impl<T: Clone + Allele> Clone for Population<T>
impl<T: Clone + Allele> Clone for Population<T>
Source§fn clone(&self) -> Population<T>
fn clone(&self) -> Population<T>
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 moreSource§impl<T: Allele> From<Vec<Chromosome<T>>> for Population<T>
impl<T: Allele> From<Vec<Chromosome<T>>> for Population<T>
Source§fn from(chromosomes: Vec<Chromosome<T>>) -> Self
fn from(chromosomes: Vec<Chromosome<T>>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<T> Freeze for Population<T>
impl<T> RefUnwindSafe for Population<T>where
T: RefUnwindSafe,
impl<T> Send for Population<T>
impl<T> Sync for Population<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more