-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeneticAlgorithm.h
59 lines (44 loc) · 1.14 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* GeneticAlgorithm.h
*
* Created on: Jul 31, 2011
* Author: Jeroen Vlek
* Email: [email protected]
* Website: www.perceptivebits.com
* License: Free Beer (Feel free to use it in every
* way possible and if you like it, make
* sure to give me credit and buy me a drink
* if we ever meet ;) )
*/
#ifndef GENETICALGORITHM_H_
#define GENETICALGORITHM_H_
#include <vector>
#include <boost/thread.hpp>
#include "GUI.h"
#include "Organism.h"
#include "PairGenerator.h"
class GeneticAlgorithm
{
public:
virtual ~GeneticAlgorithm();
protected:
GeneticAlgorithm(GUI& aGUI);
void start();
void stop();
private:
GUI& m_gui;
typedef std::vector<Organism*> Population;
typedef Population::iterator PopulationIter;
Population m_population;
PairGenerator m_pairGenerator;
boost::thread m_thread;
boost::mutex m_inputLock;
boost::mutex m_outputLock;
bool m_doEvolution;
void displayPhenoTypes();
void doNaturalSelection();
void fillNewPopulation(bool doMutation);
void createOffspring(Population& newPopulation, bool doMutation);
void evolve();
};
#endif /* GENETICALGORITHM_H_ */