Struct IntCodec

Source
pub struct IntCodec<T: Integer<T>, D = T> { /* private fields */ }
Expand description

A Codec for a Genotype of IntGenes. The encode function creates a Genotype with num_chromosomes chromosomes and num_genes genes per chromosome. The decode function creates a Vec<Vec<T>> from the Genotype where the inner Vec contains the alleles of the IntGenes in the chromosome. T must implement the Integer trait, meaning it must be one of i8, i16, i32, i64, i128, u8, u16, u32, u64, or u128.

The lower and upper bounds of the IntGenes can be set with the with_bounds function. The default bounds are equal to min and max.

Implementations§

Source§

impl<T: Integer<T>, D> IntCodec<T, D>

Source

pub fn with_bounds(self, bounds: Range<T>) -> Self

Source§

impl<T: Integer<T>> IntCodec<T, Vec<Vec<T>>>

Source

pub fn matrix(rows: usize, cols: usize, range: Range<T>) -> Self

Create a new IntCodec with the given number of chromosomes, genes, min, and max values. The f_32 values for each IntGene will be randomly generated between the min and max values.

Source§

impl<T: Integer<T>> IntCodec<T, Vec<T>>

Source

pub fn vector(count: usize, range: Range<T>) -> Self

Create a new IntCodec with the given number of chromosomes, genes, min, and max values. The f_32 values for each IntGene will be randomly generated between the min and max values.

Source§

impl<T: Integer<T>> IntCodec<T, T>

Source

pub fn scalar(range: Range<T>) -> Self

Create a new IntCodec with the given number of chromosomes, genes, min, and max values. The f_32 values for each IntGene will be randomly generated between the min and max values.

Trait Implementations§

Source§

impl<T: Clone + Integer<T>, D: Clone> Clone for IntCodec<T, D>

Source§

fn clone(&self) -> IntCodec<T, D>

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<T: Integer<T>> Codec<IntChromosome<T>, T> for IntCodec<T, T>

Implement the Codec trait for a Genotype of IntGenes. This will produce a Genotype with a single chromosome and a single gene. The decode function will create a T or a single value.

Source§

fn encode(&self) -> Genotype<IntChromosome<T>>

Source§

fn decode(&self, genotype: &Genotype<IntChromosome<T>>) -> T

Source§

impl<T: Integer<T>> Codec<IntChromosome<T>, Vec<T>> for IntCodec<T, Vec<T>>

Implement the Codec trait for a Genotype of IntGenes. This will produce a Genotype with a single chromosome and num_genes genes. The decode function will create a Vec<T> or a vector.

Source§

fn encode(&self) -> Genotype<IntChromosome<T>>

Source§

fn decode(&self, genotype: &Genotype<IntChromosome<T>>) -> Vec<T>

Source§

impl<T: Integer<T>> Codec<IntChromosome<T>, Vec<Vec<T>>> for IntCodec<T, Vec<Vec<T>>>

Implement the Codec trait for a Genotype of IntGenes. This will produce a Genotype with the given number of chromosomes and genes. The decode function will create a Vec<Vec<T>> or a matrix.

Source§

fn encode(&self) -> Genotype<IntChromosome<T>>

Source§

fn decode(&self, genotype: &Genotype<IntChromosome<T>>) -> Vec<Vec<T>>

Auto Trait Implementations§

§

impl<T, D> Freeze for IntCodec<T, D>
where T: Freeze,

§

impl<T, D> RefUnwindSafe for IntCodec<T, D>

§

impl<T, D> Send for IntCodec<T, D>
where T: Send, D: Send,

§

impl<T, D> Sync for IntCodec<T, D>
where T: Sync, D: Sync,

§

impl<T, D> Unpin for IntCodec<T, D>
where T: Unpin, D: Unpin,

§

impl<T, D> UnwindSafe for IntCodec<T, D>
where T: UnwindSafe, D: 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> 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