pub struct Mutation {
pub point_rate: f64,
pub crossover: CrossoverMethod,
pub crossover_rate: f64,
}Expand description
Mutation configuration.
Fields§
§point_rate: f64Probability of point mutation per position.
crossover: CrossoverMethodCrossover method.
crossover_rate: f64Crossover probability (if not crossed over, child = clone of parent).
Implementations§
Source§impl Mutation
impl Mutation
Sourcepub fn default_rates() -> Self
pub fn default_rates() -> Self
Default mutation: 1% point mutation rate, single-point crossover at 70%.
Sourcepub fn point_mutate(&self, agent: &mut TernaryAgent, rng: &mut SimpleRng)
pub fn point_mutate(&self, agent: &mut TernaryAgent, rng: &mut SimpleRng)
Apply point mutation to a single agent (modifies in place).
Each position has point_rate chance of being randomly changed.
Sourcepub fn crossover(
&self,
parent_a: &TernaryAgent,
parent_b: &TernaryAgent,
rng: &mut SimpleRng,
) -> (TernaryAgent, TernaryAgent)
pub fn crossover( &self, parent_a: &TernaryAgent, parent_b: &TernaryAgent, rng: &mut SimpleRng, ) -> (TernaryAgent, TernaryAgent)
Crossover two parents to produce two children.
Sourcepub fn mutate(&self, agent: &mut TernaryAgent, rng: &mut SimpleRng)
pub fn mutate(&self, agent: &mut TernaryAgent, rng: &mut SimpleRng)
Apply mutation (point mutation) to an agent.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mutation
impl RefUnwindSafe for Mutation
impl Send for Mutation
impl Sync for Mutation
impl Unpin for Mutation
impl UnsafeUnpin for Mutation
impl UnwindSafe for Mutation
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