Crossover

class jmetal.operator.crossover.ArithmeticCrossover(probability: float = 0.9, repair_operator: Callable[[float, float, float], float] | None = None)[source]

Bases: Crossover[FloatSolution, FloatSolution]

Arithmetic Crossover for real-valued solutions.

This operator performs an arithmetic combination of two parent solutions to produce two offspring. For each variable, a random weight (alpha) is used to compute a weighted average of the parent values.

The crossover works by: 1. For each variable, generate a random weight alpha in [0, 1] 2. Calculate new values as:

  • child1 = alpha * parent1 + (1 - alpha) * parent2

  • child2 = (1 - alpha) * parent1 + alpha * parent2

  1. Apply bounds repair if values fall outside the variable bounds

Args:

probability: Crossover probability (0.0 to 1.0) repair_operator: Optional function to repair out-of-bounds values.

If None, values are clamped to the variable bounds using min/max. Signature: repair_operator(value: float, lower_bound: float, upper_bound: float) -> float

Raises:

ValueError: If probability is not in [0,1]

Reference:

Michalewicz, Z. (1996). Genetic Algorithms + Data Structures = Evolution Programs. Springer-Verlag, Berlin.

doCrossover(probability: float, parent1: FloatSolution, parent2: FloatSolution) List[FloatSolution][source]

Perform the arithmetic crossover operation.

Args:

probability: Crossover probability parent1: First parent solution parent2: Second parent solution

Returns:

A list containing two offspring solutions

execute(parents: List[FloatSolution]) List[FloatSolution][source]
get_name() str[source]
get_number_of_children() int[source]
get_number_of_parents() int[source]
class jmetal.operator.crossover.BLXAlphaBetaCrossover(probability: float = 0.9, alpha: float = 0.5, beta: float = 0.5, repair_operator: Callable[[float, float, float], float] | None = None)[source]

Bases: Crossover[FloatSolution, FloatSolution]

BLX-αβ (Blend Crossover with separate alpha and beta) for real-valued solutions.

An extension of BLX-α crossover that uses two different expansion factors (α and β) for the lower and upper bounds respectively. This allows for asymmetric exploration around the parent solutions.

The crossover works by: 1. For each variable, determine the min and max values from the parents 2. Calculate the range between parents (d = max - min) 3. Expand the range by α*d below the min and β*d above the max 4. Sample new values uniformly from this expanded range 5. Apply bounds repair if values fall outside the variable bounds

Args:

probability: Crossover probability (0.0 to 1.0) alpha: Lower expansion factor (must be ≥ 0). Controls exploration below parents:

  • alpha = 0: No exploration below the smaller parent value

  • alpha > 0: Expands range below smaller parent by alpha*d

  • Typical values: 0.1 to 0.5

beta: Upper expansion factor (must be ≥ 0). Controls exploration above parents:
  • beta = 0: No exploration above the larger parent value

  • beta > 0: Expands range above larger parent by beta*d

  • Typical values: 0.1 to 0.5

repair_operator: Optional function to repair out-of-bounds values.

If None, values are clamped to the variable bounds using min/max. Signature: repair_operator(value: float, lower_bound: float, upper_bound: float) -> float

Raises:

ValueError: If probability is not in [0,1] or alpha/beta are negative.

Reference:

Eshelman, L. J., & Schaffer, J. D. (1993). Real-coded genetic algorithms and interval-schemata. Foundations of genetic algorithms, 2, 187-202.

doCrossover(probability: float, parent1: FloatSolution, parent2: FloatSolution) List[FloatSolution][source]

Perform the crossover operation.

Args:

probability: Crossover probability parent1: First parent solution parent2: Second parent solution

Returns:

A list containing two offspring solutions

execute(parents: List[FloatSolution]) List[FloatSolution][source]
get_name() str[source]
get_number_of_children() int[source]
get_number_of_parents() int[source]
class jmetal.operator.crossover.BLXAlphaCrossover(probability: float = 0.9, alpha: float = 0.5, repair_operator: Callable[[float, float, float], float] | None = None)[source]

Bases: Crossover[FloatSolution, FloatSolution]

BLX-α (Blend Crossover) for real-valued solutions.

The BLX-α crossover creates offspring within a range that is extended by a factor of α (alpha) beyond the range defined by the parent values. This allows for exploration beyond the region defined by the parents while maintaining a balance between exploration and exploitation.

