Package org.biojavax.ga.impl
Class AbstractGeneticAlgorithm
- java.lang.Object
-
- org.biojava.utils.AbstractChangeable
-
- 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
Fields Modifier and Type Field Description protected Populationpopulation-
Fields inherited from interface org.biojavax.ga.GeneticAlgorithm
CROSS_OVER_FUNCTION, FITNESS_FUNCTION, FUNCTION, MUTATION_FUNCTION, POPULATION, SELECTION_FUNCTION
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractGeneticAlgorithm()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CrossOverFunctiongetCrossOverFunction()FitnessFunctiongetFitnessFunction()Returns the fitness function, i.e. the class that computes the fitness of each organism in a population.MutationFunctiongetMutationFunction()PopulationgetPopulation()The registeredPopulationSelectionFunctiongetSelectionFunction()voidinitPopulation()Assigns a fitness value to each organism within the population according to the currently set fitness function.voidsetCrossOverFunction(CrossOverFunction function)Changes theCrossOverFunctionused to CrossOver ChromosomesvoidsetFitnessFunction(FitnessFunction func)The fitness function that will be used to compute the fitness of each organism.voidsetMutationFunction(MutationFunction function)Sets the currentMutationFunctionvoidsetPopulation(Population pop)Sets thePopulationofOrganismsto the Algorithm.voidsetSelectionFunction(SelectionFunction function)Changes theSelectionFunctionused 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.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
-
Methods inherited from interface org.biojavax.ga.GeneticAlgorithm
getGeneration, run
-
-
-
-
Field Detail
-
population
protected Population population
-
-
Constructor Detail
-
AbstractGeneticAlgorithm
protected AbstractGeneticAlgorithm()
-
-
Method Detail
-
getCrossOverFunction
public final CrossOverFunction getCrossOverFunction()
- Specified by:
getCrossOverFunctionin interfaceGeneticAlgorithm- Returns:
- the current CrossOverFunction
-
getFitnessFunction
public FitnessFunction getFitnessFunction()
Description copied from interface:GeneticAlgorithmReturns the fitness function, i.e. the class that computes the fitness of each organism in a population.- Specified by:
getFitnessFunctionin interfaceGeneticAlgorithm- Returns:
- the fitness function
-
getMutationFunction
public final MutationFunction getMutationFunction()
- Specified by:
getMutationFunctionin interfaceGeneticAlgorithm- Returns:
- the current
MutationFunction
-
getPopulation
public final Population getPopulation()
Description copied from interface:GeneticAlgorithmThe registeredPopulation- Specified by:
getPopulationin interfaceGeneticAlgorithm- Returns:
- the
Populationbeing operated on.
-
getSelectionFunction
public final SelectionFunction getSelectionFunction()
- Specified by:
getSelectionFunctionin interfaceGeneticAlgorithm- 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:GeneticAlgorithmChanges theCrossOverFunctionused to CrossOver Chromosomes- Specified by:
setCrossOverFunctionin interfaceGeneticAlgorithm- Parameters:
function- aCrossOverFunction- Throws:
ChangeVetoException- if theCrossOverFunctionis not allowed to be changed
-
setFitnessFunction
public final void setFitnessFunction(FitnessFunction func) throws ChangeVetoException
Description copied from interface:GeneticAlgorithmThe fitness function that will be used to compute the fitness of each organism.- Specified by:
setFitnessFunctionin interfaceGeneticAlgorithm- Parameters:
func- theFitnessFunctionto be used- Throws:
ChangeVetoException- if the change is vetoed.
-
setMutationFunction
public final void setMutationFunction(MutationFunction function) throws ChangeVetoException
Description copied from interface:GeneticAlgorithmSets the currentMutationFunction- Specified by:
setMutationFunctionin interfaceGeneticAlgorithm- Parameters:
function- aMutationFunction- Throws:
ChangeVetoException- if theMutationFunctionchange is Vetoed by a listener.
-
setPopulation
public final void setPopulation(Population pop) throws ChangeVetoException
Description copied from interface:GeneticAlgorithmSets thePopulationofOrganismsto the Algorithm.- Specified by:
setPopulationin interfaceGeneticAlgorithm- 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:GeneticAlgorithmChanges theSelectionFunctionused to select candidates for the next generation- Specified by:
setSelectionFunctionin interfaceGeneticAlgorithm- Parameters:
function- aSelectionFunction- Throws:
ChangeVetoException- if theSelectionFunctionis not allowed to be changed
-
-