Struct genetic_algorithm::genotype::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<G::Genes>,
}
Expand description

The builder for a Genotype struct

Shared initialization options for all Genotypes:

  • Builder with_seed_genes_list(Vec<Genotype::Genes>), optional, list of start genes of all chromosomes which are distributed randomly in the population (instead of the default random genes). Sometimes it is efficient to start with a certain population

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<G::Genes>

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<G::Genes>) -> 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, G::Genes: Clone,

source§

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

Returns a copy 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, G::Genes: 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 = TryFromBuilderError

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 TryFrom<Builder<Bit>> for Bit

source§

type Error = TryFromBuilderError

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> TryFrom<Builder<List<T>>> for List<T>

source§

type Error = TryFromBuilderError

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> TryFrom<Builder<MultiList<T>>> for MultiList<T>

source§

type Error = TryFromBuilderError

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>
where T: SampleUniform + Allele + Into<f64> + Add<Output = T> + PartialOrd, Uniform<T>: Send + Sync,

source§

type Error = TryFromBuilderError

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> TryFrom<Builder<MultiUnique<T>>> for MultiUnique<T>

source§

type Error = TryFromBuilderError

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>
where T: SampleUniform + Allele + Add<Output = T> + PartialOrd, Uniform<T>: Send + Sync,

source§

type Error = TryFromBuilderError

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> TryFrom<Builder<Unique<T>>> for Unique<T>

source§

type Error = TryFromBuilderError

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>

§

impl<G> Send for Builder<G>

§

impl<G> Sync for Builder<G>

§

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

§

impl<G> UnwindSafe for Builder<G>

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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