org.biojavax.ga.impl
Class SimpleGeneticAlgorithm

java.lang.Object
  extended by org.biojava.utils.AbstractChangeable
      extended by org.biojavax.ga.impl.AbstractGeneticAlgorithm
          extended by org.biojavax.ga.impl.SimpleGeneticAlgorithm
All Implemented Interfaces:
Changeable, GeneticAlgorithm

public final class SimpleGeneticAlgorithm
extends AbstractGeneticAlgorithm

A simple implementation of the GeneticAlgorithm interface it is not intended that this class be overidden, hence it is final. It is much better to overide AbstractGeneticAlgorithm.

Since:
1.5
Version:
1.1
Author:
Mark Schreiber, Susanne Merz, Andreas Dräger

Field Summary
 
Fields inherited from class org.biojavax.ga.impl.AbstractGeneticAlgorithm
population
 
Fields inherited from interface org.biojavax.ga.GeneticAlgorithm
CROSS_OVER_FUNCTION, FITNESS_FUNCTION, FUNCTION, MUTATION_FUNCTION, POPULATION, SELECTION_FUNCTION
 
Constructor Summary
SimpleGeneticAlgorithm()
           
SimpleGeneticAlgorithm(Population pop, MutationFunction mutFunc, CrossOverFunction xFunc, SelectionFunction selFunc)
           
 
Method Summary
 List getCrossResults()
          Get a List containing details of all the cross over events during the run.
 int getGeneration()
          The current generation
 void run(GAStoppingCriteria stoppingCriteria)
          Iterates the Algorithm until the stopping criteria are met.
 
Methods inherited from class org.biojavax.ga.impl.AbstractGeneticAlgorithm
getCrossOverFunction, getFitnessFunction, getMutationFunction, getPopulation, getSelectionFunction, initPopulation, setCrossOverFunction, setFitnessFunction, setMutationFunction, setPopulation, setSelectionFunction
 
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 

Constructor Detail

SimpleGeneticAlgorithm

public SimpleGeneticAlgorithm()

SimpleGeneticAlgorithm

public SimpleGeneticAlgorithm(Population pop,
                              MutationFunction mutFunc,
                              CrossOverFunction xFunc,
                              SelectionFunction selFunc)
Method Detail

getGeneration

public int getGeneration()
The current generation

Returns:
an int giving the generation number

getCrossResults

public List getCrossResults()
Get a List containing details of all the cross over events during the run. If run(GAStoppingCriteria stoppingCriteria) has not yet been called the list will be empty. This implementation only stores a buffer of the last 100 crosses for memory reasons.

Returns:
a List of GACrossResult objects.

run

public void run(GAStoppingCriteria stoppingCriteria)
         throws ChangeVetoException,
                IllegalAlphabetException,
                IllegalSymbolException
Description copied from interface: GeneticAlgorithm
Iterates the Algorithm until the stopping criteria are met. For saftey implementations should synchronize on this method.

Parameters:
stoppingCriteria - determines when to stop.
Throws:
ChangeVetoException - if the Population being modified is locked
IllegalAlphabetException - if the MutationFunction chosen attempts to modify a Symbol from one of the Chromosomes to a Symbol outside of its Alphabet.
IllegalSymbolException - if the MutationFunction chosen is using the wrong Alphabet.