Module io.jenetics.base
Package io.jenetics
Class LineCrossover<G extends NumericGene<?,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.LineCrossover<G,C>
- All Implemented Interfaces:
Alterer<G,C>
public class LineCrossover<G extends NumericGene<?,G>,C extends Comparable<? super C>>
extends Crossover<G,C>
This alterer takes two chromosomes (treating it as vectors) and creates a
linear combination of these vectors as a result. The line-recombination depends
on a variable p which determines how far out along the line (defined
by the two multidimensional points/vectors) the children are allowed to be.
If p = 0 then the children will be located along the line within the
hypercube between the two points. If p > 0 then the children may
be located anywhere on the line, even somewhat outside the hypercube.
Points outside the allowed numeric range are rejected and the original
value is used instead. The strategy on how out-of-range points are handled,
is the difference to the very similar IntermediateCrossover.
- Since:
- 3.8
- Version:
- 3.8
- See Also:
-
Field Summary
Fields inherited from class io.jenetics.AbstractAlterer
_probabilityFields inherited from interface io.jenetics.Alterer
DEFAULT_ALTER_PROBABILITY -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new linear-crossover with default recombination probability (Alterer.DEFAULT_ALTER_PROBABILITY) and a p value of zero, which restricts the recombined chromosomes within the hypercube of the selected chromosomes (vectors).LineCrossover(double probability) Creates a new linear-crossover with the given recombination probability.LineCrossover(double probability, double p) Creates a new linear-crossover with the given recombination probability and the line-scaling factor p. -
Method Summary
Methods inherited from class io.jenetics.Recombinator
alter, orderMethods inherited from class io.jenetics.AbstractAlterer
probability
-
Constructor Details
-
LineCrossover
Creates a new linear-crossover with the given recombination probability and the line-scaling factor p.- Parameters:
probability- the recombination probability.p- defines the possible location of the recombined chromosomes. If p = 0 then the children will be located along the line within the hypercube between the two points. If p > 0 then the children may be located anywhere on the line, even somewhat outside the hypercube.- Throws:
IllegalArgumentException- if theprobabilityis not in the valid range of[0, 1]or ifpis smaller then zero
-
LineCrossover
Creates a new linear-crossover with the given recombination probability. The parameter p is set to zero, which restricts the recombined chromosomes within the hypercube of the selected chromosomes (vectors).- Parameters:
probability- the recombination probability.- Throws:
IllegalArgumentException- if theprobabilityis not in the valid range of[0, 1]
-
LineCrossover
public LineCrossover()Creates a new linear-crossover with default recombination probability (Alterer.DEFAULT_ALTER_PROBABILITY) and a p value of zero, which restricts the recombined chromosomes within the hypercube of the selected chromosomes (vectors).
-
-
Method Details
-
crossover
Description copied from class:CrossoverTemplate method which performs the crossover. The arguments given are mutable non-null arrays of the same length.- Specified by:
crossoverin classCrossover<G extends NumericGene<?,G>, C extends Comparable<? super C>> - Parameters:
v- the genes of the first chromosomew- the genes of the other chromosome- Returns:
- the number of altered genes
-
toString
-