32 vector<size_t> all_idx(
pop.size());
33 std::iota(all_idx.begin(), all_idx.end(), 0);
35 cout <<
"selecting randoms\n";
36 vector<size_t> selected;
37 for (
unsigned i = 0;
i < P; ++
i)
40 cout <<
"getting elite\n";
59 int P =
pop.individuals.size()/2;
61 vector<size_t> all_idx(
pop.size());
62 std::iota(all_idx.begin(), all_idx.end(), 0);
64 cout <<
"selecting randoms\n";
65 vector<size_t> selected;
66 for (
unsigned i = 0;
i < P; ++
i)
68 cout <<
"getting elite\n";
78 size_t best_idx, worst_idx;
79 float min_fit, max_fit;
81 for (
unsigned i = 0;
i <
pop.individuals.size(); ++
i)
83 if (
pop.individuals.at(
i).fitness < min_fit ||
i == 0)
85 min_fit =
pop.individuals.at(
i).fitness;
90 if (!
in(selected, best_idx) )
92 for (
unsigned i = 0;
i < selected.size(); ++
i)
94 if (
pop.individuals.at(selected.at(
i)).fitness > max_fit ||
i == 0)
96 max_fit =
pop.individuals.at(selected.at(
i)).fitness;
101 selected.at(worst_idx) = best_idx;
data holding X, y, and Z data
T random_choice(const vector< T > &v)
bool in(const vector< T > v, const T &i)
check if element is in vector.
holds the hyperparameters for Feat.
Defines a population of programs and functions for constructing them.
vector< size_t > survive(Population &pop, const Parameters ¶ms, const Data &d)
vector< size_t > select(Population &pop, const Parameters ¶ms, const Data &d)
void enforce_elite(Population &pop, vector< size_t > &selected)
replaces worst individual in selected with best individual in Pop.