Class Recombinator<G extends Gene<?,G>,C extends Comparable<? super C>>
- All Implemented Interfaces:
Alterer<G,
C>
- Direct Known Subclasses:
CombineAlterer
,Crossover
An enhanced genetic algorithm (EGA) combine elements of existing solutions in order to create a new solution, with some of the properties of each parent. Recombination creates a new chromosome by combining parts of two (or more) parent chromosomes. This combination of chromosomes can be made by selecting one or more crossover points, splitting these chromosomes on the selected points, and merge those portions of different chromosomes to form new ones.
The recombination probability P(r) determines the probability that a
given individual (genotype, not gene) of a population is selected for
recombination. The (mean) number of changed individuals depend on the
concrete implementation and can be vary from
P(r)·NG to
P(r)·NG·OR, where
OR is the order of the recombination, which is the number
of individuals involved int the recombine(io.jenetics.util.MSeq<io.jenetics.Phenotype<G, C>>, int[], long)
method.
- Since:
- 1.0
- Version:
- 6.0
-
Field Summary
Fields inherited from class io.jenetics.AbstractAlterer
_probability
Fields inherited from interface io.jenetics.Alterer
DEFAULT_ALTER_PROBABILITY
-
Constructor Summary
ModifierConstructorDescriptionprotected
Recombinator
(double probability, int order) Constructs an alterer with a given recombination probability. -
Method Summary
Modifier and TypeMethodDescriptionfinal AltererResult<G,
C> Alters (recombine) a given population.int
order()
Return the number of individuals involved in therecombine(MSeq, int[], long)
step.protected abstract int
Recombination template method.Methods inherited from class io.jenetics.AbstractAlterer
probability
-
Constructor Details
-
Recombinator
Constructs an alterer with a given recombination probability.- Parameters:
probability
- The recombination probability.order
- the number of individuals involved in therecombine(MSeq, int[], long)
step- Throws:
IllegalArgumentException
- if theprobability
is not in the valid range of[0, 1]
or the givenorder
is smaller than two.
-
-
Method Details
-
order
Return the number of individuals involved in therecombine(MSeq, int[], long)
step.- Returns:
- the number of individuals involved in the recombination step.
-
alter
Description copied from interface:Alterer
Alters (recombine) a given population. If thepopulation
is empty, nothing is altered. The altered population is part of the returnedAlterResult
object.- Parameters:
population
- The Population to be altered. If thepopulation
isnull
or empty, nothing is altered.generation
- the date of birth (generation) of the altered phenotypes.- Returns:
- the alter-result object, which contains the altered population and the alteration count
-
recombine
protected abstract int recombine(MSeq<Phenotype<G, C>> population, int[] individuals, long generation) Recombination template method. This method is called 0 to n times. It is guaranteed that this method is only called by one thread.- Parameters:
population
- the population to recombineindividuals
- the array with the indexes of the individuals which are involved in the recombination step. The length of the array isorder()
. The first individual is the primary individual.generation
- the current generation.- Returns:
- the number of genes that has been altered.
-