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 Population
population
-
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 protected
AbstractGeneticAlgorithm()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CrossOverFunction
getCrossOverFunction()
FitnessFunction
getFitnessFunction()
Returns the fitness function, i.e. the class that computes the fitness of each organism in a population.MutationFunction
getMutationFunction()
Population
getPopulation()
The registeredPopulation
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 theCrossOverFunction
used to CrossOver Chromosomesvoid
setFitnessFunction(FitnessFunction func)
The fitness function that will be used to compute the fitness of each organism.void
setMutationFunction(MutationFunction function)
Sets the currentMutationFunction
void
setPopulation(Population pop)
Sets thePopulation
ofOrganisms
to the Algorithm.void
setSelectionFunction(SelectionFunction function)
Changes theSelectionFunction
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.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:
getCrossOverFunction
in interfaceGeneticAlgorithm
- 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 interfaceGeneticAlgorithm
- Returns:
- the fitness function
-
getMutationFunction
public final MutationFunction getMutationFunction()
- Specified by:
getMutationFunction
in interfaceGeneticAlgorithm
- Returns:
- the current
MutationFunction
-
getPopulation
public final Population getPopulation()
Description copied from interface:GeneticAlgorithm
The registeredPopulation
- Specified by:
getPopulation
in interfaceGeneticAlgorithm
- Returns:
- the
Population
being operated on.
-
getSelectionFunction
public final SelectionFunction getSelectionFunction()
- Specified by:
getSelectionFunction
in 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: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
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 interfaceGeneticAlgorithm
- Parameters:
func
- theFitnessFunction
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 currentMutationFunction
- Specified by:
setMutationFunction
in interfaceGeneticAlgorithm
- Parameters:
function
- aMutationFunction
- Throws:
ChangeVetoException
- if theMutationFunction
change is Vetoed by a listener.
-
setPopulation
public final void setPopulation(Population pop) throws ChangeVetoException
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
public final void setSelectionFunction(SelectionFunction function) throws ChangeVetoException
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
-
-