| Path: | data/CROSSOVER |
| Last Update: | Thu Feb 12 21:43:00 +0100 2009 |
A crossover operator combines two parents to generate one or (usually) two children.
The crossover operator should be defined as a cross method in the metaclass of your genotype class.
class Example < Genotype
...
class << self
def cross(parent1,parent2)
# generate children.
end
end
use NullCrossover # or include some builtin operator
end
Also see the Genotype#from_genes function, which can be useful for generating children after extracting and recombining the parents’ genes.
The builtin crossover operators are implemented as modules which should be included in the metaclass. Using the Genotype.use keyword does this automatically.
Just returns copies of the two parents, i.e. performs no crossover at all.
These crossovers can be used for all list- and string-based genotypes.
Standard single point crossover. Returns two children.
Standard uniform crossover.Returns two children.
N-point crossover. Returns two children.
Blending crossover as used in ES
PermutationCrossover is a partial preservation crossover for permutations. It is fairly destructive, which can lead to poor performance.
EdgeRecombinationCrossover is a less destructive crossover for permutations. It‘s reasonably effective, but fairly slow and only works for permutations of 0...n, so you have to look up the actual elements in the fitness function.
PartiallyMappedCrossover aka Two point Partial Preservation Crossover.
TreeCrossover does a standard subtree swapping crossover for trees. Returns two children.
These functions take one or more crossover modules and generate a new crossover module.
Applies an arbitrary crossover and returns a random child.
Applies an arbitrary crossover with probability p, and another crossover with probability 1-p.
Version of PCross for more than two crossover operators. If sum(probability) < 1, NullCrossover will be used for the remaining probability.