pub struct RealVector { /* private fields */ }Expand description
Fixed-length real-valued vector genome
This genome type represents continuous optimization problems where solutions are vectors of real numbers.
Implementations§
Source§impl RealVector
impl RealVector
Sourcepub fn filled(dimension: usize, value: f64) -> Self
pub fn filled(dimension: usize, value: f64) -> Self
Create a vector filled with a constant value
Sourcepub fn collect_from<I: IntoIterator<Item = f64>>(iter: I) -> Self
pub fn collect_from<I: IntoIterator<Item = f64>>(iter: I) -> Self
Create from an iterator
Sourcepub fn into_inner(self) -> Vec<f64>
pub fn into_inner(self) -> Vec<f64>
Get the underlying vector
Sourcepub fn norm_squared(&self) -> f64
pub fn norm_squared(&self) -> f64
Calculate squared Euclidean norm
Sourcepub fn add(&self, other: &Self) -> Result<Self, GenomeError>
pub fn add(&self, other: &Self) -> Result<Self, GenomeError>
Element-wise addition
Sourcepub fn sub(&self, other: &Self) -> Result<Self, GenomeError>
pub fn sub(&self, other: &Self) -> Result<Self, GenomeError>
Element-wise subtraction
Trait Implementations§
Source§impl BoundedCrossoverOperator<RealVector> for SbxCrossover
impl BoundedCrossoverOperator<RealVector> for SbxCrossover
Source§fn crossover_bounded<R: Rng>(
&self,
parent1: &RealVector,
parent2: &RealVector,
bounds: &MultiBounds,
rng: &mut R,
) -> OperatorResult<(RealVector, RealVector)>
fn crossover_bounded<R: Rng>( &self, parent1: &RealVector, parent2: &RealVector, bounds: &MultiBounds, rng: &mut R, ) -> OperatorResult<(RealVector, RealVector)>
Apply bounded crossover to two parents
Source§impl BoundedMutationOperator<RealVector> for GaussianMutation
impl BoundedMutationOperator<RealVector> for GaussianMutation
Source§fn mutate_bounded<R: Rng>(
&self,
genome: &mut RealVector,
bounds: &MultiBounds,
rng: &mut R,
)
fn mutate_bounded<R: Rng>( &self, genome: &mut RealVector, bounds: &MultiBounds, rng: &mut R, )
Apply bounded mutation to a genome
Source§impl BoundedMutationOperator<RealVector> for PolynomialMutation
impl BoundedMutationOperator<RealVector> for PolynomialMutation
Source§fn mutate_bounded<R: Rng>(
&self,
genome: &mut RealVector,
bounds: &MultiBounds,
rng: &mut R,
)
fn mutate_bounded<R: Rng>( &self, genome: &mut RealVector, bounds: &MultiBounds, rng: &mut R, )
Apply bounded mutation to a genome
Source§impl BoundedMutationOperator<RealVector> for UniformMutation
impl BoundedMutationOperator<RealVector> for UniformMutation
Source§fn mutate_bounded<R: Rng>(
&self,
genome: &mut RealVector,
bounds: &MultiBounds,
rng: &mut R,
)
fn mutate_bounded<R: Rng>( &self, genome: &mut RealVector, bounds: &MultiBounds, rng: &mut R, )
Apply bounded mutation to a genome
Source§impl Clone for RealVector
impl Clone for RealVector
Source§fn clone(&self) -> RealVector
fn clone(&self) -> RealVector
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl CrossoverOperator<RealVector> for ArithmeticCrossover
impl CrossoverOperator<RealVector> for ArithmeticCrossover
Source§fn crossover<R: Rng>(
&self,
parent1: &RealVector,
parent2: &RealVector,
_rng: &mut R,
) -> OperatorResult<(RealVector, RealVector)>
fn crossover<R: Rng>( &self, parent1: &RealVector, parent2: &RealVector, _rng: &mut R, ) -> OperatorResult<(RealVector, RealVector)>
Apply crossover to two parents and produce two offspring
Source§fn crossover_probability(&self) -> f64
fn crossover_probability(&self) -> f64
Get the probability of crossover being applied
Source§impl CrossoverOperator<RealVector> for BlxAlphaCrossover
impl CrossoverOperator<RealVector> for BlxAlphaCrossover
Source§fn crossover<R: Rng>(
&self,
parent1: &RealVector,
parent2: &RealVector,
rng: &mut R,
) -> OperatorResult<(RealVector, RealVector)>
fn crossover<R: Rng>( &self, parent1: &RealVector, parent2: &RealVector, rng: &mut R, ) -> OperatorResult<(RealVector, RealVector)>
Apply crossover to two parents and produce two offspring
Source§fn crossover_probability(&self) -> f64
fn crossover_probability(&self) -> f64
Get the probability of crossover being applied
Source§impl CrossoverOperator<RealVector> for SbxCrossover
impl CrossoverOperator<RealVector> for SbxCrossover
Source§fn crossover<R: Rng>(
&self,
parent1: &RealVector,
parent2: &RealVector,
rng: &mut R,
) -> OperatorResult<(RealVector, RealVector)>
fn crossover<R: Rng>( &self, parent1: &RealVector, parent2: &RealVector, rng: &mut R, ) -> OperatorResult<(RealVector, RealVector)>
Apply crossover to two parents and produce two offspring
Source§fn crossover_probability(&self) -> f64
fn crossover_probability(&self) -> f64
Get the probability of crossover being applied
Source§impl Debug for RealVector
impl Debug for RealVector
Source§impl<'de> Deserialize<'de> for RealVector
impl<'de> Deserialize<'de> for RealVector
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl EvolutionaryGenome for RealVector
impl EvolutionaryGenome for RealVector
Source§fn to_trace(&self) -> Trace
fn to_trace(&self) -> Trace
Convert RealVector to Fugue trace.
Each gene is stored at address “gene#i” where i is the index.
Source§fn from_trace(trace: &Trace) -> Result<Self, GenomeError>
fn from_trace(trace: &Trace) -> Result<Self, GenomeError>
Reconstruct RealVector from Fugue trace.
Reads genes from addresses “gene#0”, “gene#1”, … until no more are found.
Source§fn generate<R: Rng>(rng: &mut R, bounds: &MultiBounds) -> Self
fn generate<R: Rng>(rng: &mut R, bounds: &MultiBounds) -> Self
Generate a random genome within the given bounds
Source§fn as_mut_slice(&mut self) -> Option<&mut [f64]>
fn as_mut_slice(&mut self) -> Option<&mut [f64]>
Get the genome’s genes as a mutable slice (for numeric genomes)
Source§fn trace_prefix() -> &'static str
fn trace_prefix() -> &'static str
Get the address prefix used for trace storage (default: “gene”)
Source§impl From<RealVector> for Vec<f64>
impl From<RealVector> for Vec<f64>
Source§fn from(genome: RealVector) -> Self
fn from(genome: RealVector) -> Self
Converts to this type from the input type.
Source§impl Index<usize> for RealVector
impl Index<usize> for RealVector
Source§impl IndexMut<usize> for RealVector
impl IndexMut<usize> for RealVector
Source§impl<'a> IntoIterator for &'a RealVector
impl<'a> IntoIterator for &'a RealVector
Source§impl IntoIterator for RealVector
impl IntoIterator for RealVector
Source§impl MutationOperator<RealVector> for GaussianMutation
impl MutationOperator<RealVector> for GaussianMutation
Source§fn mutate<R: Rng>(&self, genome: &mut RealVector, rng: &mut R)
fn mutate<R: Rng>(&self, genome: &mut RealVector, rng: &mut R)
Apply mutation to a genome in place
Source§fn mutation_probability(&self) -> f64
fn mutation_probability(&self) -> f64
Get the mutation probability per gene
Source§impl MutationOperator<RealVector> for PolynomialMutation
impl MutationOperator<RealVector> for PolynomialMutation
Source§fn mutate<R: Rng>(&self, genome: &mut RealVector, rng: &mut R)
fn mutate<R: Rng>(&self, genome: &mut RealVector, rng: &mut R)
Apply mutation to a genome in place
Source§fn mutation_probability(&self) -> f64
fn mutation_probability(&self) -> f64
Get the mutation probability per gene
Source§impl MutationOperator<RealVector> for ScrambleMutation
impl MutationOperator<RealVector> for ScrambleMutation
Source§fn mutate<R: Rng>(&self, genome: &mut RealVector, rng: &mut R)
fn mutate<R: Rng>(&self, genome: &mut RealVector, rng: &mut R)
Apply mutation to a genome in place
Source§fn mutation_probability(&self) -> f64
fn mutation_probability(&self) -> f64
Get the mutation probability per gene
Source§impl MutationOperator<RealVector> for SwapMutation
impl MutationOperator<RealVector> for SwapMutation
Source§fn mutate<R: Rng>(&self, genome: &mut RealVector, rng: &mut R)
fn mutate<R: Rng>(&self, genome: &mut RealVector, rng: &mut R)
Apply mutation to a genome in place
Source§fn mutation_probability(&self) -> f64
fn mutation_probability(&self) -> f64
Get the mutation probability per gene
Source§impl MutationOperator<RealVector> for UniformMutation
impl MutationOperator<RealVector> for UniformMutation
Source§fn mutate<R: Rng>(&self, genome: &mut RealVector, rng: &mut R)
fn mutate<R: Rng>(&self, genome: &mut RealVector, rng: &mut R)
Apply mutation to a genome in place
Source§fn mutation_probability(&self) -> f64
fn mutation_probability(&self) -> f64
Get the mutation probability per gene
Source§impl PartialEq for RealVector
impl PartialEq for RealVector
Source§impl RealValuedGenome for RealVector
impl RealValuedGenome for RealVector
Source§fn from_genes(genes: Vec<f64>) -> Result<Self, GenomeError>
fn from_genes(genes: Vec<f64>) -> Result<Self, GenomeError>
Create from a vector of genes
Source§fn apply_bounds(&mut self, bounds: &MultiBounds)
fn apply_bounds(&mut self, bounds: &MultiBounds)
Apply bounds to all genes
Source§impl Serialize for RealVector
impl Serialize for RealVector
impl StructuralPartialEq for RealVector
Auto Trait Implementations§
impl Freeze for RealVector
impl RefUnwindSafe for RealVector
impl Send for RealVector
impl Sync for RealVector
impl Unpin for RealVector
impl UnsafeUnpin for RealVector
impl UnwindSafe for RealVector
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.