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
FieldsFields inherited from interface org.biojavax.ga.GeneticAlgorithm
CROSS_OVER_FUNCTION, FITNESS_FUNCTION, FUNCTION, MUTATION_FUNCTION, POPULATION, SELECTION_FUNCTION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal CrossOverFunctionReturns the fitness function, i.e. the class that computes the fitness of each organism in a population.final MutationFunctionfinal PopulationThe registeredPopulationfinal SelectionFunctionvoidAssigns a fitness value to each organism within the population according to the currently set fitness function.final voidsetCrossOverFunction(CrossOverFunction function) Changes theCrossOverFunctionused to CrossOver Chromosomesfinal voidThe fitness function that will be used to compute the fitness of each organism.final voidsetMutationFunction(MutationFunction function) Sets the currentMutationFunctionfinal voidsetPopulation(Population pop) Sets thePopulationofOrganismsto the Algorithm.final voidsetSelectionFunction(SelectionFunction function) Changes theSelectionFunctionused to select candidates for the next generationMethods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListenerMethods inherited from interface org.biojavax.ga.GeneticAlgorithm
getGeneration, run
-
Field Details
-
population
-
-
Constructor Details
-
AbstractGeneticAlgorithm
protected AbstractGeneticAlgorithm()
-
-
Method Details
-
getCrossOverFunction
- Specified by:
getCrossOverFunctionin interfaceGeneticAlgorithm- Returns:
- the current CrossOverFunction
-
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
- Specified by:
getMutationFunctionin interfaceGeneticAlgorithm- Returns:
- the current
MutationFunction
-
getPopulation
Description copied from interface:GeneticAlgorithmThe registeredPopulation- Specified by:
getPopulationin interfaceGeneticAlgorithm- Returns:
- the
Populationbeing operated on.
-
getSelectionFunction
- Specified by:
getSelectionFunctionin interfaceGeneticAlgorithm- Returns:
- the current
SelectionFunction
-
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
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
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
Description copied from interface:GeneticAlgorithmSets the currentMutationFunction- Specified by:
setMutationFunctionin interfaceGeneticAlgorithm- Parameters:
function- aMutationFunction- Throws:
ChangeVetoException- if theMutationFunctionchange is Vetoed by a listener.
-
setPopulation
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
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
-