Struct genevo::reinsertion::elitist::ElitistReinserter
source · [−]pub struct ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>, { /* private fields */ }
Expand description
The ElitistReinserter
combines the best individuals from the offspring and
the old population. When there are more individuals in the offspring than
necessary, either because the offspring is larger than the population size
or a replace ratio smaller then 1.0 is specified, only those individuals
with the best fitness are taken over into the new population.
The reinserter can be configured by the replace_ratio
field. The
replace ratio is the fraction of the population size that is replaced by
individuals from the offspring. The remaining spots are filled with
individuals from the old population.
A replace ratio of 1.0 means that the new population is fist filled with individuals from the offspring. If the offspring does not contain enough individuals then the new population is filled up with individuals from the old population. If the offspring contains more individuals than the size of the population then the individuals are chosen uniformly at random.
Implementations
sourceimpl<G, F, E> ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
impl<G, F, E> ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
sourcepub fn new(
fitness_evaluator: E,
offspring_has_precedence: bool,
replace_ratio: f64
) -> Self
pub fn new(
fitness_evaluator: E,
offspring_has_precedence: bool,
replace_ratio: f64
) -> Self
Constructs a new instance of the ElitistReinserter
.
sourcepub fn is_offspring_has_precedence(&self) -> bool
pub fn is_offspring_has_precedence(&self) -> bool
Returns true if the offspring should take precedence over better performing individuals from the old population.
sourcepub fn set_offspring_has_precedence(&mut self, value: bool)
pub fn set_offspring_has_precedence(&mut self, value: bool)
Sets whether the offspring should have precedence over better performing individuals from the old population.
sourcepub fn replace_ratio(&self) -> f64
pub fn replace_ratio(&self) -> f64
Returns the replace_ratio
of this ElitistReinserter
.
sourcepub fn set_replace_ratio(&mut self, value: f64)
pub fn set_replace_ratio(&mut self, value: f64)
Set the replace_ratio
of this ElitistReinserter
to the given
value. The value must be between 0 and 1.0 (inclusive).
Trait Implementations
sourceimpl<G: Clone, F: Clone, E: Clone> Clone for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
impl<G: Clone, F: Clone, E: Clone> Clone for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
sourcefn clone(&self) -> ElitistReinserter<G, F, E>
fn clone(&self) -> ElitistReinserter<G, F, E>
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: Debug, F: Debug, E: Debug> Debug for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
impl<G: Debug, F: Debug, E: Debug> Debug for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
sourceimpl<G, F, E> GeneticOperator for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
impl<G, F, E> GeneticOperator for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
sourceimpl<G: PartialEq, F: PartialEq, E: PartialEq> PartialEq<ElitistReinserter<G, F, E>> for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
impl<G: PartialEq, F: PartialEq, E: PartialEq> PartialEq<ElitistReinserter<G, F, E>> for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
sourcefn eq(&self, other: &ElitistReinserter<G, F, E>) -> bool
fn eq(&self, other: &ElitistReinserter<G, F, E>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ElitistReinserter<G, F, E>) -> bool
fn ne(&self, other: &ElitistReinserter<G, F, E>) -> bool
This method tests for !=
.
sourceimpl<G, F, E> ReinsertionOp<G, F> for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
impl<G, F, E> ReinsertionOp<G, F> for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
impl<G, F, E> MultiObjective for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
Can be used for multi-objective optimization
impl<G, F, E> SingleObjective for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
Can be used for single-objective optimization
impl<G, F, E> StructuralPartialEq for ElitistReinserter<G, F, E> where
G: Genotype,
F: Fitness,
E: FitnessFunction<G, F>,
Auto Trait Implementations
impl<G, F, E> RefUnwindSafe for ElitistReinserter<G, F, E> where
E: RefUnwindSafe,
F: RefUnwindSafe,
G: RefUnwindSafe,
impl<G, F, E> Send for ElitistReinserter<G, F, E> where
E: Send,
F: Send,
impl<G, F, E> Sync for ElitistReinserter<G, F, E> where
E: Sync,
F: Sync,
impl<G, F, E> Unpin for ElitistReinserter<G, F, E> where
F: Unpin,
G: Unpin,
impl<G, F, E> UnwindSafe for ElitistReinserter<G, F, E> where
E: UnwindSafe,
F: UnwindSafe,
G: UnwindSafe,
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