Feat C++ API
A feature engineering automation tool
selection.cc
Go to the documentation of this file.
1 /* FEAT
2 copyright 2017 William La Cava
3 license: GNU/GPL v3
4 */
5 
6 #include "selection.h"
7 
8 namespace FT{
9 namespace Sel{
10 
12 {
16  this->type = "lexicase";
17  this->survival = false;
18  this->set_operator();
19 }
20 
21 Selection::Selection(string type, bool survival)
22 {
26  this->type = type;
27  this->survival = survival;
28  this->set_operator();
29 }
30 
32 {
33  if (this->type == "lexicase")
34  pselector = std::make_shared<Lexicase>(survival);
35  else if (this->type == "fair_lexicase")
36  pselector = std::make_shared<FairLexicase>(survival);
37  else if (this->type == "nsga2")
38  pselector = std::make_shared<NSGA2>(survival);
39  else if (this->type == "tournament")
40  pselector = std::make_shared<Tournament>(survival);
41  else if (this->type == "offspring") // offspring survival
42  pselector = std::make_shared<Offspring>(survival);
43  else if (this->type == "random") // offspring survival
44  pselector = std::make_shared<Random>(survival);
45  else if (this->type == "simanneal") // offspring survival
46  pselector = std::make_shared<SimAnneal>(survival);
47  else
48  WARN("Undefined Selection Operator " + this->type + "\n");
49 
50 }
51 
53 
55 string Selection::get_type(){ return pselector->name; }
56 
59 
61 vector<size_t> Selection::select(Population& pop,
62  const Parameters& params, const Data& d)
63 {
64  return pselector->select(pop, params, d);
65 }
66 
69  const Parameters& params, const Data& d)
70 {
71  return pselector->survive(pop, params, d);
72 }
73 
74 }
75 }
data holding X, y, and Z data
Definition: data.h:42
#define WARN(err)
Definition: error.h:33
T pop(vector< T > *v)
Definition: auto_backprop.h:49
bool in(const vector< T > v, const T &i)
check if element is in vector.
Definition: utils.h:47
main Feat namespace
Definition: data.cc:13
holds the hyperparameters for Feat.
Definition: params.h:25
Defines a population of programs and functions for constructing them.
Definition: population.h:28
string get_type()
return type of selectionoperator
Definition: selection.cc:55
void set_type(string)
set type of selectionoperator
Definition: selection.cc:58
vector< size_t > survive(Population &pop, const Parameters &params, const Data &d)
perform survival
Definition: selection.cc:68
shared_ptr< SelectionOperator > pselector
Definition: selection.h:37
vector< size_t > select(Population &pop, const Parameters &params, const Data &d)
perform selection
Definition: selection.cc:61