Skip to main content

MutationOperator

Trait MutationOperator 

Source
pub trait MutationOperator<G: EvolutionaryGenome>: Send + Sync {
    // Required method
    fn mutate<R: Rng>(&self, genome: &mut G, rng: &mut R);

    // Provided method
    fn mutation_probability(&self) -> Option<f64> { ... }
}
Expand description

Mutation operator trait

Applies random changes to a genome.

Required Methods§

Source

fn mutate<R: Rng>(&self, genome: &mut G, rng: &mut R)

Apply mutation to a genome in place

Provided Methods§

Source

fn mutation_probability(&self) -> Option<f64>

Report the per-gene mutation probability actually applied by this operator.

Returns None when the operator uses a genome-length-dependent default (the canonical 1/n per-gene rate) that cannot be expressed as a single constant here — this is the honest signal that the effective rate is 1 / genome.len(), not the misleading 1.0 this method used to report (audit EV-103). Operators that always act on the whole genome (or have no per-gene rate) return Some(1.0).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§