-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeneticAlgorithm.h
38 lines (27 loc) · 989 Bytes
/
GeneticAlgorithm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef GALGORITHM_H
#define GALGORITHM_H
#include "Population.h"
class GeneticAlgorithm {
public:
GeneticAlgorithm(int, double, double, int);
/* Population size, mutation rate, crossover rate, elitism */
Population* makePopulation(int);
/* Input: Desired length of chromosomes */
double calcFitness(Individual*);
/* Calculate the fitness of an individual */
/* Called by evalPopulation() */
void evalPopulation(Population*);
/* Calls calcFitness on every individual */
Population* mutatePopulation(Population*);
/* Mutate population when appropriate */
bool isTerminationConditionMet(Population*);
/* Tests each individual for sufficient fitness */
Individual* selectParent(Population*);
Population* crossoverPopulation(Population*);
private:
int populationSize;
double mutationRate;
double crossoverRate;
int elitismCount;
};
#endif