-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.cpp
140 lines (113 loc) · 2.89 KB
/
Config.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**
* Config.cpp
*
* Created on: Aug 9, 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 ;) )
*/
#include <cmath>
#include <iostream>
#include "Config.h"
#include "Factory.h"
unsigned int Config::m_Width = 0;
unsigned int Config::m_Height = 0;
unsigned int Config::m_MinGeneSize = 3;
unsigned int Config::m_MaxGeneSize = 7;
unsigned int Config::m_GenomeSize = 10;
unsigned int Config::m_PopulationSize = 100;
unsigned int Config::m_MutationInterval = 1;
unsigned int Config::m_ReportingInterval = 100;
unsigned int Config::m_NumWorkerThreads = 8;
unsigned int Config::m_DisplaySize = 19;
Config::Config()
{
}
Config::~Config()
{
}
unsigned int Config::GetGenomeSize()
{
return m_GenomeSize;
}
unsigned int Config::GetPopulationSize()
{
return m_PopulationSize;
}
unsigned int Config::GetHeight()
{
return m_Height;
}
unsigned int Config::GetMaxGeneSize()
{
return m_MaxGeneSize;
}
unsigned int Config::GetMinGeneSize()
{
return m_MinGeneSize;
}
unsigned int Config::GetWidth()
{
return m_Width;
}
unsigned int Config::GetMutationInterval() {
return m_MutationInterval;
}
unsigned int Config::GetReportingInterval() {
return m_ReportingInterval;
}
unsigned int Config::GetNumWorkerThreads() {
return m_NumWorkerThreads;
}
unsigned int Config::GetDisplaySize() {
return m_DisplaySize;
}
void Config::SetGenomeSize(const unsigned int genomeSize)
{
m_GenomeSize = genomeSize;
}
void Config::SetPopulationSize(const unsigned int populationSize)
{
m_PopulationSize = populationSize;
}
void Config::SetHeight(const unsigned int Height)
{
m_Height = Height;
Factory::Instance().update();
}
void Config::SetMaxGeneSize(const unsigned int MaxGeneSize)
{
m_MaxGeneSize = MaxGeneSize;
Factory::Instance().update();
}
void Config::SetMinGeneSize(const unsigned int MinGeneSize)
{
m_MinGeneSize = MinGeneSize;
Factory::Instance().update();
}
void Config::SetWidth(const unsigned int Width)
{
m_Width = Width;
Factory::Instance().update();
}
std::string Config::GetTestImageName()
{
return std::string("data/simple_red_star.jpg");
}
void Config::SetMutationInterval(const unsigned int mutationInterval) {
m_MutationInterval = mutationInterval == 0 ? 1 : mutationInterval;
std::cout << "[ Config::SetMutationInterval() ] New interval set to " << m_MutationInterval << std::endl;
}
void Config::SetReportingInterval(const unsigned int reportingInterval) {
m_ReportingInterval = reportingInterval;
}
void Config::SetNumWorkerThreads(unsigned int numWorkerThreads) {
m_NumWorkerThreads = numWorkerThreads;
}
void Config::SetDisplaySize(unsigned int displaySize) {
m_DisplaySize = std::min(displaySize, m_PopulationSize);
}