-
Notifications
You must be signed in to change notification settings - Fork 1
/
Settings.h
200 lines (162 loc) · 4.8 KB
/
Settings.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#ifndef _SETTINGS_H_
#define _SETTINGS_H_
#include <QString>
#include <QList>
class QSettings;
class h_Robot;
class graph_Robot;
class graph_Simulation;
class NeuralNet;
class Layer;
class Layer_Spiking;
class h_Simulation;
class Settings
{
public:
Settings(QSettings* pQSettings);
h_Simulation* createSim(Settings* settings, int aNumberRobot, int aNumberFoods, int aNumberPoisons, qreal worldWidth) const;
NeuralNet* createNeuralNet(Settings* settings) const;
Layer_Spiking* createLayer(Settings* settings, int aNumNeurons) const;
h_Robot* createRobot(Settings* settings, h_Simulation *aSimulation, qreal aRadius);
graph_Robot* createGraphRobot(Settings* settings, graph_Simulation* aGraph_Sim, h_Robot* aRobot);
void writeSettingsToFile(QSettings* pQSettings);
bool saveMatrixInFile(QString filename, QVector<QVector<qreal> > *pMatrix);
qreal randNumber(qreal min, qreal max);
int randInteger(int min, int max);
int normAngle(int angle); // between 0 and 360
int normAngle180(int angle); // between -180 and 180
qreal normAngle(qreal angle);
qreal radian(qreal angle);
qreal degree(qreal angle);
int numCaptors();
qreal sigmoid(qreal x);
void setSerialNumber(int aNumber) {cond.serialNumber = aNumber;}
struct EvolutionSettings
{
int popSize; // Size of the evolving population
int numFoods; // Number of food items for the evolution simulations
int numPoisons; // Number of poison items for the evolution simulations
int numWallPoisons;
int lengthSim; // Number of times the robot advance in one cycle
int lengthLastSim; // Number of times the robot advance in the last cycle of the evolution
int avgLastSim; // Number of times we average some lengthLastSim-length experiments
QString crossOverType; // Barycentric or one point
qreal crossOverRate;
qreal mutationRate;
qreal mutationAmpli;
qreal worldWidth;
// Fitness
int fitFoodCoeff; // For the fitness function, measures the importance of food compared to poison
int fitPoisCoeff;
} ev;
struct GraphSimulationSettings
{
int numRobots; // must be less than ev.popSize
int numFoods;
int numPoisons;
int numWallPoisons;
qreal worldWdith;
int numBunches; // Number of bunches of food
qreal radiusBunch; // food is scattered in this radius circle
qreal timeOutInterval; // Time between two simulations
} sim;
struct RobotSettings
{
int robotModel;
qreal sensorScope;
qreal maximumAngle;
qreal maxWheelSpeed;
qreal minWheelSpeed;
// angles of the sensors
int lSAngle1;
int lSAngle2;
int mSAngle1;
int mSAngle2;
int rSAngle1;
int rSAngle2;
int maxIntensity;
bool captorFood;
bool captorPoison;
int borderMode;
} rob;
struct nnSettings
{
int neuronModel;
int neuralNetModel;
int numberNeurons;
int numberSensors;
qreal dt;
int stepTime;
// Integrate and fire
qreal potResting_lif;
qreal potThreshold_lif;
qreal potSpiking_lif;
qreal maxWeight;
qreal minWeight;
int maxRefPeriodTime; // Refractory period
int minRefPeriodTime;
int maxDelayTime;
int minDelayTime;
QString noiseMode; // random, initial
qreal noiseCurrent; // in percentage
qreal curFactor;
qreal curRecFactor;
qreal curSensFactor;
} nn;
struct condSettings
{
int serialNumber; // Number that uniquely identify the process
QString experiment; // Evolution, lesion, etc
int numGenerations; // Number of cycles of the genetic algorithm (only used in Condor mode)
int numSimulations; // Number of simulations for the lesion
} cond;
int appMode; // Graphic or condor mode
int simMode; // Mode of the simulation
};
enum simMode
{
standard,
exploration,
memo
};
enum AppMode
{
graphical,
condor
};
enum neuronMode
{
QIF,
Izhi
};
enum neuralNetMode
{
spiking1Layer,
CTRNN1Layer,
zigzagNN
};
enum robotMode
{
foodPoison,
foodPoison_explo,
noSensor,
switchFP1,
smell,
memory,
switchFP2
};
enum RobotBorderMode // Way the robots cop with borders
{
blocked,
through // pass through borders
};
namespace Neuron // To have numbers for important neurons
{
enum Neuron
{
leftMotor,
rightMotor,
noise
};
}
#endif