|
pulsatrix
|
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"
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. | |
Genetic-algorithm selection operators (tournament, roulette/fitness-proportionate, linear-rank) over a population of Individual<Genotype, FitnessT>.