The crossover works by: 1. For each variable, determine the min and max values from the parents 2. Calculate the range between parents 3. Expand the range by α * range in both directions 4. Sample new values uniformly from this expanded range 5. Apply bounds repair if values fall outside the variable bounds

Args:

probability: Crossover probability (0.0 to 1.0) alpha: Expansion factor (must be ≥ 0). Controls the exploration range:

  • alpha = 0: Offspring will be in the range defined by parents (no exploration)

  • alpha > 0: Offspring can be outside parent range (increased exploration)

  • Typical values: 0.1 to 0.5

repair_operator: Optional function to repair out-of-bounds values.

If None, values are clamped to the variable bounds using min/max. Signature: repair_operator(value: float, lower_bound: float, upper_bound: float) -> float

Raises:

ValueError: If probability is not in [0,1] or alpha is negative.

Reference:

Eshelman, L. J., & Schaffer, J. D. (1993). Real-coded genetic algorithms and interval-schemata. Foundations of genetic algorithms, 2, 187-202.

doCrossover(probability: float, parent1: FloatSolution, parent2: FloatSolution) List[FloatSolution][source]

Perform the crossover operation.

Args:

probability: Crossover probability parent1: First parent solution parent2: Second parent solution

Returns:

A list containing two offspring solutions

execute(parents: List[FloatSolution]) List[FloatSolution][source]
get_name() str[source]
get_number_of_children() int[source]
get_number_of_parents() int[source]
class jmetal.operator.crossover.CXCrossover(probability: float)[source]

Bases: Crossover[PermutationSolution, PermutationSolution]

execute(parents: List[PermutationSolution]) List[PermutationSolution][source]
get_name()[source]
get_number_of_children() int[source]
get_number_of_parents() int[source]
class jmetal.operator.crossover.CompositeCrossover(crossover_operator_list: List[Crossover])[source]

Bases: Crossover[CompositeSolution, CompositeSolution]

execute(solutions: List[CompositeSolution]) List[CompositeSolution][source]
get_name() str[source]
get_number_of_children() int[source]
get_number_of_parents() int[source]
class jmetal.operator.crossover.DifferentialEvolutionCrossover(CR: float, F: float, K: float = 0.5)[source]

Bases: Crossover[FloatSolution, FloatSolution]

Differential Evolution (DE) crossover operator for real-valued solutions.

This operator implements the standard DE crossover used in the DE/rand/1/bin and DE/best/1/bin variants. It creates a trial vector by combining the target vector with a difference vector, then performs binomial crossover between the target and trial vectors.

The operator requires three parents and three mutation factors (F, CR, and K). The first parent is the target vector, while the other two are used to compute the difference vector.

Args:
cr: Crossover probability (0.0 to 1.0). Controls the probability of each variable being

taken from the trial vector versus the target vector.

f: Differential weight (mutation factor) for the difference vector. Typically in [0, 2]. k: Scaling factor for the difference vector. Typically in [0, 1].

Raises:

ValueError: If cr is not in [0,1] or f/k are negative.

Reference:

Storn, R., & Price, K. (1997). Differential evolution - a simple and efficient heuristic for global optimization over continuous spaces. Journal of global optimization, 11(4), 341-359.

execute(parents: List[FloatSolution]) List[FloatSolution][source]

Execute the differential evolution crossover (‘best/1/bin’ variant in jMetal).

get_name() str[source]
get_number_of_children() int[source]
get_number_of_parents() int[source]
class jmetal.operator.crossover.IntegerSBXCrossover(probability: float, distribution_index: float = 20.0)[source]

Bases: Crossover[IntegerSolution, IntegerSolution]

execute(parents: List[IntegerSolution]) List[IntegerSolution][source]
get_name() str[source]
get_number_of_children() int[source]
get_number_of_parents() int[source]
class jmetal.operator.crossover.NullCrossover[source]

Bases: Crossover[Solution, Solution]

execute(parents: List[Solution]) List[Solution][source]
get_name()[source]
get_number_of_children() int[source]
get_number_of_parents() int[source]
class jmetal.operator.crossover.PMXCrossover(probability: float)[source]

Bases: Crossover[PermutationSolution, PermutationSolution]

