pub struct FloatGene<F>where
F: Float,{ /* private fields */ }Expand description
A Gene that represents a floating point number.
The allele is the in the case of the FloatGene is of type F - which is a floating point type.
The min and max values default to F::MIN and F::MAX respectively.
During evolution, the value_range is used to generate new allele values, while the bounds are used
to ensure that the allele remains within a valid range. If no bounds are provided, they default to the same values as value_range.
§Example
use radiate_core::*;
// Create a new FloatGene with a min value of 0 and a max value of 1 meaning the
// allele will be a random number between 0 and 1.
// The upper_bound and lower_bound are set to 0 and 1 respectively.
let gene = FloatGene::from(0_f32..1_f32);
// Create a new FloatGene with a min of 0 and a max of 1 and set the upper_bound
// and lower_bound to 0 and 100 respectively.
let gene = FloatGene::from((0_f32..1_f32, 0_f32..100_f32));Implementations§
Trait Implementations§
Source§impl<F> ArithmeticGene for FloatGene<F>where
F: Float,
impl<F> ArithmeticGene for FloatGene<F>where
F: Float,
Source§impl<F> BoundedGene for FloatGene<F>where
F: Float,
impl<F> BoundedGene for FloatGene<F>where
F: Float,
Source§impl<F> From<FloatGene<F>> for FloatChromosome<F>where
F: Float,
impl<F> From<FloatGene<F>> for FloatChromosome<F>where
F: Float,
Source§fn from(gene: FloatGene<F>) -> FloatChromosome<F>
fn from(gene: FloatGene<F>) -> FloatChromosome<F>
Converts to this type from the input type.
Source§impl<F> FromIterator<FloatGene<F>> for FloatChromosome<F>where
F: Float,
impl<F> FromIterator<FloatGene<F>> for FloatChromosome<F>where
F: Float,
Source§fn from_iter<I>(iter: I) -> FloatChromosome<F>where
I: IntoIterator<Item = FloatGene<F>>,
fn from_iter<I>(iter: I) -> FloatChromosome<F>where
I: IntoIterator<Item = FloatGene<F>>,
Creates a value from an iterator. Read more
Source§impl<F> Gene for FloatGene<F>where
F: Float,
impl<F> Gene for FloatGene<F>where
F: Float,
Source§impl<F> PartialEq for FloatGene<F>
impl<F> PartialEq for FloatGene<F>
impl<F> StructuralPartialEq for FloatGene<F>
Source§impl<F> Valid for FloatGene<F>where
F: Float,
impl<F> Valid for FloatGene<F>where
F: Float,
The is_valid method checks if the allele of the FloatGene is between the min and max values.
The GeneticEngine will check the validity of the Chromosome and Phenotype and remove any
invalid individuals from the population, replacing them with new individuals at the given generation.
Auto Trait Implementations§
impl<F> Freeze for FloatGene<F>where
F: Freeze,
impl<F> RefUnwindSafe for FloatGene<F>where
F: RefUnwindSafe,
impl<F> Send for FloatGene<F>where
F: Send,
impl<F> Sync for FloatGene<F>where
F: Sync,
impl<F> Unpin for FloatGene<F>where
F: Unpin,
impl<F> UnsafeUnpin for FloatGene<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for FloatGene<F>where
F: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<G, T> NumericGene for Gwhere
G: Gene<Allele = T>,
T: NumericAllele,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more