Real encoded crossovers#

namespace real#

Predefined crossover operators for the real encoded genetic algorithm.

class Arithmetic#

#include <crossover/real.hpp>
class Arithmetic : public gapp::crossover::Crossover<RealGene>#

Arithmetic crossover operator for the real-encoded GA.

The children are the linear combinations of the parents, such that:

\[ child_1 = \beta p_1 + (1 - \beta) p_2 \]
\[ child_2 = (1 - \beta) p_1 + \beta p_2 \]
where \( \beta \) is a random number generated from a uniform distribution on [0.0, 1.0]. The same \( \beta \) value is used for each pair of parent genes.

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 BLXa#

#include <crossover/real.hpp>
class BLXa : public gapp::crossover::Crossover<RealGene>#

BLX- \( \alpha \) (blend) crossover operator for the real-encoded GA.

The genes of the children are chosen randomly from a uniform distribution based on the values of the corresponding genes of the parents.

The intervals the child genes are chosen from are:

\[ [-\alpha I + \min(p_1, p_2),\ \max(p_1, p_2) + \alpha I] \textrm{, where } I = |p_1 - p_2| \]

This crossover operator has a single parameter (alpha), which controls the length of the intervals the child genes are chosen from. Larger alpha values correspond to larger intervals. The recommended value of alpha is around 0.5.

Public Functions

inline constexpr BLXa() noexcept#

Create a BLX-alpha crossover operator.

inline explicit constexpr BLXa(
Probability pc,
NonNegative<GeneType> alpha = 0.5,
) noexcept#

Create a BLX-alpha crossover operator with the specified parameters.

Parameters:
  • pc – The crossover probability.

  • alpha – The alpha parameter of the crossover. Must be a finite non-negative value.

inline constexpr void alpha(NonNegative<GeneType> alpha) noexcept#

Set the alpha parameter of the crossover. This parameter controls the length of the interval the children’s genes are chosen from. Larger values values correspond to larger intervals.

Parameters:

alpha – The alpha parameter of the crossover. Must be a finite non-negative value.

inline constexpr GeneType alpha() const noexcept#
Returns:

The value of the alpha parameter.

class SimulatedBinary#

#include <crossover/real.hpp>
class SimulatedBinary : public gapp::crossover::Crossover<RealGene>#

Simulated binary crossover (SBX) operator for the real-encoded GA. This crossover operator is based on the single-point crossover used in the binary encoded GA.

This crossover has a single parameter (eta), which controls the shape of the probability distribution the child genes are chosen from. Larger eta values lead to children further away from the parents, while smaller values will result in the children being closer to the parents. Typical values for eta are in the range [1.0, 5.0].

Public Functions

inline constexpr SimulatedBinary() noexcept#

Create a simulated binary crossover operator.

inline explicit constexpr SimulatedBinary(
Probability pc,
NonNegative<GeneType> eta = 4.0,
) noexcept#

Create a simulated binary crossover operator with the specified parameters.

Parameters:
  • pc – The crossover probability.

  • eta – The shape parameter of the simulated binary crossover. Must be finite, non-negative value.

inline constexpr void eta(NonNegative<GeneType> eta) noexcept#

Set the shape parameter of the simulated binary crossover.

The value of this parameter controls the shape of the probability distribution the children’s genes are chosen from. Larger value will lead to child genes that are more likely to be further away from the parent genes values. Typical values for this parameter are in the range [1.0, 5.0].

Parameters:

eta – The eta parameter of the crossover. Must be finite, non-negative value.

inline constexpr GeneType eta() const noexcept#
Returns:

The eta parameter of the operator.

class Wright#

#include <crossover/real.hpp>
class Wright : public gapp::crossover::Crossover<RealGene>#

Wright’s heuristic crossover operator for the real-encoded GA.

If p1 is the better parent, then the created children are:

\[ child_1 = p_1 + w_1 * (p_1 - p_2) \]
\[ child_2 = p_1 + w_2 * (p_1 - p_2) \]
where \( w_1 \) and \( w_2 \) are random weights generated from a uniform distribution on [0.0, 1.0]. The same weights are used for all of the genes.

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].