dignea  1.0.0
Diverse Instance Generator with Novelty Search and Evolutionary Algorithms
KNN.h
Go to the documentation of this file.
1 
11 #ifndef __KNN_H__
12 #define __KNN_H__
13 
14 #include <dignea/core/Solution.h>
15 #include <dignea/distances/Distance.h>
16 #include <dignea/searches/NoveltySearch.h>
17 
18 #include <functional>
19 #include <iostream>
20 #include <string>
21 #include <utility>
22 #include <vector>
23 
24 using namespace std;
25 
33 using neighborT = pair<float, int>;
34 
44 using neighVector = vector<neighborT>;
65 using neighMatrix = vector<neighVector>;
66 
67 using Descriptor = vector<float>;
71 class KNN {
72  public:
73  KNN() = default;
74 
75  virtual ~KNN() = default;
76 
77  neighVector run(const Descriptor &individual,
78  const vector<Descriptor> &neighbours,
79  Distance<float> *metric, const int &k = 3);
80 
81  neighMatrix run(const vector<Descriptor> &population,
82  Distance<float> *metric, const int &k = 3);
83 };
84 
97 vector<float> sparseness(const vector<Descriptor> &population,
98  Distance<float> *metric, const int k);
112 float sparseness(const Descriptor &solution,
113  const vector<Descriptor> &population, Distance<float> *metric,
114  const int k);
115 
116 #endif // __KNN_H__
vector< neighVector > neighMatrix
Data type which represents a matrix of close neighbours. The first value is the index of the neighbou...
Definition: KNN.h:65
vector< float > sparseness(const vector< Descriptor > &population, Distance< float > *metric, const int k)
Computes the sparseness of all individuals in the population vector Based on the Novelty Search from ...
Definition: KNN.cpp:81
pair< float, int > neighborT
Data type which represents a close neighbours. The first value is the distance to the individual The ...
Definition: KNN.h:33
vector< neighborT > neighVector
Vector of neighbours Each element is of type neighborT. [(Distance_to_other_0, other_index_0),...
Definition: KNN.h:44
K-Nearest Neighbours Algorithm.
Definition: KNN.h:71