Recombination Operators

The pycellga.recombination package includes various recombination (crossover) operators used to combine genetic information from parent chromosomes to create offspring in genetic algorithms. Each crossover operator serves a unique purpose and is suitable for different types of genetic representations, including binary, real-valued, and permutation-based chromosomes.

Arithmetic Crossover

Performs arithmetic operations on parent genes to produce offspring. Often used in real-valued genetic algorithms to create intermediate values between parent genes.

class ArithmeticCrossover(parents: list, problem: AbstractProblem)[source]

Bases: RecombinationOperator

ArithmeticCrossover performs an arithmetic crossover operation on a pair of parent individuals to produce offspring individuals.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

__init__(parents: list, problem: AbstractProblem)[source]

Initialize the ArithmeticCrossover object.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

get_recombinations() List[Individual][source]

Perform the arithmetic crossover on the parent individuals to produce offspring.

Returns:

A list containing the offspring individuals.

Return type:

List[Individual]

BLX-Alpha Crossover

Generates offspring by creating genes within a specified range around parent genes, controlled by the alpha parameter. Effective in real-valued optimization for maintaining diversity.

class BlxalphaCrossover(parents: list, problem: AbstractProblem)[source]

Bases: RecombinationOperator

BlxalphaCrossover performs BLX-alpha crossover on a pair of parent individuals to produce offspring individuals.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

__init__(parents: list, problem: AbstractProblem)[source]

Initialize the BlxalphaCrossover object.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

combine(p1: Individual, p2: Individual, locationsource: Individual) Individual[source]

Combine two parent individuals using BLX-alpha crossover to produce a single offspring.

Parameters:
  • p1 (Individual) – The first parent individual.

  • p2 (Individual) – The second parent individual.

  • locationsource (Individual) – The individual from which to copy positional information for the offspring.

Returns:

The resulting offspring individual.

Return type:

Individual

get_recombinations() List[Individual][source]

Perform the BLX-alpha crossover on the parent individuals to produce offspring.

Returns:

A list containing the offspring individuals.

Return type:

List[Individual]

Byte One-Point Crossover

A one-point crossover operator specifically designed for byte-based chromosomes, suitable for machine-coded genetic algorithms.

class ByteOnePointCrossover(parents: list, problem: AbstractProblem)[source]

Bases: RecombinationOperator

ByteOnePointCrossover operator defined in (Satman, 2013). ByteOnePointCrossover performs a one-point crossover at the byte level on a pair of parent individuals to produce offspring individuals.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

__init__(parents: list, problem: AbstractProblem)[source]

Initialize the ByteOnePointCrossover object.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

get_recombinations() List[Individual][source]

Perform the one-point crossover on the parent individuals at the byte level to produce offspring.

Returns:

A list containing the offspring individuals.

Return type:

List[Individual]

Byte Uniform Crossover

Applies uniform crossover at the byte level, allowing fine control over gene mixing in machine-coded chromosomes.

class ByteUniformCrossover(parents: list, problem: AbstractProblem)[source]

Bases: RecombinationOperator

ByteUniformCrossover operator defined in (Satman, 2013). ByteUniformCrossover performs a uniform crossover at the byte level on a pair of parent individuals to produce offspring individuals.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

__init__(parents: list, problem: AbstractProblem)[source]

Initialize the ByteUniformCrossover object.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

combine(p1: Individual, p2: Individual, locationsource: Individual) Individual[source]

Combine two parent individuals using uniform crossover at the byte level to produce a single offspring.

Parameters:
  • p1 (Individual) – The first parent individual.

  • p2 (Individual) – The second parent individual.

  • locationsource (Individual) – The individual from which to copy positional information for the offspring.

Returns:

The resulting offspring individual.

Return type:

Individual

get_recombinations() List[Individual][source]

Perform the uniform crossover on the parent individuals to produce offspring.

Returns:

A list containing the offspring individuals.

Return type:

List[Individual]

Flat Crossover

Creates offspring by generating random values within a range defined by the parent genes. Suitable for real-valued chromosomes.

class FlatCrossover(parents: list, problem: AbstractProblem)[source]

Bases: RecombinationOperator

FlatCrossover performs a flat crossover on a pair of parent individuals to produce offspring individuals.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

__init__(parents: list, problem: AbstractProblem)[source]

Initialize the FlatCrossover object.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

combine(p1: Individual, p2: Individual, locationsource: Individual) Individual[source]

Combine two parent individuals using flat crossover to produce a single offspring.

Parameters:
  • p1 (Individual) – The first parent individual.

  • p2 (Individual) – The second parent individual.

  • locationsource (Individual) – The individual from which to copy positional information for the offspring.

Returns:

The resulting offspring individual.

Return type:

Individual

get_recombinations() List[Individual][source]

Perform the flat crossover on the parent individuals to produce offspring.

