pub struct TournamentSelection {
pub tournament_size: usize,
pub with_replacement: bool,
}Expand description
Tournament selection operator
Selects the best individual from a randomly sampled subset (the “tournament”) of the population.
§Sampling with vs. without replacement
By default competitors are sampled with replacement (each of the k
competitors is drawn independently and uniformly from the whole
population). This is the textbook model, for which the probability that the
individual of rank i wins has the clean closed form and selection pressure
grows smoothly with k; the same individual may appear more than once in a
tournament. Crucially, tournament_size >= population size does not
make selection deterministic under this model — a draw of k = n
competitors with replacement includes the global best only with probability
1 - ((n-1)/n)^k (≈ 0.63 at k = n).
The without-replacement variant (constructed via
without_replacement) instead draws k
distinct individuals; there the tournament size is capped at the
population size and k >= n degenerates to fully elitist selection (the
global best is chosen every call).
Fields§
§tournament_size: usizeTournament size (number of individuals competing)
with_replacement: boolWhether competitors are sampled with replacement (canonical default) or as distinct individuals.
Implementations§
Source§impl TournamentSelection
impl TournamentSelection
Sourcepub fn new(tournament_size: usize) -> Self
pub fn new(tournament_size: usize) -> Self
Create a new tournament selection with the given size (sampling with replacement, the canonical model).
Sourcepub fn without_replacement(tournament_size: usize) -> Self
pub fn without_replacement(tournament_size: usize) -> Self
Create a tournament selection that samples tournament_size distinct
competitors (without replacement).
Note that with this variant tournament_size >= population size selects
the global best deterministically every call.
Trait Implementations§
Source§impl Clone for TournamentSelection
impl Clone for TournamentSelection
Source§fn clone(&self) -> TournamentSelection
fn clone(&self) -> TournamentSelection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TournamentSelection
impl Debug for TournamentSelection
Source§impl<G: EvolutionaryGenome> SelectionOperator<G> for TournamentSelection
impl<G: EvolutionaryGenome> SelectionOperator<G> for TournamentSelection
Auto Trait Implementations§
impl Freeze for TournamentSelection
impl RefUnwindSafe for TournamentSelection
impl Send for TournamentSelection
impl Sync for TournamentSelection
impl Unpin for TournamentSelection
impl UnsafeUnpin for TournamentSelection
impl UnwindSafe for TournamentSelection
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
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> ⓘ
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> ⓘ
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.