public abstract class AbstractGeneticAlgorithm extends AbstractChangeable implements GeneticAlgorithm
Modifier and Type | Field and Description |
---|---|
protected Population |
population |
CROSS_OVER_FUNCTION, FITNESS_FUNCTION, FUNCTION, MUTATION_FUNCTION, POPULATION, SELECTION_FUNCTION
Modifier | Constructor and Description |
---|---|
protected |
AbstractGeneticAlgorithm() |
Modifier and Type | Method and 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 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 |
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getGeneration, run
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
protected Population population
protected AbstractGeneticAlgorithm()
public final CrossOverFunction getCrossOverFunction()
getCrossOverFunction
in interface GeneticAlgorithm
public FitnessFunction getFitnessFunction()
GeneticAlgorithm
getFitnessFunction
in interface GeneticAlgorithm
public final MutationFunction getMutationFunction()
getMutationFunction
in interface GeneticAlgorithm
MutationFunction
public final Population getPopulation()
GeneticAlgorithm
Population
getPopulation
in interface GeneticAlgorithm
Population
being operated on.public final SelectionFunction getSelectionFunction()
getSelectionFunction
in interface GeneticAlgorithm
SelectionFunction
public void initPopulation()
public final void setCrossOverFunction(CrossOverFunction function) throws ChangeVetoException
GeneticAlgorithm
CrossOverFunction
used to CrossOver ChromosomessetCrossOverFunction
in interface GeneticAlgorithm
function
- a CrossOverFunction
ChangeVetoException
- if the CrossOverFunction
is not allowed to be
changedpublic final void setFitnessFunction(FitnessFunction func) throws ChangeVetoException
GeneticAlgorithm
setFitnessFunction
in interface GeneticAlgorithm
func
- the FitnessFunction
to be usedChangeVetoException
- if the change is vetoed.public final void setMutationFunction(MutationFunction function) throws ChangeVetoException
GeneticAlgorithm
MutationFunction
setMutationFunction
in interface GeneticAlgorithm
function
- a MutationFunction
ChangeVetoException
- if the MutationFunction
change is Vetoed by a
listener.public final void setPopulation(Population pop) throws ChangeVetoException
GeneticAlgorithm
Population
of Organisms
to the
Algorithm.setPopulation
in interface GeneticAlgorithm
pop
- the population to add.ChangeVetoException
- if new populations are not allowed.public final void setSelectionFunction(SelectionFunction function) throws ChangeVetoException
GeneticAlgorithm
SelectionFunction
used to select candidates for
the next generationsetSelectionFunction
in interface GeneticAlgorithm
function
- a SelectionFunction
ChangeVetoException
- if the SelectionFunction
is not allowed to be
changedCopyright © 2014 BioJava. All rights reserved.