Permutation encoded mutations#

namespace perm#

Predefined mutation operators for the permutation encoded genetic algorithm.

class Inversion#

#include <mutation/permutation.hpp>
class Inversion : public gapp::mutation::Mutation<PermutationGene>#

Inversion mutation operator for the permutation encoded GA.

Each individual is mutated with the specified mutation probability. In the mutated individuals, a randomly selected range of genes are reversed.

The operator has a single parameter (range_max) that specifies the maximum length of the reversed ranges relative to the chromosome length.

Public Functions

inline explicit constexpr Inversion(
Probability pm,
Normalized<double> range_max = 0.75,
) noexcept#

Create an inversion mutation operator.

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

  • range_max – The maximum length of the reversed ranges. Must be in the closed interval [0.0, 1.0].

inline virtual constexpr bool allow_variable_chrom_length(
) const noexcept override#

This method specifies whether the mutation operator supports variable chromosome lengths or not. If variable chromosome lengths are supported, the Candidates passed to the mutation operator are allowed to have chromosome lengths that are different from the chromosome length specified for the GA that the operator is used in.

This method will return false by default. If a particular mutation method allows variable chromosome lengths, it should override this method to return true.

Returns:

True if the mutation operator support variable chromosome lengths.

inline constexpr void range_max(Normalized<double> rm) noexcept#

Set the maximum length of the ranges that can be selected to be reversed by the operator. The parameter specifies the maximum range length relative to the overall chromosome length of a candidate.

Parameters:

rm – The maximum length of the reversed ranges. Must be in the closed interval [0.0, 1.0].

inline constexpr double range_max() const noexcept#
Returns:

The maximum length of the reversed ranges.

class Swap2#

#include <mutation/permutation.hpp>
class Swap2 : public gapp::mutation::Mutation<PermutationGene>#

Single swap/swap2 mutation operator for the permutation encoded GA.

Each candidate solution is mutated with the set mutation probability. In the mutated candidates, two distinct genes are randomly selected and then swapped.

Public Functions

inline virtual constexpr bool allow_variable_chrom_length(
) const noexcept override#

This method specifies whether the mutation operator supports variable chromosome lengths or not. If variable chromosome lengths are supported, the Candidates passed to the mutation operator are allowed to have chromosome lengths that are different from the chromosome length specified for the GA that the operator is used in.

This method will return false by default. If a particular mutation method allows variable chromosome lengths, it should override this method to return true.

Returns:

True if the mutation operator support variable chromosome lengths.

inline explicit constexpr Mutation(Probability pm) noexcept#

Create a mutation operator.

Parameters:

pm – The mutation probability. Must be in the closed interval [0.0, 1.0].

class Swap3#

#include <mutation/permutation.hpp>
class Swap3 : public gapp::mutation::Mutation<PermutationGene>#

Swap-3 mutation operator for the permutation encoded GA.

Each candidate solution is mutated with the set mutation probability. In the mutated candidates, 3 distinct genes are randomly selected and then reordered as: (a-b-c) -> (c-a-b).

Public Functions

inline virtual constexpr bool allow_variable_chrom_length(
) const noexcept override#

This method specifies whether the mutation operator supports variable chromosome lengths or not. If variable chromosome lengths are supported, the Candidates passed to the mutation operator are allowed to have chromosome lengths that are different from the chromosome length specified for the GA that the operator is used in.

This method will return false by default. If a particular mutation method allows variable chromosome lengths, it should override this method to return true.

Returns:

True if the mutation operator support variable chromosome lengths.

inline explicit constexpr Mutation(Probability pm) noexcept#

Create a mutation operator.

Parameters:

pm – The mutation probability. Must be in the closed interval [0.0, 1.0].

class Shuffle#

#include <mutation/permutation.hpp>
class Shuffle : public gapp::mutation::Mutation<PermutationGene>#

Shuffle/scramble mutation operator for the permutation encoded GA.

Each candidate solution is mutated with the set mutation probability. In the mutated candidates, a random range of genes is selected and then randomly shuffled.

The operator has a single parameter (range_max) that specifies the maximum length of the shuffled ranges relative to the chromosome length.

Note

There is a possbility that the shuffled chromosome will be the same as the original chromosome, so the probability of a chromosome being changed won’t be exactly equal to the set mutation probability (it will be slightly lower).

Public Functions

inline explicit constexpr Shuffle(
Probability pm,
Normalized<double> range_max = 0.5,
) noexcept#

Create a shuffle mutation operator.

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

  • range_max – The maximum length of the shuffled ranges. Must be in the closed interval [0.0, 1.0].

inline virtual constexpr bool allow_variable_chrom_length(
) const noexcept override#

This method specifies whether the mutation operator supports variable chromosome lengths or not. If variable chromosome lengths are supported, the Candidates passed to the mutation operator are allowed to have chromosome lengths that are different from the chromosome length specified for the GA that the operator is used in.

This method will return false by default. If a particular mutation method allows variable chromosome lengths, it should override this method to return true.

Returns:

True if the mutation operator support variable chromosome lengths.

inline constexpr void range_max(Normalized<double> rm) noexcept#

Set the maximum length of the ranges that can be selected to be shuffled by the operator. The parameter specifies the maximum range length relative to the overall chromosome length of a candidate.

Parameters:

rm – The maximum length of the shuffled ranges. Must be in the closed interval [0.0, 1.0].

inline constexpr double range_max() const noexcept#
Returns:

The maximum length of the shuffled ranges.

class Shift#

#include <mutation/permutation.hpp>
class Shift : public gapp::mutation::Mutation<PermutationGene>#

Shift/slide mutation operator for the permutation encoded GA.

Each candidate solution is mutated with the set mutation proability. In the mutated candidates, a random range of genes is selected and then moved to a different position in the chromosome.

The operator has a single parameter (range_max) that specifies the maximum length of the moved ranges relative to the chromosome length.

Public Functions

inline explicit constexpr Shift(
Probability pm,
Normalized<double> range_max = 0.75,
) noexcept#

Create a shift mutation operator.

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

  • range_max – The maximum length of the moved ranges. Must be in the closed interval [0.0, 1.0].

inline virtual constexpr bool allow_variable_chrom_length(
) const noexcept override#

This method specifies whether the mutation operator supports variable chromosome lengths or not. If variable chromosome lengths are supported, the Candidates passed to the mutation operator are allowed to have chromosome lengths that are different from the chromosome length specified for the GA that the operator is used in.

This method will return false by default. If a particular mutation method allows variable chromosome lengths, it should override this method to return true.

Returns:

True if the mutation operator support variable chromosome lengths.

inline constexpr void range_max(Normalized<double> rm) noexcept#

Set the maximum length of the ranges that can be selected to be moved by the operator. The parameter specifies the maximum range length relative to the overall chromosome length of a candidate.

Parameters:

rm – The maximum length of the moved ranges. Must be in the closed interval [0.0, 1.0].

inline constexpr double range_max() const noexcept#
Returns:

The maximum length of the moved ranges.