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>
impl<T: Integer<T>, D> IntCodec<T, D>
pub fn with_bounds(self, bounds: Range<T>) -> Self
Trait Implementations§
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.
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.
fn encode(&self) -> Genotype<IntChromosome<T>>
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.
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.