55 vector<size_t> pool(
pop.size());
56 std::iota(pool.begin(), pool.end(), 0);
61 vector<size_t> selected(
pop.size());
63 for (
int i = 0;
i <
pop.size(); ++
i)
67 selected.push_back(winner);
90 #pragma omp parallel for
91 for (
unsigned int i=0;
i<
pop.size(); ++
i)
98 vector<size_t> selected;
102 std::vector<int>& Fi =
front.at(
i);
105 for (
int j = 0; j < Fi.size(); ++j)
106 selected.push_back(Fi.at(j));
114 const int extra = params.
pop_size - selected.size();
115 for (
int j = 0; j < extra; ++j)
116 selected.push_back(
front.at(
i).at(j));
126 #pragma omp parallel for
127 for (
int i = 0;
i < individuals.size(); ++
i) {
129 std::vector<unsigned int> dom;
136 for (
int j = 0; j < individuals.size(); ++j) {
144 }
else if (compare == -1) {
168 std::sort(
front.at(0).begin(),
front.at(0).end());
171 while (
front.at(fi-1).size() > 0) {
173 std::vector<int>& fronti =
front.at(fi-1);
175 for (
int i = 0;
i < fronti.size(); ++
i) {
179 for (
int j = 0; j < p.
dominated.size() ; ++j) {
199 std::vector<int> F =
front.at(fronti);
200 if (F.size() == 0 )
return;
202 const int fsize = F.size();
204 for (
int i = 0;
i < fsize; ++
i)
205 pop.individuals.at(F.at(
i)).crowd_dist = 0;
208 const int limit =
pop.individuals.at(0).obj.size();
209 for (
int m = 0; m < limit; ++m) {
215 pop.individuals.at(F.at(0)).crowd_dist = std::numeric_limits<float>::max();
217 pop.individuals.at(F.at(fsize-1)).crowd_dist = std::numeric_limits<float>::max();
219 for (
int i = 1;
i < fsize-1; ++
i)
221 if (
pop.individuals.at(F.at(
i)).crowd_dist != std::numeric_limits<float>::max())
223 pop.individuals.at(F.at(
i)).crowd_dist +=
224 (
pop.individuals.at(F.at(
i+1)).obj.at(m) -
pop.individuals.at(F.at(
i-1)).obj.at(m))
225 / (
pop.individuals.at(F.at(fsize-1)).obj.at(m) -
pop.individuals.at(F.at(0)).obj.at(m));
data holding X, y, and Z data
individual programs in the population
int check_dominance(const Individual &b) const
check whether this dominates b.
vector< unsigned int > dominated
individual indices this dominates
unsigned int dcounter
number of individuals this dominates
float crowd_dist
crowding distance on the Pareto front
void set_rank(unsigned r)
setting and getting from individuals vector
T random_choice(const vector< T > &v)
holds the hyperparameters for Feat.
int pop_size
population size
int current_gen
holds current generation
vector< string > objectives
Pareto objectives.
Defines a population of programs and functions for constructing them.
sort based on objective m
sort based on rank, breaking ties with crowding distance
void fast_nds(vector< Individual > &)
vector< size_t > survive(Population &pop, const Parameters &p, const Data &d)
survival according to the survival scheme of NSGA-II
vector< size_t > select(Population &pop, const Parameters &p, const Data &d)
selection according to the survival scheme of NSGA-II
size_t tournament(vector< Individual > &pop, size_t i, size_t j) const
vector< vector< int > > front
void crowding_distance(Population &, int)