+/GENN
genetically evolving neural networks
git clone https://git.julia.blue/+/GENN
eb6e103
v0.2
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 13class Species { 14public : 15std ::vector < Genome *> genomes ; 16int staleness = 0 ; 17double maxFitness = 0 ; 18static bool compare (Species a ,Species b ) {return (a .maxFitness > b .maxFitness ); } 19}; 20 21class NEAT { 22private : 23std ::vector < std ::array < int ,2 >>innovation ; 24 25std ::vector < Species > species ; 26 27int population ,staleThreshold ,generation ,maxSpecies ; 28 29double c1 ,c2 ,c3 ,distanceThreshold ; 30 31std ::ofstream f ; 32 33public : 34NEAT (int inputs ,int outputs ); 35 36 ~NEAT (); 37 38void config ();//for setting constants like gen size and mutation rates 39 40void classify (); 41 42void cull (); 43 44void status (); 45 46void adjustFitness (); 47 48void log (); 49 50double distance (Genome * ,Genome * ); 51 52//staleness hurts chances unless at the top 53Genome * mate (Genome * ,Genome * ); 54 55bool innovationExists (int a ,int b ); 56 57int newInnovation (int a ,int b ); 58 59void mutate (Genome & ); 60 61std ::vector < Genome *> pool ; 62 63void repopulate (); 64 65void nextGen (); 66}; 67 68#endif //GENN_NETWORK_H