Brush C++ API
A flexible interpretable machine learning framework
Toggle main menu visibility
Loading...
Searching...
No Matches
selection.cpp
Go to the documentation of this file.
1
#include "
selection.h
"
2
3
namespace
Brush
{
4
namespace
Sel
{
5
6
using namespace
Brush;
7
using namespace
Pop
;
8
9
template
<ProgramType T>
10
Selection<T>::Selection
()
11
{
12
this->
type
=
"nsga2"
;
13
this->
survival
=
false
;
14
this->
set_operator
();
15
}
16
17
18
template
<ProgramType T>
19
Selection<T>::Selection
(
string
type
,
bool
survival
)
20
{
24
this->type =
type
;
25
this->survival =
survival
;
26
this->
set_operator
();
27
}
28
29
template
<ProgramType T>
30
void
Selection<T>::set_operator
()
31
{
32
if
(this->
type
==
"nsga2"
)
33
pselector
= std::make_shared<NSGA2<T>>(
survival
);
34
else
if
(this->
type
==
"lexicase"
)
35
pselector
= std::make_shared<Lexicase<T>>(
survival
);
36
else
37
HANDLE_ERROR_THROW
(
"Undefined Selection Operator "
+ this->
type
+
"\n"
);
38
39
}
40
42
template
<ProgramType T>
43
string
Selection<T>::get_type
(){
return
pselector
->name; }
44
46
template
<ProgramType T>
47
void
Selection<T>::set_type
(
string
in
){
type
=
in
;
set_operator
();}
48
50
template
<ProgramType T>
51
vector<size_t>
Selection<T>::select
(
Population<T>
& pop,
int
island,
52
const
Parameters
& params)
53
{
54
return
pselector
->select(pop, island, params);
55
}
56
58
template
<ProgramType T>
59
vector<size_t>
Selection<T>::survive
(
Population<T>
& pop,
int
island,
60
const
Parameters
& params)
61
{
62
return
pselector
->survive(pop, island, params);
63
}
64
65
}
// Sel
66
}
// Brush
67
68
template
struct
Brush::Sel::Selection<Brush::ProgramType::Regressor>
;
69
template
struct
Brush::Sel::Selection<Brush::ProgramType::BinaryClassifier>
;
70
template
struct
Brush::Sel::Selection<Brush::ProgramType::MulticlassClassifier>
;
71
template
struct
Brush::Sel::Selection<Brush::ProgramType::Representer>
;
Brush::Pop::Population
Definition
population.h:12
HANDLE_ERROR_THROW
#define HANDLE_ERROR_THROW(err)
Definition
error.h:27
Brush::Pop
Definition
individual.cpp:4
Brush::Sel
Definition
lexicase.cpp:4
Brush::Util::in
bool in(const V &v, const T &i)
check if element is in vector.
Definition
utils.h:192
Brush
< nsga2 selection operator for getting the front
Definition
bandit.cpp:3
selection.h
Brush::Parameters
Definition
params.h:20
Brush::Sel::Selection
interfaces with selection operators.
Definition
selection.h:25
Brush::Sel::Selection::select
vector< size_t > select(Population< T > &pop, int island, const Parameters ¶ms)
perform selection. selection uses a pop that has no offspring space
Definition
selection.cpp:51
Brush::Sel::Selection::survival
bool survival
Definition
selection.h:29
Brush::Sel::Selection::get_type
string get_type()
return type of selectionoperator
Definition
selection.cpp:43
Brush::Sel::Selection::set_type
void set_type(string)
set type of selectionoperator
Definition
selection.cpp:47
Brush::Sel::Selection::type
string type
Definition
selection.h:28
Brush::Sel::Selection::survive
vector< size_t > survive(Population< T > &pop, int island, const Parameters ¶ms)
perform survival. uses a pop with offspring space
Definition
selection.cpp:59
Brush::Sel::Selection::set_operator
void set_operator()
Definition
selection.cpp:30
Brush::Sel::Selection::Selection
Selection()
Definition
selection.cpp:10
Brush::Sel::Selection::pselector
std::shared_ptr< SelectionOperator< T > > pselector
Definition
selection.h:27
src
selection
selection.cpp
Generated by
1.17.0