-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleGeneticAlgorithm.h
More file actions
39 lines (35 loc) · 968 Bytes
/
SimpleGeneticAlgorithm.h
File metadata and controls
39 lines (35 loc) · 968 Bytes
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
#ifndef _SIMPLEGENETICALGORITHM_H_
#define _SIMPLEGENETICALGORITHM_H_
#include "Coin.h"
#include "Individual.h"
#include <string>
#include <vector>
class SimpleGeneticAlgorithm {
protected:
int population_size;
int tournament_size;
int generations;
int chromosome_size;
double mutation_probability;
double cross_probability;
double mse;
public:
double best_output;
Individual best;
std::vector<Individual> population;
SimpleGeneticAlgorithm(int chromosome_size, int population_size,
int tournament_size, int generations, double mutation_probability,
double cross_probability);
~SimpleGeneticAlgorithm();
int getRandomNumber(int low, int high);
void initializePopulation();
double virtual evaluateIndividual(Individual i);
std::string virtual getFenotype(Individual i);
double evaluate();
void select();
void cross();
void mutate();
double runGeneration();
std::vector<double> crosssValidation();
};
#endif