From 17909d029c6a8872b2fddf4e171d7925bbbe9c5c Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 19:27:35 +0100 Subject: Initial commit --- Simulation/SimFitness_StartSpecs.cpp | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Simulation/SimFitness_StartSpecs.cpp (limited to 'Simulation/SimFitness_StartSpecs.cpp') diff --git a/Simulation/SimFitness_StartSpecs.cpp b/Simulation/SimFitness_StartSpecs.cpp new file mode 100644 index 0000000..8fe1a41 --- /dev/null +++ b/Simulation/SimFitness_StartSpecs.cpp @@ -0,0 +1,60 @@ +#include "SimFitness.hpp" + +bool SimFitness::startSpecs() +{ + if (!text.startup(this, SELECTION_BY_FITNESS)) + { + return false; + } + + std::unique_ptr dummy; + if (prms.netClass == SINGLE_MLP) + { + dummy = std::unique_ptr(new SingleMLP(82, prms.npHiddenLayer, 5, prms.nodeClass, true)); + } + else if (prms.netClass == DUAL_MLP) + { + dummy = std::unique_ptr(new DualMLP(82, prms.npHiddenLayer, 5, prms.nodeClass, true)); + } + else if (prms.netClass == SIMPLE_RN) + { + dummy = std::unique_ptr(new SimpleRN(82, prms.npHiddenLayer, 5, prms.nodeClass, true)); + } + else if (prms.netClass == FULLY_RN) + { + dummy = std::unique_ptr(new FullyRN(82, prms.npHiddenLayer, 5, prms.nodeClass, true)); + } + unsigned chromosomeSize = dummy->getChromosomeSize(); + population = std::unique_ptr(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(new SingleMLP(82, prms.npHiddenLayer, 5, prms.nodeClass, true)); + } + else if (prms.netClass == DUAL_MLP) + { + i.neuralNet = std::shared_ptr(new DualMLP(82, prms.npHiddenLayer, 5, prms.nodeClass, true)); + } + else if (prms.netClass == SIMPLE_RN) + { + i.neuralNet = std::shared_ptr(new SimpleRN(82, prms.npHiddenLayer, 5, prms.nodeClass, true)); + } + else if (prms.netClass == FULLY_RN) + { + i.neuralNet = std::shared_ptr(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; +} -- cgit v1.2.1