-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneticAlgorithmClass.h
More file actions
49 lines (36 loc) · 1.31 KB
/
GeneticAlgorithmClass.h
File metadata and controls
49 lines (36 loc) · 1.31 KB
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
39
40
41
42
43
44
45
46
47
48
49
// ************************************************************************ //
// This class contains all functionality to run a genetic algorithm on a
// population of ChromosomeClass objects
// ************************************************************************ //
#ifndef _GENETICALGORITHM_H_
#define _GENETICALGORITHM_H_
#include "ChromosomeClass.h"
#include "ParameterClass.h"
class GeneticAlgorithmClass
{
private:
int populationSize;
int generations;
double mutationPct;
double crossoverPct;
ChromosomeClass *population;
public:
// sets the population size
bool initializePopulation(int &popSize,ParameterClass ¶m);
// sets the number of iterations to use
bool setGenerations(int &gen);
// sets the % of population to mutate
bool setMutation(double &mutation);
// sets % of population to crossover
bool setCrossover(double &crossover);
// contains functionality to run the GA
void runGeneticAlgorithm(ParameterClass ¶meters);
// functionality to mate the population and get next generation
void selectionOp();
// functionality to mutate a percentage of the population
void mutationOp();
// functionality to crossover on a percentage of population
void crossoverOp();
int getPopSize() const;
};
#endif