Selection

template<ProgramType T>
class Selection

interfaces with selection operators.

Public Functions

Selection()
inline ~Selection()
Selection(string type, bool survival)
void set_operator()
string get_type()

return type of selectionoperator

void set_type(string)

set type of selectionoperator

vector<size_t> select(Population<T> &pop, int island, const Parameters &params)

perform selection. selection uses a pop that has no offspring space

perform selection

vector<size_t> survive(Population<T> &pop, int island, const Parameters &params)

perform survival. uses a pop with offspring space

perform survival

Public Members

SelectionOperator<T> *pselector
string type
bool survival
template<ProgramType T>
class SelectionOperator

The SelectionOperator class represents a base class for selection operators in a genetic algorithm.

base class for selection operators.

This class provides common functionality and interface for selection operators.

Subclassed by Brush::Sel::Lexicase< T >, Brush::Sel::NSGA2< T >

Public Functions

virtual ~SelectionOperator()

Destructor for the SelectionOperator class.

virtual vector<size_t> select(Population<T> &pop, int island, const Parameters &p)

Selects individuals from the population based on the selection operator’s strategy.

Parameters:
  • pop – The population from which to select individuals.

  • island – The index of the island in a parallel genetic algorithm.

  • p – The parameters for the selection operator.

Returns:

A vector of indices representing the selected individuals.

virtual vector<size_t> survive(Population<T> &pop, int island, const Parameters &p)

Applies the selection operator to determine which individuals survive in the population.

Parameters:
  • pop – The population in which to apply the survival selection.

  • island – The index of the island in a parallel genetic algorithm.

  • p – The parameters for the selection operator.

Returns:

A vector of indices representing the surviving individuals.

Public Members

bool survival

Flag indicating whether the selection operator is used for survival selection.

string name

The name of the selection operator.

template<ProgramType T>
class NSGA2 : public Brush::Sel::SelectionOperator<T>

Public Functions

NSGA2(bool surv = false)

NSGA-II based selection and survival methods.

inline ~NSGA2()
virtual vector<size_t> select(Population<T> &pop, int island, const Parameters &p)

selection according to the survival scheme of NSGA-II

virtual vector<size_t> survive(Population<T> &pop, int island, const Parameters &p)

survival according to the survival scheme of NSGA-II

vector<vector<int>> fast_nds(Population<T>&, vector<size_t>&)
void crowding_distance(Population<T>&, vector<vector<int>>&, int)
template<ProgramType T>
class Lexicase : public Brush::Sel::SelectionOperator<T>

Lexicase selection operator.

Public Functions

Lexicase(bool surv = false)
inline ~Lexicase()
virtual vector<size_t> select(Population<T> &pop, int island, const Parameters &p)

function returns a set of selected indices from pop

virtual vector<size_t> survive(Population<T> &pop, int island, const Parameters &p)

lexicase survival