Package io.jenetics
Class IntermediateCrossover<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.IntermediateCrossover<G,C>
-
- All Implemented Interfaces:
Alterer<G,C>
public class IntermediateCrossover<G extends NumericGene<?,G>,C extends Comparable<? super C>> extends Crossover<G,C>
This alterer takes two chromosome (treating it as vectors) and creates a linear combination of this vectors as 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 of the hypercube.Points outside of the allowed numeric range are rejected and a new points are generated, until they lie in the valid range. The strategy on how out-of-range points are handled, is the difference to the very similar
LineCrossover
.- Since:
- 3.8
- Version:
- 3.8
- See Also:
-
Essentials of Metaheuristic, page 42,
LineCrossover
-
-
Field Summary
-
Fields inherited from class io.jenetics.AbstractAlterer
_probability
-
Fields inherited from interface io.jenetics.Alterer
DEFAULT_ALTER_PROBABILITY
-
-
Constructor Summary
Constructors Constructor Description IntermediateCrossover()
Creates a new intermediate-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).IntermediateCrossover(double probability)
Creates a new intermediate-crossover with the given recombination probability.IntermediateCrossover(double probability, double p)
Creates a new intermediate-crossover with the given recombination probability and the line-scaling factor p.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
crossover(MSeq<G> v, MSeq<G> w)
Template method which performs the crossover.String
toString()
-
Methods inherited from class io.jenetics.Recombinator
alter, order
-
Methods inherited from class io.jenetics.AbstractAlterer
probability
-
-
-
-
Constructor Detail
-
IntermediateCrossover
public IntermediateCrossover(double probability, double p)
Creates a new intermediate-crossover with the given recombination probability and the line-scaling factor p.When the value for p is greater then 0, the crossover point generation must be repeated until the points lie within the allowed range. Values greater then 10 are usually not recommended, since this leads to unnecessary crossover point generation.
- 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 of the hypercube.- Throws:
IllegalArgumentException
- if theprobability
is not in the valid range of[0, 1]
or ifp
is smaller then zero
-
IntermediateCrossover
public IntermediateCrossover(double probability)
Creates a new intermediate-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 theprobability
is not in the valid range of[0, 1]
-
IntermediateCrossover
public IntermediateCrossover()
Creates a new intermediate-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 Detail
-
crossover
protected int crossover(MSeq<G> v, MSeq<G> w)
Description copied from class:Crossover
Template method which performs the crossover. The arguments given are mutable non null arrays of the same length.- Specified by:
crossover
in 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
-
-