org.jgap.impl
Class SwappingMutationOperator

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

public class SwappingMutationOperator
extends MutationOperator

Swaps the genes instead of mutating them. This kind of operator is required by Traveling Salesman Problem.

Since:
2.0
Author:
Audrius Meskauskas, Neil Rotstan, Klaus Meffert (reused code from MutationOperator)
See Also:
Grefenstette, R. Gopal, R. Rosmaita, and D. Gucht. Genetic algorithms for the traveling salesman problem. In Proceedings of the Second International Conference on Genetic Algorithms. Lawrence Eribaum Associates, Mahwah, NJ, 1985. and also {@link http://ecsl.cs.unr.edu/docs/techreports/gong/node3.html Sushil J. Louis & Gong Li }, Serialized Form

Constructor Summary
SwappingMutationOperator()
          {@inheritDoc}
SwappingMutationOperator(int a_desiredMutationRate)
          {@inheritDoc}
SwappingMutationOperator(IUniversalRateCalculator a_mutationRateCalculator)
          {@inheritDoc}
 
Method Summary
 int getStartOffset()
          Gets a number of genes at the start of chromosome, that are excluded from the swapping.
 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.
 void setStartOffset(int a_offset)
          Sets a number of genes at the start of chromosome, that are excluded from the swapping.
 
Methods inherited from class org.jgap.impl.MutationOperator
getMutationRateCalc, setMutationRateCalc
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwappingMutationOperator

public SwappingMutationOperator()
{@inheritDoc}


SwappingMutationOperator

public SwappingMutationOperator(IUniversalRateCalculator a_mutationRateCalculator)
{@inheritDoc}


SwappingMutationOperator

public SwappingMutationOperator(int a_desiredMutationRate)
{@inheritDoc}

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
Overrides:
operate in class MutationOperator
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.

setStartOffset

public void setStartOffset(int a_offset)
Sets a number of genes at the start of chromosome, that are excluded from the swapping. In the Salesman task, the first city in the list should (where the salesman leaves from) probably should not change as it is part of the list. The default value is 1.


getStartOffset

public int getStartOffset()
Gets a number of genes at the start of chromosome, that are excluded from the swapping. In the Salesman task, the first city in the list should (where the salesman leaves from) probably should not change as it is part of the list. The default value is 1.