pub struct SelectTournament {
pub replacement_rate: f32,
pub elitism_rate: f32,
pub tournament_size: usize,
}
Expand description
Run tournaments with randomly chosen chromosomes and pick a single winner. Do this untill the target_population_size (or full population when in shortage) of the population is reached and drop excess chromosomes. This approach kind of sorts the fitness first, but not very strictly. This preserves a level of diversity, which avoids local optimum lock-in.
Fields§
§replacement_rate: f32
§elitism_rate: f32
§tournament_size: usize
Implementations§
Source§impl Tournament
impl Tournament
pub fn new( replacement_rate: f32, elitism_rate: f32, tournament_size: usize, ) -> Self
pub fn selection<G: EvolveGenotype, R: Rng>( &self, chromosomes: &mut Vec<G::Chromosome>, selection_size: usize, genotype: &mut G, config: &EvolveConfig, rng: &mut R, )
Trait Implementations§
Source§impl Clone for Tournament
impl Clone for Tournament
Source§fn clone(&self) -> Tournament
fn clone(&self) -> Tournament
Returns a copy 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 Debug for Tournament
impl Debug for Tournament
Source§impl From<Tournament> for Wrapper
impl From<Tournament> for Wrapper
Source§fn from(select: SelectTournament) -> Self
fn from(select: SelectTournament) -> Self
Converts to this type from the input type.
Source§impl Select for Tournament
impl Select for Tournament
fn call<G: EvolveGenotype, R: Rng, SR: StrategyReporter<Genotype = G>>( &mut self, genotype: &mut G, state: &mut EvolveState<G>, config: &EvolveConfig, _reporter: &mut SR, rng: &mut R, )
fn extract_elite_chromosomes<G: EvolveGenotype>( &self, state: &mut EvolveState<G>, config: &EvolveConfig, elitism_rate: f32, ) -> Vec<G::Chromosome>
fn parent_and_offspring_survival_sizes( &self, parents_size: usize, offspring_size: usize, target_size: usize, replacement_rate: f32, ) -> (usize, usize)
Auto Trait Implementations§
impl Freeze for Tournament
impl RefUnwindSafe for Tournament
impl Send for Tournament
impl Sync for Tournament
impl Unpin for Tournament
impl UnwindSafe for Tournament
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