Genex v0.1.0 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 single point crossover.
Performs two-point crossover.
Performs uniform crossover.
Link to this section Functions
blend(p1, p2, alpha)
View Sourceblend(Genex.Chromosome.t(), Genex.Chromosome.t(), float()) :: Genex.Chromosome.t()
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.
single_point(p1, p2)
View Sourcesingle_point(Genex.Chromosome.t(), Genex.Chromosome.t()) :: Genex.Chromosome.t()
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.
two_point(p1, p2)
View Sourcetwo_point(Genex.Chromosome.t(), Genex.Chromosome.t()) :: Genex.Chromosome.t()
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.
uniform(p1, p2, rate)
View Sourceuniform(Genex.Chromosome.t(), Genex.Chromosome.t(), float()) :: Genex.Chromosome.t()
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.