pub struct GenotypeBuilder<G: Genotype> {
pub genes_size: Option<usize>,
pub allele_list: Option<Vec<G::Allele>>,
pub allele_lists: Option<Vec<Vec<G::Allele>>>,
pub allele_range: Option<RangeInclusive<G::Allele>>,
pub allele_ranges: Option<Vec<RangeInclusive<G::Allele>>>,
pub allele_mutation_range: Option<RangeInclusive<G::Allele>>,
pub allele_mutation_ranges: Option<Vec<RangeInclusive<G::Allele>>>,
pub allele_mutation_scaled_range: Option<Vec<RangeInclusive<G::Allele>>>,
pub allele_mutation_scaled_ranges: Option<Vec<Vec<RangeInclusive<G::Allele>>>>,
pub seed_genes_list: Vec<Genes<G::Allele>>,
pub genes_hashing: bool,
pub chromosome_recycling: bool,
}
Expand description
The builder for a Genotype struct. See specfic Genotype for used options.
Shared initialization options for all Genotypes:
-
Builder
with_seed_genes_list(Vec<Genotype::Genes>)
, optional, list of start genes for chromosomes which are cycled into the starting population until the target_population_size is met (instead of the default random genes). Sometimes it is efficient to start with a certain population in the Evolve strategy. For the HillClimb strategy a single random seed genes is taken as the starting point for each run (not cycling through them in repeated runs). -
Builder
with_genes_hashing(true)
, optional, default true, store a genes_hash on the chromomose (in Evolve or HillClimb). This is needed when usingwith_fitness_cache
on the strategy as key for the cache. Hashing the genes has relatively high overhead for to the main Evolve loop, but might be useful for better population cardinality estimation (falls back to fitness score cardinality otherwise). -
Builder
with_chromosome_recycling(true)
, optional, default true, recycle chromosome population instead of reallocating repeatedly. Can be beneficiary for large genes_size. But does make the custom implementations of Crossover require to handle this, otherwise a memory leak would occur
Fields§
§genes_size: Option<usize>
§allele_list: Option<Vec<G::Allele>>
§allele_lists: Option<Vec<Vec<G::Allele>>>
§allele_range: Option<RangeInclusive<G::Allele>>
§allele_ranges: Option<Vec<RangeInclusive<G::Allele>>>
§allele_mutation_range: Option<RangeInclusive<G::Allele>>
§allele_mutation_ranges: Option<Vec<RangeInclusive<G::Allele>>>
§allele_mutation_scaled_range: Option<Vec<RangeInclusive<G::Allele>>>
§allele_mutation_scaled_ranges: Option<Vec<Vec<RangeInclusive<G::Allele>>>>
§seed_genes_list: Vec<Genes<G::Allele>>
§genes_hashing: bool
§chromosome_recycling: bool
Implementations§
Source§impl<G: Genotype> Builder<G>
impl<G: Genotype> Builder<G>
pub fn new() -> Self
pub fn with_genes_size(self, genes_size: usize) -> Self
pub fn with_allele_list(self, allele_list: Vec<G::Allele>) -> Self
pub fn with_allele_lists(self, allele_lists: Vec<Vec<G::Allele>>) -> Self
pub fn with_allele_range(self, allele_range: RangeInclusive<G::Allele>) -> Self
pub fn with_allele_ranges( self, allele_ranges: Vec<RangeInclusive<G::Allele>>, ) -> Self
pub fn with_allele_mutation_range( self, allele_mutation_range: RangeInclusive<G::Allele>, ) -> Self
pub fn with_allele_mutation_ranges( self, allele_mutation_ranges: Vec<RangeInclusive<G::Allele>>, ) -> Self
pub fn with_allele_mutation_scaled_range( self, allele_mutation_scaled_range: Vec<RangeInclusive<G::Allele>>, ) -> Self
pub fn with_allele_mutation_scaled_ranges( self, allele_mutation_scaled_ranges: Vec<Vec<RangeInclusive<G::Allele>>>, ) -> Self
pub fn with_seed_genes_list( self, seed_genes_list: Vec<Genes<G::Allele>>, ) -> Self
pub fn with_genes_hashing(self, genes_hashing: bool) -> Self
pub fn with_chromosome_recycling(self, chromosome_recycling: bool) -> Self
pub fn build(self) -> Result<G, <G as TryFrom<Builder<G>>>::Error>
Trait Implementations§
Source§impl<T> TryFrom<Builder<MultiRange<T>>> for MultiRange<T>
impl<T> TryFrom<Builder<MultiRange<T>>> for MultiRange<T>
Source§impl<T: Allele + Hash> TryFrom<Builder<MultiUnique<T>>> for MultiUnique<T>
impl<T: Allele + Hash> TryFrom<Builder<MultiUnique<T>>> for MultiUnique<T>
Auto Trait Implementations§
impl<G> Freeze for Builder<G>
impl<G> RefUnwindSafe for Builder<G>
impl<G> Send for Builder<G>
impl<G> Sync for Builder<G>
impl<G> Unpin for Builder<G>
impl<G> UnwindSafe for Builder<G>
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