Package io.jenetics
Class CombineAlterer<G extends Gene<?,G>,C extends Comparable<? super C>>
- java.lang.Object
-
- io.jenetics.AbstractAlterer<G,C>
-
- io.jenetics.Recombinator<G,C>
-
- io.jenetics.CombineAlterer<G,C>
-
- All Implemented Interfaces:
Alterer<G,C>
- Direct Known Subclasses:
MeanAlterer
public class CombineAlterer<G extends Gene<?,G>,C extends Comparable<? super C>> extends Recombinator<G,C>
Alters a chromosome by replacing two genes by the result of a given combiner function.The order (
Recombinator.order()
) of this recombination implementation is two.- Since:
- 6.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
Constructors Constructor Description CombineAlterer(BinaryOperator<G> combiner)
Create a new combiner alterer with the given arguments.CombineAlterer(BinaryOperator<G> combiner, double probability)
Create a new combiner alterer with the given arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BinaryOperator<G>
combiner()
Return the combiner function, used bythis
alterer.protected int
recombine(MSeq<Phenotype<G,C>> population, int[] individuals, long generation)
Recombination template method.String
toString()
-
Methods inherited from class io.jenetics.Recombinator
alter, order
-
Methods inherited from class io.jenetics.AbstractAlterer
probability
-
-
-
-
Constructor Detail
-
CombineAlterer
public CombineAlterer(BinaryOperator<G> combiner, double probability)
Create a new combiner alterer with the given arguments.- Parameters:
combiner
- the function used for combining two genesprobability
- The recombination probability.- Throws:
IllegalArgumentException
- if theprobability
is not in the valid range of[0, 1]
NullPointerException
- if the givencombiner
isnull
-
CombineAlterer
public CombineAlterer(BinaryOperator<G> combiner)
Create a new combiner alterer with the given arguments.- Parameters:
combiner
- the function used for combining two genes- Throws:
IllegalArgumentException
- if theprobability
is not in the valid range of[0, 1]
NullPointerException
- if the givencombiner
isnull
-
-
Method Detail
-
combiner
public BinaryOperator<G> combiner()
Return the combiner function, used bythis
alterer.- Returns:
- the combiner function, used by
this
alterer
-
recombine
protected int recombine(MSeq<Phenotype<G,C>> population, int[] individuals, long generation)
Description copied from class:Recombinator
Recombination template method. This method is called 0 to n times. It is guaranteed that this method is only called by one thread.- Specified by:
recombine
in classRecombinator<G extends Gene<?,G>,C extends Comparable<? super C>>
- 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 isRecombinator.order()
. The first individual is the primary individual.generation
- the current generation.- Returns:
- the number of genes that has been altered.
-
-