Genetic algorithms used to produce fit neural networks. More...
#include <GeneticAlgo.h>
Public Member Functions | |
GeneticAlgo (unsigned int populationSize_, float mutationRate_, float crossoverRate_, int numberOfElitismCopies_, std::vector< double >(*getPopulationFitness_)(const std::vector< net::NeuralNet > &neuralNet)) | |
Initializes a genetic algorithm with the necessary parameters. More... | |
net::NeuralNet | getBestNeuralNetwork (int numberOfGenerations, net::NeuralNet modelNetwork) |
Returns the most fit neural network in a population that undergoes a specified number of generations. More... | |
Genetic algorithms used to produce fit neural networks.
GeneticAlgo::GeneticAlgo | ( | unsigned int | populationSize_, |
float | mutationRate_, | ||
float | crossoverRate_, | ||
int | numberOfElitismCopies_, | ||
std::vector< double >(*)(const std::vector< net::NeuralNet > &neuralNet) | getPopulationFitness_ | ||
) |
Initializes a genetic algorithm with the necessary parameters.
populationSize_ | the number of neural networks in the population for each generation |
mutationRate_ | the chance between 0 and 1 that a weight in a neural network will be mutated |
crossoverRate_ | the chance between 0 and 1 that a couple will produce offspring having a fused verion of their parents' networks, instead of offspring that have the same neural networks as their parents; if set to 0, the population's composition will only change as a result of mutations. |
numberOfElitismCopies_ | the number of times that best neural network from the past generation shows up in the current generation |
getPopulationFitness_ | a function that returns a vector of doubles housing the fitness of every individual in the population, when given the population of neural networks |
net::NeuralNet GeneticAlgo::getBestNeuralNetwork | ( | int | numberOfGenerations, |
net::NeuralNet | modelNetwork | ||
) |
Returns the most fit neural network in a population that undergoes a specified number of generations.
numberOfGenerations | the number of generations that the simulation will run for; in each generation, fitnesses are assigned, mating occurs, and offspring are added |
modelNetwork | used to determine the architecuture of the neural networks in the population,. |