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 canonical (higher is better), matching all other strategies in this crate. A maximisation benchmark like OneMax (count_ones(genome)) plugs in directly; a cost objective is reconciled into canonical space by the harness/adapter chokepoint rather than hand-negated here.

§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.