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
|
#include "SimFitness.hpp"
bool SimFitness::startSpecs()
{
if (!text.startup(this, SELECTION_BY_FITNESS))
{
return false;
}
std::unique_ptr<NeuralNet> dummy;
if (prms.netClass == SINGLE_MLP)
{
dummy = std::unique_ptr<NeuralNet>(new SingleMLP(82, prms.npHiddenLayer, 5, prms.nodeClass, true));
}
else if (prms.netClass == DUAL_MLP)
{
dummy = std::unique_ptr<NeuralNet>(new DualMLP(82, prms.npHiddenLayer, 5, prms.nodeClass, true));
}
else if (prms.netClass == SIMPLE_RN)
{
dummy = std::unique_ptr<NeuralNet>(new SimpleRN(82, prms.npHiddenLayer, 5, prms.nodeClass, true));
}
else if (prms.netClass == FULLY_RN)
{
dummy = std::unique_ptr<NeuralNet>(new FullyRN(82, prms.npHiddenLayer, 5, prms.nodeClass, true));
}
unsigned chromosomeSize = dummy->getChromosomeSize();
population = std::unique_ptr<Population>(new Population(prms.popQtty * prms.popSize, prms.elites, chromosomeSize));
// Set first population
guppies.resize(prms.popSize);
unsigned index = 0;
for (auto &i : guppies)
{
i.startup(this);
if (prms.netClass == SINGLE_MLP)
{
i.neuralNet = std::shared_ptr<NeuralNet>(new SingleMLP(82, prms.npHiddenLayer, 5, prms.nodeClass, true));
}
else if (prms.netClass == DUAL_MLP)
{
i.neuralNet = std::shared_ptr<NeuralNet>(new DualMLP(82, prms.npHiddenLayer, 5, prms.nodeClass, true));
}
else if (prms.netClass == SIMPLE_RN)
{
i.neuralNet = std::shared_ptr<SimpleRN>(new SimpleRN(82, prms.npHiddenLayer, 5, prms.nodeClass, true));
}
else if (prms.netClass == FULLY_RN)
{
i.neuralNet = std::shared_ptr<FullyRN>(new FullyRN(82, prms.npHiddenLayer, 5, prms.nodeClass, true));
}
i.create();
// Set neural net initial random weights
i.neuralNet->setChromosome(population->getChromosome(index));
++index;
}
return true;
}
|