From 6fd23da97fa9700f59c61a966b4bf7d25fa46b34 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 03:15:03 +0100 Subject: initial commit --- Population.hpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Population.hpp (limited to 'Population.hpp') diff --git a/Population.hpp b/Population.hpp new file mode 100644 index 0000000..075a08f --- /dev/null +++ b/Population.hpp @@ -0,0 +1,30 @@ +#ifndef __POPULATION_HPP__ +#define __POPULATION_HPP__ + +#include "NNUtils.hpp" + +class Population +{ +public: + Population(unsigned popSize, unsigned eliteCount, unsigned chromosomeSize); + + void roulleteWheel(); + + unsigned getPopSize() const { return m_popSize; } + unsigned getChromosomeSize() const { return m_chromosomeSize; } + unsigned getEliteCount() const { return m_eliteCount; } + + void setFitness(unsigned i, unsigned fitness) { m_fitnesses[i] = fitness; } + Chromosome getChromosome(unsigned i) const { return m_chromosomes[i]; } + unsigned getFitness(unsigned i) const { return m_fitnesses[i]; } + +private: + unsigned m_popSize = 0; + unsigned m_eliteCount = 0; + unsigned m_chromosomeSize = 0; + + std::vector m_chromosomes; + std::vector m_fitnesses; +}; + +#endif // __POPULATION_HPP__ -- cgit v1.2.1