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

NEAT's own generational evolutionary loop: fitness evaluation, speciation, fitness sharing, proportional offspring allocation, and mutation-only reproduction. More...

#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>
#include <random>
#include <stdexcept>
#include <vector>
#include "pulsatrix/neat_genome.hpp"
#include "pulsatrix/neat_speciation.hpp"
Include dependency graph for neat_evolution.hpp:

Go to the source code of this file.

Classes

struct  pulsatrix::NEATEvolutionResult
 Result of a full NEAT evolutionary run. More...
 

Namespaces

namespace  pulsatrix
 

Functions

std::vector< int > pulsatrix::AllocateOffspringCounts (const std::vector< double > &species_adjusted_fitness_sums, int population_size)
 Pure core: allocates population_size offspring slots across species proportionally to each species' own adjusted-fitness sum, using the largest-remainder (Hamilton) apportionment method so the total always sums to exactly population_size (ties in fractional remainder broken by species index, earliest first). Falls back to an equal split (remainder to the earliest species, by index) if every species sum is non-positive, rather than dividing by zero.
 
template<typename RNG >
NEATGenome pulsatrix::ReproduceOffspring (const NEATGenome &parent, InnovationTracker &tracker, RNG &rng, double weight_mutation_sigma, double weight_mutation_probability, double add_connection_probability, double add_node_probability)
 RNG-driven wrapper: clones parent, then applies weight mutation (gated per-connection by weight_mutation_probability inside MutateWeights itself) and, independently, one attempt each at the two structural mutations, each gated by its own probability.
 
template<typename FitnessFn , typename RNG >
NEATEvolutionResult pulsatrix::RunNEATEvolution (std::vector< NEATGenome > population, FitnessFn fitness_fn, int num_generations, double compatibility_threshold, double c1, double c2, double c3, double weight_mutation_sigma, double weight_mutation_probability, double add_connection_probability, double add_node_probability, InnovationTracker &tracker, RNG &rng)
 Runs num_generations of speciated, mutation-only NEAT evolution. Each generation: evaluates every genome's fitness via fitness_fn, tracks the best genome seen across the whole run so far (global elitism – best_fitness never decreases generation to generation), speciates the population, applies fitness sharing, allocates each species a share of the next generation proportional to its adjusted-fitness sum, and fills that share with one unmutated species-champion copy plus mutated copies of uniformly-randomly chosen species members.
 

Detailed Description

NEAT's own generational evolutionary loop: fitness evaluation, speciation, fitness sharing, proportional offspring allocation, and mutation-only reproduction.

Note
Crossover between two genomes is deliberately NOT built here – a logged scope cut matching Mission 0/1's own notes (the innovation-tracking system exists to eventually support it, but it remains a future mission's concern). Reproduction in this file is therefore mutation-only: clone a parent, then apply weight and/or structural mutation. This is a real scope reduction from NEAT's own original design (which uses crossover as its primary variation operator), not an oversight.