Replacement methods#

namespace replacement#

Population replacement policies for the single-objective algorithms.

class KeepChildren#

#include <algorithm/soga_replacement.hpp>
class KeepChildren : public gapp::replacement::Replacement#

A population update method that selects only the child candidates from the combined parent and child populations, and uses these as the population of the next generation of the GA.

If the number of children is greater than the population size used in the algorithm, only the first population_size children will be selected.

class Elitism#

#include <algorithm/soga_replacement.hpp>
class Elitism : public gapp::replacement::Replacement#

A population update method that selects the candidates of the next generation using elitism.

The operator has a single parameter N, which determines the number of candidates that will be selected from the parent population. Of the combined parent and child populations, the N best candidates of the parent population will be copied over to the next population, while the remaining (pop_size - N) slots are filled by the first (pop_size - N) child solutions.

If N is equal to 0, this is equivalent to only keeping the children for the next generation (ie. KeepChildren).

Public Functions

inline constexpr Elitism(size_t n = 1) noexcept#

Create an elitist population update operator.

Parameters:

n – The number of solutions from the parent population that will be copied to the next generation of the algorithm.

inline constexpr void elite_num(size_t n) noexcept#

Set the number of elite solutions used.

Parameters:

n – The number of solutions from the parent population that will be copied to the next generation of the algorithm.

inline constexpr size_t elite_num() const noexcept#
Returns:

The number of elite solutions used.

class KeepBest#

#include <algorithm/soga_replacement.hpp>
class KeepBest : public gapp::replacement::Replacement#

A population update method that selects the best pop_size candidates of the combined parent and child populations, and uses these as the candidates of the next generation of the algorithm.

The operator assumes fitness maximization.