org.jgap.impl
Class AveragingCrossoverOperator
- java.lang.Object
-
- org.jgap.BaseGeneticOperator
-
- org.jgap.impl.AveragingCrossoverOperator
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable, GeneticOperator
public class AveragingCrossoverOperator extends BaseGeneticOperator
The averaging crossover operator randomly selects two Chromosomes from the population and "mates" them by randomly picking a gene and then swapping that gene and all subsequent genes between the two Chromosomes. The two modified Chromosomes are then added to the list of candidate Chromosomes. This operation is performed half as many times as there are Chromosomes in the population. Additionally, the loci of crossing over are cached for each index, i.e., after randomizing the loci for each index once, they don't change again. If you work with CompositeGene's, this operator expects them to contain genes of the same type (e.g. IntegerGene). If you have mixed types, please provide your own crossover operator.- Since:
- 2.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description AveragingCrossoverOperator()Using the same random generator for randomizing the loci for crossing over as for selecting the genes to be crossed over.AveragingCrossoverOperator(Configuration a_configuration)Using the same random generator for randomizing the loci for crossing over as for selecting the genes to be crossed over.AveragingCrossoverOperator(Configuration a_configuration, IUniversalRateCalculator a_crossoverRateCalculator)Constructs a new instance of this CrossoverOperator with a specified crossover rate calculator, which results in dynamic crossover being turned on.AveragingCrossoverOperator(Configuration a_configuration, RandomGenerator a_generatorForAveraging)Using a different random generator for randomizing the loci for crossing over than for selecting the genes to be crossed over
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intcompareTo(java.lang.Object a_other)Compares the given object to this one.booleanequals(java.lang.Object a_other)Compares this GeneticOperator against the specified object.voidoperate(Population a_population, java.util.List a_candidateChromosomes)Crossover that acts as a perturbed mean of two individuals.voidsetCrossoverRate(int a_rate)-
Methods inherited from class org.jgap.BaseGeneticOperator
getConfiguration
-
-
-
-
Constructor Detail
-
AveragingCrossoverOperator
public AveragingCrossoverOperator() throws InvalidConfigurationExceptionUsing the same random generator for randomizing the loci for crossing over as for selecting the genes to be crossed over.Attention: The configuration used is the one set with the static method Genotype.setConfiguration.
- Throws:
InvalidConfigurationException- Since:
- 2.0
-
AveragingCrossoverOperator
public AveragingCrossoverOperator(Configuration a_configuration) throws InvalidConfigurationException
Using the same random generator for randomizing the loci for crossing over as for selecting the genes to be crossed over.- Parameters:
a_configuration- the configuration to use- Throws:
InvalidConfigurationException- Since:
- 3.0
-
AveragingCrossoverOperator
public AveragingCrossoverOperator(Configuration a_configuration, RandomGenerator a_generatorForAveraging) throws InvalidConfigurationException
Using a different random generator for randomizing the loci for crossing over than for selecting the genes to be crossed over- Parameters:
a_configuration- the configuration to usea_generatorForAveraging- RandomGenerator to use- Throws:
InvalidConfigurationException- Since:
- 3.0 (since 2.0 without a_configuration)
-
AveragingCrossoverOperator
public AveragingCrossoverOperator(Configuration a_configuration, IUniversalRateCalculator a_crossoverRateCalculator) throws InvalidConfigurationException
Constructs a new instance of this CrossoverOperator with a specified crossover rate calculator, which results in dynamic crossover being turned on.- Parameters:
a_configuration- the configuration to usea_crossoverRateCalculator- calculator for dynamic crossover rate computation- Throws:
InvalidConfigurationException- Since:
- 3.0 (since 2.0 without a_configuration)
-
-
Method Detail
-
operate
public void operate(Population a_population, java.util.List a_candidateChromosomes)
Crossover that acts as a perturbed mean of two individuals. x_i = p*x1_i + (1-p)*x2_i p - uniform random value over [0,1]. Averaging over line means p is same for every i, averaging over space if different p is chosen for each i. See CrossoverOperator for general description, also see feature request 708774- Parameters:
a_population- Chromosome[]a_candidateChromosomes- List- Since:
- 2.0
-
equals
public boolean equals(java.lang.Object a_other)
Compares this GeneticOperator against the specified object. The result is true if and the argument is an instance of this class and is equal wrt the data.- Overrides:
equalsin classBaseGeneticOperator- Parameters:
a_other- the object to compare against- Returns:
- true: if the objects are the same, false otherwise
- Since:
- 2.6
-
compareTo
public int compareTo(java.lang.Object a_other)
Compares the given object to this one.- Parameters:
a_other- the instance against which to compare this instance- Returns:
- a negative number if this instance is "less than" the given instance, zero if they are equal to each other, and a positive number if this is "greater than" the given instance
- Since:
- 2.6
-
setCrossoverRate
public void setCrossoverRate(int a_rate)
- Parameters:
a_rate- crossover rate to use by this crossover operator- Since:
- 2.6
-
-
DMelt 3.0 © DataMelt by jWork.ORG