-
Notifications
You must be signed in to change notification settings - Fork 0
/
genomecollection.h
32 lines (29 loc) · 974 Bytes
/
genomecollection.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
#pragma once
#include <set>
#include <vector>
#include <ga/GA1DArrayGenome.h>
struct GenomeWithResult
{
bool operator< (const GenomeWithResult &p_right) const
{
return this->genome < p_right.genome;
}
GenomeWithResult(const std::vector<unsigned short int> &p_genome, float p_value) :
genome(p_genome),
value(p_value) {}
std::vector<unsigned short int> genome;
float value;
};
class GenomeCollection
{
public:
GenomeCollection();
void insert(const std::vector<int> &p_genome, float p_fitness);
void insert(const GA1DArrayAlleleGenome<int> &p_genome, float p_fitness);
bool isInCollection(std::vector<int> p_genome);
bool isInCollection(const GA1DArrayAlleleGenome<int> &p_genome);
float getFitnessForGenome(const GA1DArrayAlleleGenome<int> &p_genome);
private:
std::vector<unsigned short> buildIntVector(const GA1DArrayAlleleGenome<int> &p_genome);
std::set<GenomeWithResult> m_genomes{};
};