org.jgap.impl
Class CrossoverOperator

java.lang.Object
  extended byorg.jgap.impl.CrossoverOperator
All Implemented Interfaces:
GeneticOperator, java.io.Serializable

public class CrossoverOperator
extends java.lang.Object
implements GeneticOperator

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. 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. A dynamic rate is one determined by this class if no fixed rate is provided.

Since:
1.0
Author:
Neil Rotstan, Klaus Meffert, Chris Knowles
See Also:
Serialized Form

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(int a_desiredCrossoverRate)
          Constructs a new instance of this CrossoverOperator with the given crossover rate.
CrossoverOperator(IUniversalRateCalculator a_crossoverRateCalculator)
          Constructs a new instance of this CrossoverOperator with a specified crossover rate calculator, which results in dynamic crossover being turned on.
 
Method Summary
 void operate(Population a_population, java.util.List a_candidateChromosomes)
          The operate method will be invoked on each of the genetic operators referenced by the current Configuration object during the evolution phase.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CrossoverOperator

public CrossoverOperator()
Constructs a new instance of this CrossoverOperator without a specified crossover rate, this results in dynamic crossover rate being turned off. This means that the crossover rate will be fixed at populationsize\2.

Since:
2.0

CrossoverOperator

public CrossoverOperator(IUniversalRateCalculator a_crossoverRateCalculator)
Constructs a new instance of this CrossoverOperator with a specified crossover rate calculator, which results in dynamic crossover being turned on.

Parameters:
a_crossoverRateCalculator - calculator for dynamic crossover rate computation
Since:
2.0

CrossoverOperator

public CrossoverOperator(int a_desiredCrossoverRate)
Constructs a new instance of this CrossoverOperator with the given crossover rate.

Parameters:
a_desiredCrossoverRate - The desired rate of crossover.
Since:
2.0
Method Detail

operate

public void operate(Population a_population,
                    java.util.List a_candidateChromosomes)
The operate method will be invoked on each of the genetic operators referenced by the current Configuration object during the evolution phase. Operators are given an opportunity to run in the order that they are added to the Configuration. Implementations of this method may reference the population of Chromosomes as it was at the beginning of the evolutionary phase and/or they may instead reference the candidate Chromosomes, which are the results of prior genetic operators. In either case, only Chromosomes added to the list of candidate chromosomes will be considered for natural selection. Implementations should never modify the original population, but should first make copies of the Chromosomes selected for modification and operate upon the copies.

Specified by:
operate in interface GeneticOperator
Parameters:
a_population - The population of chromosomes from the current evolution prior to exposure to any genetic operators. Chromosomes in this array should never be modified.
a_candidateChromosomes - The pool of chromosomes that are candidates for the next evolved population. Only these chromosomes will go to the natural phase, so it's important to add any modified copies of Chromosomes to this list if it's desired for them to be considered for natural selection.
Since:
2.0 (earlier versions referenced the Configuration object)