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 CrossOverFunction
Returns the fitness function, i.e. the class that computes the fitness of each organism in a population.final MutationFunction
final Population
The registeredPopulation
final SelectionFunction
void
Assigns a fitness value to each organism within the population according to the currently set fitness function.final void
setCrossOverFunction
(CrossOverFunction function) Changes theCrossOverFunction
used to CrossOver Chromosomesfinal void
The fitness function that will be used to compute the fitness of each organism.final void
setMutationFunction
(MutationFunction function) Sets the currentMutationFunction
final void
setPopulation
(Population pop) Sets thePopulation
ofOrganisms
to the Algorithm.final void
setSelectionFunction
(SelectionFunction function) Changes theSelectionFunction
used to select candidates for the next generationMethods 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 Details
-
population
-
-
Constructor Details
-
AbstractGeneticAlgorithm
protected AbstractGeneticAlgorithm()
-
-
Method Details
-
getCrossOverFunction
- Specified by:
getCrossOverFunction
in interfaceGeneticAlgorithm
- Returns:
- the current CrossOverFunction
-
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 interfaceGeneticAlgorithm
- Returns:
- the fitness function
-
getMutationFunction
- Specified by:
getMutationFunction
in interfaceGeneticAlgorithm
- Returns:
- the current
MutationFunction
-
getPopulation
Description copied from interface:GeneticAlgorithm
The registeredPopulation
- Specified by:
getPopulation
in interfaceGeneticAlgorithm
- Returns:
- the
Population
being operated on.
-
getSelectionFunction
- Specified by:
getSelectionFunction
in 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:GeneticAlgorithm
Changes theCrossOverFunction
used to CrossOver Chromosomes- Specified by:
setCrossOverFunction
in interfaceGeneticAlgorithm
- Parameters:
function
- aCrossOverFunction
- Throws:
ChangeVetoException
- if theCrossOverFunction
is not allowed to be changed
-
setFitnessFunction
Description copied from interface:GeneticAlgorithm
The fitness function that will be used to compute the fitness of each organism.- Specified by:
setFitnessFunction
in interfaceGeneticAlgorithm
- Parameters:
func
- theFitnessFunction
to be used- Throws:
ChangeVetoException
- if the change is vetoed.
-
setMutationFunction
Description copied from interface:GeneticAlgorithm
Sets the currentMutationFunction
- Specified by:
setMutationFunction
in interfaceGeneticAlgorithm
- Parameters:
function
- aMutationFunction
- Throws:
ChangeVetoException
- if theMutationFunction
change is Vetoed by a listener.
-
setPopulation
Description copied from interface:GeneticAlgorithm
Sets thePopulation
ofOrganisms
to the Algorithm.- Specified by:
setPopulation
in interfaceGeneticAlgorithm
- Parameters:
pop
- the population to add.- Throws:
ChangeVetoException
- if new populations are not allowed.
-
setSelectionFunction
Description copied from interface:GeneticAlgorithm
Changes theSelectionFunction
used to select candidates for the next generation- Specified by:
setSelectionFunction
in interfaceGeneticAlgorithm
- Parameters:
function
- aSelectionFunction
- Throws:
ChangeVetoException
- if theSelectionFunction
is not allowed to be changed
-