pub struct FloatGene<F: Float> { /* private fields */ }Expand description
Minimum and maximum values for the FloatGene allele.
This should be large enough to cover most practical use cases
but small enough to avoid overflow or underflow issues in calculations.
1e18 = 1 quintillion
A Gene that represents a floating point number.
The allele is the in the case of the FloatGene a f32. The min and max values
default to [MIN] and [MAX] respectively. The min and max values are used to
generate a random number between the min and max values, which is the allele of the FloatGene.
The upper_bound and lower_bound are used to set the bounds of the FloatGene when it is used
in a BoundGene context (crossover or mutation). The upper_bound and lower_bound
default to [MAX] and [MIN] respectively.
§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: Float> ArithmeticGene for FloatGene<F>
impl<F: Float> ArithmeticGene for FloatGene<F>
Source§impl<F: Float> BoundedGene for FloatGene<F>
impl<F: Float> BoundedGene for FloatGene<F>
Source§impl<F: Float> FromIterator<FloatGene<F>> for FloatChromosome<F>
impl<F: Float> FromIterator<FloatGene<F>> for FloatChromosome<F>
Source§impl<F: Float> Gene for FloatGene<F>
impl<F: Float> Gene for FloatGene<F>
Source§impl<F: Float> Valid for FloatGene<F>
impl<F: Float> Valid for FloatGene<F>
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.
impl<F: Float> StructuralPartialEq for FloatGene<F>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more