org.biojavax.ga.impl
Class AbstractGeneticAlgorithm

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

public abstract class AbstractGeneticAlgorithm
extends AbstractChangeable
implements GeneticAlgorithm

Base class from which most implementations of GeneticAlgorithm will inherit.

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

Field Summary
protected  Population population
           
 
Fields inherited from interface org.biojavax.ga.GeneticAlgorithm
CROSS_OVER_FUNCTION, FITNESS_FUNCTION, FUNCTION, MUTATION_FUNCTION, POPULATION, SELECTION_FUNCTION
 
Constructor Summary
protected AbstractGeneticAlgorithm()
           
 
Method Summary
 CrossOverFunction getCrossOverFunction()
           
 FitnessFunction getFitnessFunction()
          Returns the fitness function, i.e.
 MutationFunction getMutationFunction()
           
 Population getPopulation()
          The registered Population
 SelectionFunction getSelectionFunction()
           
 void initPopulation()
          Assigns a fitness value to each organism within the population according to the currently set fitness function.
 void setCrossOverFunction(CrossOverFunction function)
          Changes the CrossOverFunction used to CrossOver Chromosomes
 void setFitnessFunction(FitnessFunction func)
          The fitness function that will be used to compute the fitness of each organism.
 void setMutationFunction(MutationFunction function)
          Sets the current MutationFunction
 void setPopulation(Population pop)
          Sets the Population of Organisms to the Algorithm.
 void setSelectionFunction(SelectionFunction function)
          Changes the SelectionFunction used to select candidates for the next generation
 
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.biojavax.ga.GeneticAlgorithm
getGeneration, run
 
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 

Field Detail

population

protected Population population
Constructor Detail

AbstractGeneticAlgorithm

protected AbstractGeneticAlgorithm()
Method Detail

getCrossOverFunction

public final CrossOverFunction getCrossOverFunction()
Specified by:
getCrossOverFunction in interface GeneticAlgorithm
Returns:
the current CrossOverFunction

getFitnessFunction

public FitnessFunction getFitnessFunction()
Description copied from interface: GeneticAlgorithm
Returns the fitness function, i.e. the class that computes the fitness of each organism in a population.

Specified by:
getFitnessFunction in interface GeneticAlgorithm
Returns:
the fitness function

getMutationFunction

public final MutationFunction getMutationFunction()
Specified by:
getMutationFunction in interface GeneticAlgorithm
Returns:
the current MutationFunction

getPopulation

public final Population getPopulation()
Description copied from interface: GeneticAlgorithm
The registered Population

Specified by:
getPopulation in interface GeneticAlgorithm
Returns:
the Population being operated on.

getSelectionFunction

public final SelectionFunction getSelectionFunction()
Specified by:
getSelectionFunction in interface GeneticAlgorithm
Returns:
the current SelectionFunction

initPopulation

public void initPopulation()
Assigns a fitness value to each organism within the population according to the currently set fitness function. If no population or no fitness function is set, nothing will happen.


setCrossOverFunction

public final void setCrossOverFunction(CrossOverFunction function)
                                throws ChangeVetoException
Description copied from interface: GeneticAlgorithm
Changes the CrossOverFunction used to CrossOver Chromosomes

Specified by:
setCrossOverFunction in interface GeneticAlgorithm
Parameters:
function - a CrossOverFunction
Throws:
ChangeVetoException - if the CrossOverFunction is not allowed to be changed

setFitnessFunction

public final void setFitnessFunction(FitnessFunction func)
                              throws ChangeVetoException
Description copied from interface: GeneticAlgorithm
The fitness function that will be used to compute the fitness of each organism.

Specified by:
setFitnessFunction in interface GeneticAlgorithm
Parameters:
func - the FitnessFunction to be used
Throws:
ChangeVetoException - if the change is vetoed.

setMutationFunction

public final void setMutationFunction(MutationFunction function)
                               throws ChangeVetoException
Description copied from interface: GeneticAlgorithm
Sets the current MutationFunction

Specified by:
setMutationFunction in interface GeneticAlgorithm
Parameters:
function - a MutationFunction
Throws:
ChangeVetoException - if the MutationFunction change is Vetoed by a listener.

setPopulation

public final void setPopulation(Population pop)
                         throws ChangeVetoException
Description copied from interface: GeneticAlgorithm
Sets the Population of Organisms to the Algorithm.

Specified by:
setPopulation in interface GeneticAlgorithm
Parameters:
pop - the population to add.
Throws:
ChangeVetoException - if new populations are not allowed.

setSelectionFunction

public final void setSelectionFunction(SelectionFunction function)
                                throws ChangeVetoException
Description copied from interface: GeneticAlgorithm
Changes the SelectionFunction used to select candidates for the next generation

Specified by:
setSelectionFunction in interface GeneticAlgorithm
Parameters:
function - a SelectionFunction
Throws:
ChangeVetoException - if the SelectionFunction is not allowed to be changed