JGAP

org.jgap.impl
Class InversionOperator

java.lang.Object
  extended by org.jgap.BaseGeneticOperator
      extended by org.jgap.impl.InversionOperator
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, GeneticOperator

public class InversionOperator
extends BaseGeneticOperator

The inversion operator randomly selects one chromosomes from the population and inverses it by randomly picking a splitting locus on which to swap the first part with the last part of the chromosome.

Since:
2.3
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jgap.BaseGeneticOperator
m_monitor, m_monitorActive
 
Constructor Summary
InversionOperator()
          Default constructor.
InversionOperator(Configuration a_config)
          Constructs a new instance of this operator.
 
Method Summary
 int compareTo(java.lang.Object a_other)
          Compares the given GeneticOperator to this GeneticOperator.
 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 org.jgap.BaseGeneticOperator
equals, getConfiguration
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InversionOperator

public InversionOperator()
                  throws InvalidConfigurationException
Default constructor.

Attention: The configuration used is the one set with the static method Genotype.setConfiguration.

Throws:
InvalidConfigurationException
Since:
2.3

InversionOperator

public InversionOperator(Configuration a_config)
                  throws InvalidConfigurationException
Constructs a new instance of this operator.

Parameters:
a_config - the configuration to use
Throws:
InvalidConfigurationException
Since:
3.0
Method Detail

operate

public void operate(Population a_population,
                    java.util.List a_candidateChromosomes)
Description copied from interface: GeneticOperator
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. The parameters a_population and a_candidateChromosomes may refer to the same list of chromosomes for performance issues. Thus would mean an in-place modification. In ealier JGAP versions it was suggested never modifying the input population. Please refer to implementations delivered with JGAP to get a picture of the way non-susceptible in-place modifications are possible. If wrongly done, ConcurrentModificationException could be risen when accessing the population by an iterator in a GeneticOperator. Or, if population.getChromosomes().size() was used inside a loop where chromosomes were added to the input population this could lead to an infinite loop in worst case.

Parameters:
a_population - the population to operate on
a_candidateChromosomes - resulting chromosomes
Since:
2.3

compareTo

public int compareTo(java.lang.Object a_other)
Compares the given GeneticOperator to this GeneticOperator.

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

JGAP