pulsatrix
Loading...
Searching...
No Matches
selection.hpp File Reference

Genetic-algorithm selection operators (tournament, roulette/fitness-proportionate, linear-rank) over a population of Individual<Genotype, FitnessT>. More...

#include <algorithm>
#include <numeric>
#include <random>
#include <stdexcept>
#include <vector>
#include "pulsatrix/assert.hpp"
#include "pulsatrix/individual.hpp"
Include dependency graph for selection.hpp:

Go to the source code of this file.

Namespaces

namespace  pulsatrix
 

Functions

template<typename Genotype , typename FitnessT , typename RNG >
size_t pulsatrix::TournamentSelect (const std::vector< Individual< Genotype, FitnessT > > &population, size_t tournament_size, RNG &rng)
 Tournament selection: draw tournament_size individuals without replacement from population and return the index of the fittest among them.
 
template<typename Genotype , typename FitnessT >
size_t pulsatrix::RouletteSelectByDraw (const std::vector< Individual< Genotype, FitnessT > > &population, FitnessT draw)
 Fitness-proportionate ("roulette wheel") selection given an explicit draw in [0, total_fitness). Pure and deterministic – the hand-testable core RouletteSelect wraps with an RNG-generated draw.
 
template<typename Genotype , typename FitnessT , typename RNG >
size_t pulsatrix::RouletteSelect (const std::vector< Individual< Genotype, FitnessT > > &population, RNG &rng)
 RNG-driven wrapper around RouletteSelectByDraw: draws uniformly from [0, total_fitness) and selects accordingly.
 
template<typename Genotype , typename FitnessT >
size_t pulsatrix::RankSelectByDraw (const std::vector< Individual< Genotype, FitnessT > > &population, double draw)
 Linear-rank selection given an explicit draw in [0, total_weight). Individuals are ranked ascending by fitness (worst = rank 1, best = rank population.size()); each rank's selection weight equals its rank, so the best individual is population.size() times as likely to be drawn as the worst. Pure and deterministic – the hand-testable core RankSelect wraps with an RNG-generated draw.
 
template<typename Genotype , typename FitnessT , typename RNG >
size_t pulsatrix::RankSelect (const std::vector< Individual< Genotype, FitnessT > > &population, RNG &rng)
 RNG-driven wrapper around RankSelectByDraw: draws uniformly from [0, total_weight) and selects accordingly.
 

Detailed Description

Genetic-algorithm selection operators (tournament, roulette/fitness-proportionate, linear-rank) over a population of Individual<Genotype, FitnessT>.

Note
All three operators assume higher fitness is better (maximization) – the same convention as DEAP's own weights=(1.0,) FitnessMax default (research doc research_2026_evolutionary_deep_learning.md, campaign campaign_exai_dl_library_evolutionary_deep_learning, Phase 1 Mission 0).
Each stochastic operator (TournamentSelect, RouletteSelect, RankSelect) is a thin RNG-driven wrapper around a pure, deterministic core (RouletteSelectByDraw, RankSelectByDraw) or is itself exactly reproducible given its RNG stream (TournamentSelect) – this is what makes each operator's correctness hand-derivable/closed-form testable independent of any particular RNG's internal implementation, per this project's TDD discipline.