mc2lib
|
Helper to manages and evolve a populates. More...
#include <simplega.hpp>
Public Types | |
typedef std::list< GenomeT > | Population |
typedef std::vector< GenomeT * > | Selection |
Public Member Functions | |
GenePool (std::size_t target_population_size=80, float mutation_rate=0.02f) | |
GenePool (Population population, float mutation_rate=0.02f) | |
GenePool (Selection selection, float mutation_rate=0.02f) | |
operator std::string () const | |
const Population & | get () const |
Population * | get_ptr () |
float | mutation_rate () const |
void | set_mutation_rate (float mutation_rate) |
std::size_t | target_population_size () const |
std::size_t | population_size () const |
std::size_t | steps () const |
float | AverageFitness () const |
float | WorstFitness () const |
float | BestFitness () const |
void | Sort () |
const GenomeT & | SelectBest () const |
Selection | SelectAll () |
template<class URNG , class DIST > | |
Selection | SelectDist (URNG &urng, DIST &dist, std::size_t count) |
template<class URNG > | |
Selection | SelectRoulette (URNG &urng, std::size_t count) |
template<class URNG > | |
Selection | SelectUniform (URNG &urng, std::size_t count) |
void | SelectionSort (Selection *v) |
template<class URNG , class CrossoverMutateFunc > | |
void | Step (URNG &urng, CrossoverMutateFunc crossover_mutate, const Selection &selection, std::size_t mates, std::size_t keep=0, std::size_t mate1_stride=1, std::size_t mate2_stride=1) |
Protected Attributes | |
std::size_t | target_population_size_ |
float | mutation_rate_ |
std::size_t | steps_ |
Population | population_ |
Helper to manages and evolve a populates.
Helps manage and evolve a population, and provides various primitives for implementing selection operators.
typedef std::list<GenomeT> mc2lib::simplega::GenePool< GenomeT >::Population |
Using a list for the population pool, as this permits O(1) removal of elements.
typedef std::vector<GenomeT*> mc2lib::simplega::GenePool< GenomeT >::Selection |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Sorts (in-place) a Selection based on fitness.
|
inline |
|
inline |
|
inline |
|
inline |
Sorts (in-place) the population based on fitness.
|
inline |
Takes a selection and mates the initial selection[:mates] individuals.
The elements in selection also determine which individuals are to be removed from the population; selection[keep:] are removed from population (can e.g. be used for elitism).
|
inline |
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |