+/GENN
genetically evolving neural networks
git clone https://git.julia.blue/+/GENN
cc48e92
master
1#ifndef GENN_NEAT_H 2#define GENN_NEAT_H 3 4#include "Genome.h" 5#include <time.h> 6#include <cstdlib> 7#include <array> 8#include <algorithm> 9#include <fstream> 10#include <iostream> 11 12 13struct Species { 14std ::vector < Genome *> genomes ; 15int staleness = 0 ; 16double maxFitness = 0 ; 17 18static bool compare (const Species & a ,const Species & b ) {return a .genomes [0 ]-> fitness > b .genomes [0 ]-> fitness ; } 19}; 20 21class NEAT { 22private : 23double m [7 ]; 24 25std ::vector < std ::array < int ,2 >>innovation ; 26 27std ::vector < Species > species ; 28 29int population ,staleThreshold ,generation ,maxSpecies ; 30 31double c1 ,c2 ,c3 ,distanceThreshold ,maxFitness ; 32 33std ::ofstream f ; 34 35void adjustFitness (); 36 37void log (); 38 39void status (); 40 41void cull (); 42 43void repopulate (); 44 45void classify (); 46 47double distance (Genome ,Genome ); 48 49Genome mate (Genome * ,Genome * ); 50 51void mutate (Genome & ); 52 53int newInnovation (int a ,int b ); 54 55int findInnovation (int a ,int b ); 56 57void labelInnovations (Genome & ); 58 59public : 60NEAT (int inputs ,int outputs ); 61 62void nextGen (); 63 64std ::vector < Genome > pool ; 65}; 66 67#endif //GENN_NEAT_H