|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jgap.BaseGeneticOperator
org.jgap.impl.CrossoverOperator
public class CrossoverOperator
The 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. If you work with CompositeGenes, 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. This CrossoverOperator supports both fixed and dynamic crossover rates. A fixed rate is one specified at construction time by the user. This operation is performed 1/m_crossoverRate as many times as there are Chromosomes in the population. Another possibility is giving the crossover rate as a percentage. A dynamic rate is determined by this class on the fly if no fixed rate is provided.
| Field Summary |
|---|
| Fields inherited from class org.jgap.BaseGeneticOperator |
|---|
m_monitor, m_monitorActive |
| Constructor Summary | |
|---|---|
CrossoverOperator()
Constructs a new instance of this CrossoverOperator without a specified crossover rate, this results in dynamic crossover rate being turned off. |
|
CrossoverOperator(Configuration a_configuration)
Constructs a new instance of this CrossoverOperator without a specified crossover rate, this results in dynamic crossover rate being turned off. |
|
CrossoverOperator(Configuration a_configuration,
double a_crossoverRatePercentage)
Constructs a new instance of this CrossoverOperator with the given crossover rate. |
|
CrossoverOperator(Configuration a_configuration,
double a_crossoverRatePercentage,
boolean a_allowFullCrossOver)
Constructs a new instance of this CrossoverOperator with the given crossover rate. |
|
CrossoverOperator(Configuration a_configuration,
double a_crossoverRatePercentage,
boolean a_allowFullCrossOver,
boolean a_xoverNewAge)
Constructs a new instance of this CrossoverOperator with the given crossover rate. |
|
CrossoverOperator(Configuration a_configuration,
int a_desiredCrossoverRate)
Constructs a new instance of this CrossoverOperator with the given crossover rate. |
|
CrossoverOperator(Configuration a_configuration,
int a_desiredCrossoverRate,
boolean a_allowFullCrossOver)
Constructs a new instance of this CrossoverOperator with the given crossover rate. |
|
CrossoverOperator(Configuration a_configuration,
int a_desiredCrossoverRate,
boolean a_allowFullCrossOver,
boolean a_xoverNewAge)
Constructs a new instance of this CrossoverOperator with the given crossover rate. |
|
CrossoverOperator(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. |
|
CrossoverOperator(Configuration a_configuration,
IUniversalRateCalculator a_crossoverRateCalculator,
boolean a_allowFullCrossOver)
Constructs a new instance of this CrossoverOperator with a specified crossover rate calculator, which results in dynamic crossover being turned on. |
|
| Method Summary | |
|---|---|
int |
compareTo(java.lang.Object a_other)
Compares the given object to this one. |
protected void |
doCrossover(IChromosome firstMate,
IChromosome secondMate,
java.util.List a_candidateChromosomes,
RandomGenerator generator)
|
int |
getCrossOverRate()
|
double |
getCrossOverRatePercent()
|
protected void |
init()
Initializes certain parameters. |
boolean |
isAllowFullCrossOver()
|
boolean |
isXoverNewAge()
|
void |
operate(Population a_population,
java.util.List a_candidateChromosomes)
Does the crossing over. |
void |
setAllowFullCrossOver(boolean a_allowFullXOver)
|
void |
setXoverNewAge(boolean a_xoverNewAge)
|
| Methods inherited from class org.jgap.BaseGeneticOperator |
|---|
equals, getConfiguration |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CrossoverOperator()
throws InvalidConfigurationException
Attention: The configuration used is the one set with the static method Genotype.setConfiguration.
InvalidConfigurationException
public CrossoverOperator(Configuration a_configuration)
throws InvalidConfigurationException
a_configuration - the configuration to use
InvalidConfigurationException
public CrossoverOperator(Configuration a_configuration,
IUniversalRateCalculator a_crossoverRateCalculator)
throws InvalidConfigurationException
a_configuration - the configuration to usea_crossoverRateCalculator - calculator for dynamic crossover rate
computation
InvalidConfigurationException
public CrossoverOperator(Configuration a_configuration,
IUniversalRateCalculator a_crossoverRateCalculator,
boolean a_allowFullCrossOver)
throws InvalidConfigurationException
a_configuration - the configuration to usea_crossoverRateCalculator - calculator for dynamic crossover rate
computationa_allowFullCrossOver - true: x-over before AND after x-over point,
false: only x-over after x-over point
InvalidConfigurationException
public CrossoverOperator(Configuration a_configuration,
int a_desiredCrossoverRate)
throws InvalidConfigurationException
a_configuration - the configuration to usea_desiredCrossoverRate - the desired rate of crossover
InvalidConfigurationException
public CrossoverOperator(Configuration a_configuration,
int a_desiredCrossoverRate,
boolean a_allowFullCrossOver)
throws InvalidConfigurationException
a_configuration - the configuration to usea_desiredCrossoverRate - the desired rate of crossovera_allowFullCrossOver - true: x-over before AND after x-over point,
false: only x-over after x-over point
InvalidConfigurationException
public CrossoverOperator(Configuration a_configuration,
int a_desiredCrossoverRate,
boolean a_allowFullCrossOver,
boolean a_xoverNewAge)
throws InvalidConfigurationException
a_configuration - the configuration to usea_desiredCrossoverRate - the desired rate of crossovera_allowFullCrossOver - true: x-over before AND after x-over point,
false: only x-over after x-over pointa_xoverNewAge - true: also x-over chromosomes with age of zero (newly
created chromosomes)
InvalidConfigurationException
public CrossoverOperator(Configuration a_configuration,
double a_crossoverRatePercentage)
throws InvalidConfigurationException
a_configuration - the configuration to usea_crossoverRatePercentage - the desired rate of crossover in
percentage of the population
InvalidConfigurationException
public CrossoverOperator(Configuration a_configuration,
double a_crossoverRatePercentage,
boolean a_allowFullCrossOver)
throws InvalidConfigurationException
a_configuration - the configuration to usea_crossoverRatePercentage - the desired rate of crossover in
percentage of the populationa_allowFullCrossOver - true: x-over before AND after x-over point,
false: only x-over after x-over point
InvalidConfigurationException
public CrossoverOperator(Configuration a_configuration,
double a_crossoverRatePercentage,
boolean a_allowFullCrossOver,
boolean a_xoverNewAge)
throws InvalidConfigurationException
a_configuration - the configuration to usea_crossoverRatePercentage - the desired rate of crossover in
percentage of the populationa_allowFullCrossOver - true: x-over before AND after x-over point,
false: only x-over after x-over pointa_xoverNewAge - true: also x-over chromosomes with age of zero (newly
created chromosomes)
InvalidConfigurationException| Method Detail |
|---|
protected void init()
public void operate(Population a_population,
java.util.List a_candidateChromosomes)
operate in interface GeneticOperatora_population - the population of chromosomes from the current
evolution prior to exposure to crossing overa_candidateChromosomes - the pool of chromosomes that have been
selected for the next evolved population
protected void doCrossover(IChromosome firstMate,
IChromosome secondMate,
java.util.List a_candidateChromosomes,
RandomGenerator generator)
public int compareTo(java.lang.Object a_other)
compareTo in interface java.lang.Comparablea_other - the instance against which to compare this instance
public void setAllowFullCrossOver(boolean a_allowFullXOver)
a_allowFullXOver - x-over before and after a randomly chosen pointpublic boolean isAllowFullCrossOver()
public int getCrossOverRate()
public double getCrossOverRatePercent()
public void setXoverNewAge(boolean a_xoverNewAge)
a_xoverNewAge - true: also x-over chromosomes with age of zero (newly
created chromosomes)public boolean isXoverNewAge()
|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||