Skip to main content

Module ga_binary

Module ga_binary 

Source
Expand description

Binary-coded Genetic Algorithm.

A canonical GA over Tensor<B, 2, Int> populations where every gene is restricted to {0, 1}:

  1. Evaluate the current population (done externally by the harness).
  2. Select two independent sets of parents via crate::ops::selection::tournament_indices_host (k-tournament).
  3. Recombine via crate::ops::crossover::binary_uniform_crossover (per-gene coin flip with probability crossover_p).
  4. Mutate via crate::ops::mutation::bit_flip_mutation (per-gene flip with probability mutation_rate).
  5. Replace via fixed elitist policy: the elitism_k best parents survive; the remaining pop_size − elitism_k slots are filled by the best offspring.

Unlike crate::algorithms::ga::GeneticAlgorithm, there is no enum-selectable replacement policy — only elitist replacement is supported. Extend BinaryGaConfig and the tell impl if a generational variant is needed.

All random draws go through crate::rng::seed_stream — never B::seed + Tensor::random — so per-run results are reproducible across thread schedules.

§Fitness convention

Fitness is treated as cost (lower is better), matching all other strategies in this crate. Maximization benchmarks like OneMax must be phrased as minimization before being plugged in, e.g.: cost = D − count_ones(genome).

§References

  • Holland (1975), Adaptation in Natural and Artificial Systems.
  • Goldberg (1989), Genetic Algorithms in Search, Optimization, and Machine Learning.

Structs§

BinaryGaConfig
Static configuration for a BinaryGeneticAlgorithm run.
BinaryGaState
State for BinaryGeneticAlgorithm.
BinaryGeneticAlgorithm
Binary-coded canonical Genetic Algorithm.