Integer encoded crossovers#

namespace integer#

Predefined crossover operators for the integer encoded genetic algorithm.

class SinglePoint#

#include <crossover/integer.hpp>
class SinglePoint : public gapp::crossover::Crossover<IntegerGene>#

Standard single-point crossover operator for the integer encoded GA.

A random position is selected in the chromosomes as the crossover point, and the genes before this crossover point are swapped between the parents in order to create the child solutions.

Public Functions

inline explicit constexpr Crossover() noexcept#

Create a crossover operator using the default crossover probability.

inline explicit constexpr Crossover(Probability pc) noexcept#

Create a crossover operator.

Parameters:

pc – The crossover probability. Must be in the closed interval [0.0, 1.0].

class TwoPoint#

#include <crossover/integer.hpp>
class TwoPoint : public gapp::crossover::Crossover<IntegerGene>#

Two-point crossover operator for the integer encoded GA.

2 random points are selected in the chromosomes as the crossover points, and the genes between these 2 crossover points are swapped between the parents in order to create the child solutions. This operation is effectively the same as performing 2 consecutive single-point crossovers on the parents.

Public Functions

inline explicit constexpr Crossover() noexcept#

Create a crossover operator using the default crossover probability.

inline explicit constexpr Crossover(Probability pc) noexcept#

Create a crossover operator.

Parameters:

pc – The crossover probability. Must be in the closed interval [0.0, 1.0].

class NPoint#

#include <crossover/integer.hpp>
class NPoint : public gapp::crossover::Crossover<IntegerGene>#

General N-point crossover operator for the integer encoded GA.

N random points are selected in the chromosomes as the crossover points for performing the crossover. This operation is effectively the same as performing N consecutive single-point crossovers on the parents to generate the child solutions.

Public Functions

inline explicit constexpr NPoint(Positive<size_t> n) noexcept#

Create an N-point crossover operator.

Parameters:

n – The number of crossover points. Must be at least 1.

inline constexpr NPoint(Probability pc, Positive<size_t> n) noexcept#

Create an N-point crossover operator.

Parameters:
  • pc – The crossover probability. Must be in the closed interval [0.0, 1.0].

  • n – The number of crossover points. Must be at least 1.

inline constexpr void num_crossover_points(Positive<size_t> n) noexcept#

Set the number of crossover points used in for the crossovers. The number of crossover points can’t be 0, and all values greater than the chromosome length will be treated the same, as if they are equal to the chromosome length.

Parameters:

n – The number of crossover points to use.

inline constexpr size_t num_crossover_points() const noexcept#
Returns:

The number of crossover points used.