Skip to main content

Module operators

Module operators 

Source
Expand description

Variation operators: the genome-agnostic traits (Initializer, Mutation, Crossover, Repair, Selection), closure adapters, combinators, and ready-made operators per representation in the submodules.

Every trait method is generic over the generator, which keeps the hot path monomorphised; closures are accepted through *_fn adapters that receive &mut dyn Rng.

ModuleGenome
realVec<f64> within Bounds
discretebit strings Vec<bool> and integer strings Vec<u32>
permutationpermutations Vec<usize> of 0..n
sequenceany Vec<T>: fixed-length crossovers
chainGLEAM action chains: variable-length Vec<T> and parameterised actions
selectionparent selection over a cost slice

Re-exports§

pub use selection::Selection;

Modules§

chain
GLEAM action chains (Blume and Jakob; Jakob 2021): variable-length chromosomes of typed, parameterised actions, with gene-level and chain-level mutations and crossovers that accept parents of different lengths.
discrete
Operators for bit strings Vec<bool> and integer strings Vec<u32> with per-gene domains: random initialisation, bit flips, random reset and creep mutation. Crossovers for both live in sequence.
permutation
Operators for permutations Vec<usize> of 0..n: swap, insertion, inversion and scramble mutation; partially mapped (PMX), order (OX), cycle (CX) and edge recombination (ERX) crossover. Every operator maps permutations to permutations (property-tested).
real
Operators for real vectors Vec<f64>: box Bounds, uniform and Latin hypercube initialisation, Gaussian, polynomial and uniform-reset mutation, SBX, BLX-α and arithmetic crossover, and clamping or reflecting repair.
selection
Parent selection over a slice of costs (smaller is better): tournament, truncation, fitness-proportional, linear ranking, stochastic universal sampling and uniform.
sequence
Positional crossovers for any Vec<T>: one-point, two-point and uniform. They also accept parents of different lengths: cut points lie within the shorter parent and tails are exchanged whole, so lengths are swapped, never invented.

Structs§

CrossoverFn
A closure used as a Crossover; created by crossover_fn.
InitializerFn
A closure used as an Initializer; created by initializer_fn.
Mix
Applies a with probability weight_a / (weight_a + weight_b), otherwise b; the building block of GLEAM-style operator mixes. Nest it for more than two operators, or use mix.
MutationFn
A closure used as a Mutation; created by mutation_fn.
NoCrossover
The crossover that returns copies of the parents, for mutation-only runs.
NoMutation
The mutation that changes nothing, for crossover-only or selection-only runs.
NoRepair
The repair that changes nothing.
RepairFn
A closure used as a Repair; created by repair_fn.
Seeded
An initialiser that yields caller-supplied seed genomes first (for example previous plans or heuristic solutions), then falls back to inner.
Sometimes
Applies inner with probability probability, otherwise leaves the genome unchanged.
Then
Applies first, then second.
Variation
The variation operators of algorithms that bring their own selection (NSGA-II, NSGA-III, MOEA/D, MAP-Elites): initialisation, crossover, mutation and repair.

Traits§

Crossover
Produces two children from two parents.
Initializer
Creates random genomes for an initial population.
Mutation
Changes one genome in place.
Repair
Makes a genome valid again after variation (genotypic repair).

Functions§

crossover_fn
Turns a closure FnMut(&G, &G, &mut dyn Rng) -> [G; 2] into a Crossover.
initializer_fn
Turns a closure FnMut(&mut dyn Rng) -> G into an Initializer.
mix
Creates a Mix choosing a and b in proportion to their (non-negative) weights.
mutation_fn
Turns a closure FnMut(&mut G, &mut dyn Rng) into a Mutation.
repair_fn
Turns a closure FnMut(&mut G, &mut dyn Rng) into a Repair.