Returns:

A list containing the offspring individuals.

Return type:

List[Individual]

Linear Crossover

Generates offspring by linearly combining genes of the parents. This operator is useful in real-valued optimization for exploring intermediate values.

class LinearCrossover(parents: list, problem: AbstractProblem)[source]

Bases: RecombinationOperator

LinearCrossover performs a linear crossover on a pair of parent individuals to produce offspring individuals.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

__init__(parents: list, problem: AbstractProblem)[source]

Initialize the LinearCrossover object.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

combine(p1: Individual, p2: Individual, locationsource: Individual) Individual[source]

Combine two parent individuals using linear crossover to produce a single offspring.

Parameters:
  • p1 (Individual) – The first parent individual.

  • p2 (Individual) – The second parent individual.

  • locationsource (Individual) – The individual from which to copy positional information for the offspring.

Returns:

The resulting offspring individual.

Return type:

Individual

get_recombinations() List[Individual][source]

Perform the linear crossover on the parent individuals to produce offspring.

Returns:

A list containing the offspring individuals.

Return type:

List[Individual]

One-Point Crossover

A classic crossover technique where a single crossover point is chosen to swap segments between parents. Commonly used in binary-encoded genetic algorithms.

class OnePointCrossover(parents: list, problem: AbstractProblem)[source]

Bases: RecombinationOperator

OnePointCrossover performs a one-point crossover on a pair of parent individuals to produce offspring individuals.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

__init__(parents: list, problem: AbstractProblem)[source]

Initialize the OnePointCrossover object.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

get_recombinations() List[Individual][source]

Perform the one-point crossover on the parent individuals to produce offspring.

Returns:

A list containing the offspring individuals.

Return type:

List[Individual]

Partially Matched Crossover (PMX)

A crossover method designed for permutation-based chromosomes, such as sequencing problems. Maintains gene order by partially matching segments between parents.

class PMXCrossover(parents: list, problem: AbstractProblem)[source]

Bases: RecombinationOperator

PMXCrossover performs Partially Mapped Crossover (PMX) on a pair of parent individuals to produce offspring individuals.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

__init__(parents: list, problem: AbstractProblem)[source]

Initialize the PMXCrossover object.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

get_recombinations() List[Individual][source]

Perform the PMX crossover on the parent individuals to produce offspring.

Returns:

A list containing the offspring individuals.

Return type:

List[Individual]

Two-Point Crossover

A crossover method with two crossover points, allowing for a higher level of gene exchange between parents. Widely used in binary-encoded algorithms.

class TwoPointCrossover(parents: list, problem: AbstractProblem)[source]

Bases: RecombinationOperator

TwoPointCrossover performs a two-point crossover on a pair of parent individuals to produce offspring individuals.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

__init__(parents: list, problem: AbstractProblem)[source]

Initialize the TwoPointCrossover object.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

get_recombinations() List[Individual][source]

Perform the two-point crossover on the parent individuals to produce offspring.

Returns:

A list containing the offspring individuals.

Return type:

List[Individual]

Unfair Average Crossover

Calculates the average of parent genes with a slight bias, leading to offspring that retain more traits of one parent. Used in real-valued genetic algorithms.

class UnfairAvarageCrossover(parents: list, problem: AbstractProblem)[source]

Bases: RecombinationOperator

UnfairAvarageCrossover performs an unfair average crossover on a pair of parent individuals to produce offspring individuals.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

__init__(parents: list, problem: AbstractProblem)[source]

Initialize the UnfairAvarageCrossover object.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

get_recombinations() List[Individual][source]

Perform the unfair average crossover on the parent individuals to produce offspring.

Returns:

A list containing the offspring individuals.

Return type:

List[Individual]

Uniform Crossover

Swaps genes randomly between parents, creating diverse offspring. Suitable for both binary and real-valued genetic representations.

class UniformCrossover(parents: list, problem: AbstractProblem)[source]

Bases: RecombinationOperator

UniformCrossover performs a uniform crossover on a pair of parent individuals to produce offspring individuals.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

__init__(parents: list, problem: AbstractProblem)[source]

Initialize the UniformCrossover object.

Parameters:
  • parents (list) – A list containing two parent individuals.

  • problem (AbstractProblem) – The problem instance that provides the fitness function.

combine(p1: Individual, p2: Individual, locationsource: Individual) Individual[source]

Combine two parent individuals using uniform crossover to produce a single offspring.

Parameters:
  • p1 (Individual) – The first parent individual.

  • p2 (Individual) – The second parent individual.

  • locationsource (Individual) – The individual from which to copy positional information for the offspring.

Returns:

The resulting offspring individual.

Return type:

Individual

get_recombinations() List[Individual][source]

Perform the uniform crossover on the parent individuals to produce offspring.

Returns:

A list containing the offspring individuals.

Return type:

List[Individual]