Genex v1.0.1-beta Genex.Tools.Crossover View Source

Implementation of several popular crossover methods.

Crossover is analagous to reproduction or biological crossover. Genex utilizes pairs of chromosomes to create offspring from the genetic material of parent chromosomes. Crossover happens with some probability P(c). Typically this is a high probability.

The probability of crossover or crossover_rate as it is called in our case, determines the number of parents selected to breed for the next generation. See more on this in the Selection documentation.

Crossover operators are generic. As with any optimization problem, no single method will be perfect. Genex offers a variety of crossover operators to experiment with; however, you may find that you need to write your own to fit your specific use case. You can do this by writing your own method and referencing it in the :crossover_type option.

Each time a crossover takes place, 2 new children are created. These children then populate the children field of the Population struct before they are merged into the new population.

Link to this section Summary

Functions

Performs a blend crossover.

Performs cut-on-worst crossover of p1 and p2.

Performs a messy single point crossover at random points.

Performs modified crossover of p1 and p2.

Performs multi-point crossover of p1 and p2.

Performs Order One (Davis Order) crossover of a random slice.

Performs a partialy matched crossover of p1 and p2.

Performs a simulated binary crossover.

Performs single point crossover at a random point.

Performs two-point crossover at a random point.

Performs uniform crossover.

Performs a uniform partialy matched crossover of p1 and p2.

Link to this section Functions

Performs a blend crossover.

This will blend genes according to some alpha between 0 and 1.

Returns {%Chromosome{}, %Chromosome{}}.

Parameters

  • p1: Parent one.
  • p2: Parent two.
  • alpha: Float between 0 and 1 representing percentage of each parent to blend into children.

Performs cut-on-worst crossover of p1 and p2.

Returns {%Chromosome{}, %Chromosome{}}.

Parameters

  • p1: Parent one.
  • p2: Parent two.
  • heuristic: Function with arity 2 to measure "badness" of a gene.
  • repair: Function specifying how to repair chromosome.

Performs a messy single point crossover at random points.

This crossover disregards the length of the chromosome and will often arbitrarily increase or decrease it's size.

Returns {%Chromosome{}, %Chromosome{}}.

Parameters

  • p1: Parent one.
  • p2: Parent two.

Performs modified crossover of p1 and p2.

Returns {%Chromosome{}, %Chromosome{}}.

Parameters

  • p1: Parent one.
  • p2: Parent two.
  • repair: Function specifying how to repair chromosome.

Performs multi-point crossover of p1 and p2.

Returns {%Chromosome{}, %Chromosome{}}.

Parameters

  • p1: Parent one.
  • p2: Parent two.
  • n: Number of crossover points.

Performs Order One (Davis Order) crossover of a random slice.

Note: This algorithm only works if your encoding is a permutation.

Returns {%Chromosome{}, %Chromosome{}}.

Parameters

  • p1: Parent one.
  • p2: Parent two.

Performs a partialy matched crossover of p1 and p2.

Returns {%Chromosome{}, %Chromosome{}}.

Parameters

  • p1: Parent one.
  • p2: Parent two.

Performs a simulated binary crossover.

Returns {%Chromosome{}, %Chromosome{}}.

Parameters

  • p1: Parent one.
  • p2: Parent two.
  • eta: Float

Performs single point crossover at a random point.

This will swap a random slice of genes from each chromosome, producing 2 new chromosomes.

Returns {%Chromosome{}, %Chromosome{}}.

Parameters

  • p1: Parent one.
  • p2: Parent two.

Performs two-point crossover at a random point.

This will swap two random slices of genes from each chromosome, producing 2 new chromosomes.

Returns %Chromosome{}.

Parameters

  • p1: Parent one.
  • p2: Parent two.

Performs uniform crossover.

This will swap random genes from each chromosome according to some specified rate, producing 2 new chrmosomes.

Returns Chromosome.

Parameters

  • p1: Parent one.
  • p2: Parent two.
  • probability: Float between 0 and 1 representing rates to swap genes.
Link to this function

uniform_partialy_matched(p1, p2, probability)

View Source

Performs a uniform partialy matched crossover of p1 and p2.

Returns {%Chromosome{}, %Chromosome{}}.

Parameters

  • p1: Parent one.
  • p2: Parent two.
  • probability: Probability of swap during PMX.