pub struct RandomKeyChromosome {
pub keys: Vec<f64>,
/* private fields */
}Expand description
Random-key chromosome for BRKGA.
Each gene is a floating-point value in [0, 1) that represents a random key. The decoder interprets these keys to construct a solution.
Fields§
§keys: Vec<f64>Random keys in [0, 1).
Implementations§
Source§impl RandomKeyChromosome
impl RandomKeyChromosome
Sourcepub fn set_fitness(&mut self, fitness: f64)
pub fn set_fitness(&mut self, fitness: f64)
Sets the fitness value.
Sourcepub fn biased_crossover<R: Rng>(
&self,
other: &Self,
elite_bias: f64,
rng: &mut R,
) -> Self
pub fn biased_crossover<R: Rng>( &self, other: &Self, elite_bias: f64, rng: &mut R, ) -> Self
Biased crossover with another chromosome.
For each gene, there’s an elite_bias probability of inheriting
from self (the elite parent) and 1 - elite_bias from other.
Sourcepub fn decode_as_permutation(&self) -> Vec<usize>
pub fn decode_as_permutation(&self) -> Vec<usize>
Decodes the random keys into a permutation (sorted indices by key value).
This is the most common decoding: sort items by their random keys to get a placement order.
Sourcepub fn decode_as_discrete(&self, key_idx: usize, num_options: usize) -> usize
pub fn decode_as_discrete(&self, key_idx: usize, num_options: usize) -> usize
Decodes a subset of keys as discrete values in a range.
For example, to decode orientation (0-5), use:
decode_as_discrete(key_idx, 6) which maps [0, 1) to {0, 1, 2, 3, 4, 5}.
Trait Implementations§
Source§impl Clone for RandomKeyChromosome
impl Clone for RandomKeyChromosome
Source§fn clone(&self) -> RandomKeyChromosome
fn clone(&self) -> RandomKeyChromosome
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 moreAuto Trait Implementations§
impl Freeze for RandomKeyChromosome
impl RefUnwindSafe for RandomKeyChromosome
impl Send for RandomKeyChromosome
impl Sync for RandomKeyChromosome
impl Unpin for RandomKeyChromosome
impl UnwindSafe for RandomKeyChromosome
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§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 moreSource§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).Source§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.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.