GenotypeBuilder

Struct GenotypeBuilder 

Source
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 using with_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>

Source

pub fn new() -> Self

Source

pub fn with_genes_size(self, genes_size: usize) -> Self

Source

pub fn with_allele_list(self, allele_list: Vec<G::Allele>) -> Self

Source

pub fn with_allele_lists(self, allele_lists: Vec<Vec<G::Allele>>) -> Self

Source

pub fn with_allele_range(self, allele_range: RangeInclusive<G::Allele>) -> Self

Source

pub fn with_allele_ranges( self, allele_ranges: Vec<RangeInclusive<G::Allele>>, ) -> Self

Source

pub fn with_allele_mutation_range( self, allele_mutation_range: RangeInclusive<G::Allele>, ) -> Self

Source

pub fn with_allele_mutation_ranges( self, allele_mutation_ranges: Vec<RangeInclusive<G::Allele>>, ) -> Self

Source

pub fn with_allele_mutation_scaled_range( self, allele_mutation_scaled_range: Vec<RangeInclusive<G::Allele>>, ) -> Self

Source

pub fn with_allele_mutation_scaled_ranges( self, allele_mutation_scaled_ranges: Vec<Vec<RangeInclusive<G::Allele>>>, ) -> Self

Source

pub fn with_seed_genes_list( self, seed_genes_list: Vec<Genes<G::Allele>>, ) -> Self

Source

pub fn with_genes_hashing(self, genes_hashing: bool) -> Self

Source

pub fn with_chromosome_recycling(self, chromosome_recycling: bool) -> Self

Source

pub fn build(self) -> Result<G, <G as TryFrom<Builder<G>>>::Error>

Trait Implementations§

Source§

impl<G: Clone + Genotype> Clone for Builder<G>
where G::Allele: Clone,

Source§

fn clone(&self) -> Builder<G>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<G: Debug + Genotype> Debug for Builder<G>
where G::Allele: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<G: Genotype> Default for Builder<G>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl TryFrom<Builder<Binary>> for Binary

Source§

type Error = TryFromGenotypeBuilderError

The type returned in the event of a conversion error.
Source§

fn try_from(builder: Builder<Self>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: Allele + PartialEq + Hash> TryFrom<Builder<List<T>>> for List<T>

Source§

type Error = TryFromGenotypeBuilderError

The type returned in the event of a conversion error.
Source§

fn try_from(builder: Builder<Self>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: Allele + PartialEq + Hash> TryFrom<Builder<MultiList<T>>> for MultiList<T>

Source§

type Error = TryFromGenotypeBuilderError

The type returned in the event of a conversion error.
Source§

fn try_from(builder: Builder<Self>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T> TryFrom<Builder<MultiRange<T>>> for MultiRange<T>

Source§

type Error = TryFromGenotypeBuilderError

The type returned in the event of a conversion error.
Source§

fn try_from(builder: Builder<Self>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: Allele + Hash> TryFrom<Builder<MultiUnique<T>>> for MultiUnique<T>

Source§

type Error = TryFromGenotypeBuilderError

The type returned in the event of a conversion error.
Source§

fn try_from(builder: Builder<Self>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T> TryFrom<Builder<Range<T>>> for Range<T>

Source§

type Error = TryFromGenotypeBuilderError

The type returned in the event of a conversion error.
Source§

fn try_from(builder: Builder<Self>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: Allele + Hash> TryFrom<Builder<Unique<T>>> for Unique<T>

Source§

type Error = TryFromGenotypeBuilderError

The type returned in the event of a conversion error.
Source§

fn try_from(builder: Builder<Self>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<G> Freeze for Builder<G>
where <G as Genotype>::Allele: Freeze,

§

impl<G> RefUnwindSafe for Builder<G>
where <G as Genotype>::Allele: RefUnwindSafe,

§

impl<G> Send for Builder<G>

§

impl<G> Sync for Builder<G>

§

impl<G> Unpin for Builder<G>
where <G as Genotype>::Allele: Unpin,

§

impl<G> UnwindSafe for Builder<G>
where <G as Genotype>::Allele: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V