Struct genevo::algorithm::EvaluatedPopulation
source · [−]Expand description
The EvaluatedPopulation
holds the results of the evaluation stage of
the genetic algorithm. It is used to pass these values to the
operator::SelectionOp
to enable this operator to do its job.
Currently it contains the fitness value of each individual in a population, their normalized fitness values and highest and average fitness of the population.
As the information in this struct is only used to pass the output of the evaluation stage to the selection operator and this happens once for every population the types of the fields are designed to avoid cloning of whole data structures. To be able to change the fields internally later when new optimization are found the fields are kept private.
Implementations
sourceimpl<G, F> EvaluatedPopulation<G, F> where
G: Genotype,
F: Fitness,
impl<G, F> EvaluatedPopulation<G, F> where
G: Genotype,
F: Fitness,
sourcepub fn new(
individuals: Rc<Vec<G>>,
fitness_values: Vec<F>,
highest_fitness: F,
lowest_fitness: F,
average_fitness: F
) -> Self
pub fn new(
individuals: Rc<Vec<G>>,
fitness_values: Vec<F>,
highest_fitness: F,
lowest_fitness: F,
average_fitness: F
) -> Self
Construct a new instance of the EvaluatedPopulation
struct.
sourcepub fn individuals(&self) -> Rc<Vec<G>>
pub fn individuals(&self) -> Rc<Vec<G>>
Returns the individuals of the population that has been evaluated.
sourcepub fn fitness_values(&self) -> &[F]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub fn fitness_values(&self) -> &[F]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
Returns the fitness values of all individuals of the evaluated population.
The returned slice contains the fitness values of the individuals
in the same order as the slice returned by function individuals
contains the individuals itself, i.e. for individual with index i
in individuals()[i]
the fitness value is stored in
fitness_values()[i]
.
sourcepub fn highest_fitness(&self) -> &F
pub fn highest_fitness(&self) -> &F
Returns the highest genetic::Fitness
value found in the evaluated
population.
sourcepub fn lowest_fitness(&self) -> &F
pub fn lowest_fitness(&self) -> &F
Returns the lowest genetic::Fitness
value found in the evaluated
population.
sourcepub fn average_fitness(&self) -> &F
pub fn average_fitness(&self) -> &F
Returns the average of all genetic::Fitness
values of the evaluated
population.
sourcepub fn individual(&self, index: usize) -> Option<&G>
pub fn individual(&self, index: usize) -> Option<&G>
Returns the individual at the given index.
sourcepub fn fitness_of_individual(&self, individual: &G) -> Option<&F>
pub fn fitness_of_individual(&self, individual: &G) -> Option<&F>
Returns the genetic::Fitness
value of the given individual.
Note: This function might be more expensive due to the data structure chosen for this struct. So use it sparingly.
sourcepub fn individual_with_fitness(&self, fitness: &F) -> Option<&G>
pub fn individual_with_fitness(&self, fitness: &F) -> Option<&G>
Returns the genetic::Genotype
of the individual with a given
genetic::Fitness
value.
Note: This function might be more expensive due to the data structure chosen for this struct. So use it sparingly.
sourcepub fn evaluated_individual_with_fitness(
&self,
fitness: &F
) -> Option<Evaluated<G, F>>
pub fn evaluated_individual_with_fitness(
&self,
fitness: &F
) -> Option<Evaluated<G, F>>
Returns the Evaluated
individual with a given genetic::Fitness
value.
Note: This function might be more expensive due to the data structure chosen for this struct. So use it sparingly.
Trait Implementations
sourceimpl<G: Clone, F: Clone> Clone for EvaluatedPopulation<G, F> where
G: Genotype,
F: Fitness,
impl<G: Clone, F: Clone> Clone for EvaluatedPopulation<G, F> where
G: Genotype,
F: Fitness,
sourcefn clone(&self) -> EvaluatedPopulation<G, F>
fn clone(&self) -> EvaluatedPopulation<G, F>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<G: PartialEq, F: PartialEq> PartialEq<EvaluatedPopulation<G, F>> for EvaluatedPopulation<G, F> where
G: Genotype,
F: Fitness,
impl<G: PartialEq, F: PartialEq> PartialEq<EvaluatedPopulation<G, F>> for EvaluatedPopulation<G, F> where
G: Genotype,
F: Fitness,
sourcefn eq(&self, other: &EvaluatedPopulation<G, F>) -> bool
fn eq(&self, other: &EvaluatedPopulation<G, F>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &EvaluatedPopulation<G, F>) -> bool
fn ne(&self, other: &EvaluatedPopulation<G, F>) -> bool
This method tests for !=
.
impl<G: Eq, F: Eq> Eq for EvaluatedPopulation<G, F> where
G: Genotype,
F: Fitness,
impl<G, F> StructuralEq for EvaluatedPopulation<G, F> where
G: Genotype,
F: Fitness,
impl<G, F> StructuralPartialEq for EvaluatedPopulation<G, F> where
G: Genotype,
F: Fitness,
Auto Trait Implementations
impl<G, F> RefUnwindSafe for EvaluatedPopulation<G, F> where
F: RefUnwindSafe,
G: RefUnwindSafe,
impl<G, F> !Send for EvaluatedPopulation<G, F>
impl<G, F> !Sync for EvaluatedPopulation<G, F>
impl<G, F> Unpin for EvaluatedPopulation<G, F> where
F: Unpin,
impl<G, F> UnwindSafe for EvaluatedPopulation<G, F> where
F: UnwindSafe,
G: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more