-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathGeneration.h
More file actions
61 lines (46 loc) · 1.52 KB
/
Copy pathGeneration.h
File metadata and controls
61 lines (46 loc) · 1.52 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
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef GENERATION_H
#define GENERATION_H
#include <iostream>
#include <vector>
#include <algorithm>
#include "Cell.h"
#include "GAInput.h"
using namespace std;
namespace genetic
{
extern GAInput gainput;
// Generation
class Generation
{
private:
vector<Cell> m_cells;
vector<double> m_prob;
void ComputeProbability(void);
void BoltzmannProb(void);
void GaussProb(void);
void UniformProb(void);
public:
Generation(void);
Generation(const Generation& other);
// God Makes Life
void Initialize(void);
const Cell& Select(void) const;
Cell& Select(void);
inline const Cell& Select(const int& i) const { return m_cells[i]; }
inline Cell& Select(const int& i) { return m_cells[i]; }
inline const Cell& Min(void) const { return *min_element(m_cells.begin(), m_cells.end()); }
inline Cell& Min(void) { return *min_element(m_cells.begin(), m_cells.end()); }
inline const Cell& Max(void) const { return *max_element(m_cells.begin(), m_cells.end()); }
inline Cell& Max(void) { return *max_element(m_cells.begin(), m_cells.end()); }
void Generate(const Generation& ancestor);
void AddFiedler(std::vector<int> fiedlerorder);
friend ostream& operator<< (ostream& ost, const Generation& g){
using std::setw;
using std::endl;
for(int i = 0; i < g.m_cells.size(); ++i)
ost << setw(4) << i << ": " << g.m_cells[i] << " ( " << g.m_prob[i] << " ) " << endl;
return ost;
}
};
};
#endif