Genex v0.1.3 Genex.Operators.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 overriding the crossover method.

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 Davis Order crossover.

Performs a messy single point crossover.

Performs a simulated binary crossover.

Performs single point crossover.

Performs two-point crossover.

Performs uniform crossover.

Link to this section Functions

Performs a blend crossover.

This will blend genes according to some alpha between 0 and 1. If alpha=.5, the resulting chromosomes will be identical to one another.

Returns Chromosome.

Parameters

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

Performs Davis Order crossover.

Returns Chromosome.

Parameters

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

Performs a messy single point crossover.

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

Returns Chromosome.

Parameters

  • p1: Parent one.
  • p2: Parent two.
Link to this function

simulated_binary(p1, p2, eta)

View Source

Performs a simulated binary crossover.

Returns Chromosome.

Parameters

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

Performs single point crossover.

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

Returns %Chromosome{}.

Parameters

  • p1: Parent One.
  • p2: Parent Two.

Performs two-point crossover.

This will swap multiple 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.
  • rate: Float between 0 and 1 representing rates to swap genes.