jaga.evolve
Class AdaptiveMutator

java.lang.Object
  |
  +--jaga.evolve.AdaptiveMutator
All Implemented Interfaces:
GeneticOperator, java.io.Serializable

public class AdaptiveMutator
extends java.lang.Object
implements GeneticOperator

AdaptiveMutator throttles the mutation rate based on variety of the population.

The variety is calculated as the Hamming distance and in this implementation a rough estimate is achieved by taking the average of the hamming distances of 2 * popSize randomly selected individuals.

Minimum mutation rate is applied when we have a perfectly random population and average hamming distance per bit is 0.5.

Maximum mutation rate is applied when all individuals are equal and hamming distance is 0.

This operator works with variable length genotypes.

See Also:
Serialized Form

Constructor Summary
AdaptiveMutator(double lowMut, double highMut)
          Creates new AdaptiveMutator
 
Method Summary
 double getAvgHammingPerBit(Population pop)
          Avg hamming distance / Avg genotype length
 void operate(Selector selector, Population oldPopulation, Population newPopulation, int howMany)
          method that adds genotypes to the new population by extracting some from the old one and manipulating them in some way.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AdaptiveMutator

public AdaptiveMutator(double lowMut,
                       double highMut)
Creates new AdaptiveMutator
Parameters:
highMut - maximum mutations per genotype for when population stagnant.
lowMut - minimum mutations per genotype for when population random.
Method Detail

operate

public void operate(Selector selector,
                    Population oldPopulation,
                    Population newPopulation,
                    int howMany)
method that adds genotypes to the new population by extracting some from the old one and manipulating them in some way.
Specified by:
operate in interface GeneticOperator
Parameters:
oldPopulation - in parameter having all the original genotypes
newPopulation - in/out parameter where the next generation of genotypes is being built
howMany - how many new genotypes to add to the new population

getAvgHammingPerBit

public double getAvgHammingPerBit(Population pop)
Avg hamming distance / Avg genotype length

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object