aboutsummaryrefslogtreecommitdiff
path: root/Population.hpp
blob: 075a08fb45a3b88f9aad08b8b64dd19a9fad4de9 (plain)
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
#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<Chromosome> m_chromosomes;
    std::vector<unsigned> m_fitnesses;
};

#endif // __POPULATION_HPP__