execute(parents: List[PermutationSolution]) List[PermutationSolution][source]
get_name()[source]
get_number_of_children() int[source]
get_number_of_parents() int[source]
class jmetal.operator.crossover.SBXCrossover(probability: float, distribution_index: float = 20.0)[source]

Bases: Crossover[FloatSolution, FloatSolution]

Simulated Binary Crossover (SBX) for real-valued solutions.

SBX is a popular crossover operator for real-coded genetic algorithms that simulates the behavior of the single-point crossover operator in binary-coded GAs. It creates offspring solutions based on a probability distribution centered around the parent solutions, with the spread of the distribution controlled by the distribution index.

Args:

probability: Crossover probability (0.0 to 1.0) distribution_index: Distribution index (must be ≥ 0). Higher values produce offspring closer to parents.

Typical values range from 5 to 30, with 20 being a common default.

Raises:

Exception: If distribution_index is negative

execute(parents: List[FloatSolution]) List[FloatSolution][source]
get_name() str[source]
get_number_of_children() int[source]
get_number_of_parents() int[source]
class jmetal.operator.crossover.SPXCrossover(probability: float)[source]

Bases: Crossover[BinarySolution, BinarySolution]

A high-performance single-point crossover operator for BinarySolution.

This implementation uses NumPy’s vectorized operations for better performance when working with BinarySolution solutions. It performs a single-point crossover between two parent solutions to produce two offspring.

The crossover point is selected uniformly at random from all possible bit positions in the solution. The bits after the crossover point are swapped between the two parents to create the offspring.

Args:

probability: The probability of applying the crossover (must be between 0.0 and 1.0)

Raises:

ValueError: If the probability is not in the range [0.0, 1.0]

execute(parents: List[BinarySolution]) List[BinarySolution][source]

Execute the single-point crossover operation.

Args:
parents: A list of exactly two parent solutions of type BinarySolution.

Both parents must have the same number of bits.

Returns:

List[BinarySolution]: A list containing two offspring solutions.

Note:

This method assumes that both parents are valid BinarySolution instances with properly initialized bits attributes.

get_name() str[source]

Return the name of the operator.

get_number_of_children() int[source]

Return the number of offspring produced by the operator.

get_number_of_parents() int[source]

Return the number of parent solutions required by the operator.

class jmetal.operator.crossover.UnimodalNormalDistributionCrossover(probability: float = 0.9, zeta: float = 0.5, eta: float = 0.35, repair_operator: Callable[[float, float, float], float] | None = None)[source]

Bases: Crossover[FloatSolution, FloatSolution]

Unimodal Normal Distribution Crossover (UNDX) for real-valued solutions.

UNDX is a multi-parent crossover operator that generates offspring based on the normal distribution defined by three parent solutions. It is particularly effective for continuous optimization problems as it preserves the statistics of the population.

Reference:

Onikura, T., & Kobayashi, S. (1999). Extended UNIMODAL DISTRIBUTION CROSSOVER for REAL-CODED GENETIC ALGORITHMS. In Proceedings of the 1999 Congress on Evolutionary Computation-CEC99 (Cat. No. 99TH8406) (Vol. 2, pp. 1581-1588). IEEE.

Args:

probability: Crossover probability (0.0 to 1.0) zeta: Controls the spread along the line connecting parents (typically in [0.1, 1.0],

where smaller values produce offspring closer to the parents)

eta: Controls the spread in the orthogonal direction (typically in [0.1, 0.5],

where smaller values produce more concentrated distributions)

repair_operator: Optional function to repair out-of-bounds values.

If None, values are clamped to the variable bounds using min/max. Signature: repair_operator(value: float, lower_bound: float, upper_bound: float) -> float

Raises:

ValueError: If probability is not in [0,1] or if zeta or eta are negative

doCrossover(probability: float, parent1: FloatSolution, parent2: FloatSolution, parent3: FloatSolution) List[FloatSolution][source]

Perform the UNDX crossover operation.

Args:

probability: Crossover probability parent1: First parent solution parent2: Second parent solution parent3: Third parent solution (used to determine the orthogonal direction)

Returns:

A list containing two offspring solutions

execute(parents: List[FloatSolution]) List[FloatSolution][source]
get_name() str[source]
get_number_of_children() int[source]
get_number_of_parents() int[source]