Module io.jenetics.base
Package io.jenetics
Class SinglePointCrossover<G extends Gene<?,G>,C extends Comparable<? super C>>
java.lang.Object
io.jenetics.AbstractAlterer<G,C>
io.jenetics.Recombinator<G,C>
io.jenetics.Crossover<G,C>
io.jenetics.MultiPointCrossover<G,C>
io.jenetics.SinglePointCrossover<G,C>
- All Implemented Interfaces:
Alterer<G,
C>
public class SinglePointCrossover<G extends Gene<?,G>,C extends Comparable<? super C>>
extends MultiPointCrossover<G,C>
Single point crossover
One or two children are created by taking two parent strings and cutting them at some randomly chosen site. E.g.
If we create a child and its complement we preserving the total number of genes in the population, preventing any genetic drift. Single-point crossover is the classic form of crossover. However, it produces very slow mixing compared with multi-point crossover or uniform crossover. For problems where the site position has some intrinsic meaning to the problem single-point crossover can lead to small disruption than multi-point or uniform crossover.
- Since:
- 1.0
- Version:
- 5.0
- See Also:
-
Field Summary
Fields inherited from class io.jenetics.AbstractAlterer
_probability
Fields inherited from interface io.jenetics.Alterer
DEFAULT_ALTER_PROBABILITY
-
Constructor Summary
ConstructorDescriptionCreate a new single-point crossover object with crossover probability of0.05
.SinglePointCrossover
(double probability) Constructs an alterer with a given recombination probability. -
Method Summary
Methods inherited from class io.jenetics.MultiPointCrossover
crossoverPointCount
Methods inherited from class io.jenetics.Recombinator
alter, order
Methods inherited from class io.jenetics.AbstractAlterer
probability
-
Constructor Details
-
SinglePointCrossover
Constructs an alterer with a given recombination probability.- Parameters:
probability
- the crossover probability.- Throws:
IllegalArgumentException
- if theprobability
is not in the valid range of[0, 1]
.
-
SinglePointCrossover
public SinglePointCrossover()Create a new single-point crossover object with crossover probability of0.05
.
-
-
Method Details
-
crossover
Description copied from class:Crossover
Template method which performs the crossover. The arguments given are mutable non-null arrays of the same length.- Overrides:
crossover
in classMultiPointCrossover<G extends Gene<?,
G>, C extends Comparable<? super C>> - Parameters:
that
- the genes of the first chromosomeother
- the genes of the other chromosome- Returns:
- the number of altered genes
-
toString
- Overrides:
toString
in classMultiPointCrossover<G extends Gene<?,
G>, C extends Comparable<? super C>>
-