# Crossover operators

Crossover operators (a.k.a. *recombinators*) in EvoLP work on two parents `a`

and `b`

to **generate 1 offspring**. All operators are derived from the `EvoLP.Recombinator`

abstract type, and some of them have parameters to control how the recombination is performed. Crossover methods are independent of the data contained in an individual, and are instead dependent on its representation.

Currently, crossover is only implemented for *vector* individuals.

## Selecting a crossover operator

All crossover operators have been **renamed** to *recombinators* since EvoLP 1.4. The old names will be **deprecated** in a future major release. Be sure to check the new type ontology.

EvoLP provides many built-in recombinators.

### Representation-independent

Single point, two point and uniform crossover operators work on vectors of any numeric type (binary or continuous representations). Using them on permutation-based vectors could generate unfeasible solutions.

`EvoLP.SinglePointRecombinator`

— TypeSingle point crossover.

`EvoLP.TwoPointRecombinator`

— TypeTwo point crossover.

`EvoLP.UniformRecombinator`

— TypeUniform crossover.

### For continuous domains

`EvoLP.InterpolationRecombinator`

— TypeInterpolation crossover with scaling parameter `λ`

.

### For permutation representations

Order One (OX1) allows for feasibility to be preserved after recombination.

`EvoLP.OX1Recombinator`

— TypeOrder 1 crossover (OX1) for permutation-based individuals.

## Performing the crossover

After "instantiating" a recombinator, you can use the `cross`

function. `cross`

operates on two parents `a`

and `b`

to generate a new candidate solution. All operators return a new individual, and in the process no individual is modified.

`EvoLP.cross`

— Function`cross(::SinglePointRecombinator, a, b)`

Single point crossover between parents `a`

and `b`

, at a random point in the chromosome.

`cross(::TwoPointRecombinator, a, b)`

Two point crossover between parents `a`

and `b`

, at two random points in the chromosome.

`crossover(::UniformRecombinator, a, b)`

Uniform crossover between parents `a`

and `b`

. Each gene of the chromosome is randomly selected from one of the parents.

`cross(C::InterpolationRecombinator, a, b)`

Linear Interpolation crossover between parents `a`

and `b`

. The resulting individual is the addition of a scaled version of each of the parents, using `C.λ`

as a control parameter.

`cross(::OX1Recombinator, a, b)`

Order 1 crossover between permutation parents `a`

and `b`

. A substring from `a`

is copied directly to the offspring, and the remaining values are copied in the order they appear in `b`

.

To obtain a second individual during crossover, use the `cross`

method swapping the arguments.