forked from jm-armijo/genetic-algorithm
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPopulation.hpp
More file actions
40 lines (33 loc) · 1.61 KB
/
Copy pathPopulation.hpp
File metadata and controls
40 lines (33 loc) · 1.61 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
#ifndef __JM_GENETIC_ALGORITHM_POPULATION
#define __JM_GENETIC_ALGORITHM_POPULATION
#include <vector>
#include "Individual.hpp"
class Population {
private:
unsigned m_size;
unsigned m_mutation_rate;
const static double accepted_fitness;
std::vector<Individual> m_individuals;
public:
Population(unsigned size, unsigned mutation_rate);
// |
// V
void fitness(const std::vector<double> &args, double expected); // <--+
// | // |
// V // |
bool checkEndCondition() const; // -----> End // |
// | No // Yes // |
// V // |
std::vector<unsigned> select(); // |
// | // |
// V // |
void crossover(const std::vector<unsigned>& selected); // |
// | // |
// V // |
void mutate(); // |
// | // |
// +---------------------------------------------------------------+
double getTopScore() const;
void printTopIndividual() const;
};
#endif // __JM_GENETIC_ALGORITHM_POPULATION