/*
* BioJava development code This code may be freely distributed and modified
* under the terms of the GNU Lesser General Public Licence. This should be
* distributed with the code. If you do not have a copy, see:
* http://www.gnu.org/copyleft/lesser.html Copyright for this code is held
* jointly by the individual authors. These should be listed in @author doc
* comments. For more information on the BioJava project and its aims, or to
* join the biojava-l mailing list, visit the home page at:
* http://www.biojava.org/
*/
package org.biojavax.ga;
import org.biojava.bio.symbol.IllegalAlphabetException;
import org.biojava.bio.symbol.IllegalSymbolException;
import org.biojava.utils.ChangeType;
import org.biojava.utils.ChangeVetoException;
import org.biojava.utils.Changeable;
import org.biojavax.ga.functions.CrossOverFunction;
import org.biojavax.ga.functions.FitnessFunction;
import org.biojavax.ga.functions.MutationFunction;
import org.biojavax.ga.functions.SelectionFunction;
/**
* The class that runs the cycles of reproduction, evolution and selection,
* potentially on multiple Population
s
*
FitnessFunction
to be used
* @throws ChangeVetoException
* if the change is vetoed.
*/
public void setFitnessFunction(FitnessFunction func)
throws ChangeVetoException;
/**
* Returns the fitness function, i.e. the class that computes the fitness of
* each organism in a population.
*
* @return the fitness function
*/
public FitnessFunction getFitnessFunction();
/**
* Sets the Population
of Organisms
to the
* Algorithm.
*
* @param pop
* the population to add.
* @throws ChangeVetoException
* if new populations are not allowed.
*/
public void setPopulation(Population pop) throws ChangeVetoException;
/**
* The registered Population
*
* @return the Population
being operated on.
*/
public Population getPopulation();
/**
* Changes the SelectionFunction
used to select candidates for
* the next generation
*
* @param function
* a SelectionFunction
* @throws ChangeVetoException
* if the SelectionFunction
is not allowed to be
* changed
*/
public void setSelectionFunction(SelectionFunction function)
throws ChangeVetoException;
/**
* @return the current SelectionFunction
*/
public SelectionFunction getSelectionFunction();
/**
* Changes the CrossOverFunction
used to CrossOver Chromosomes
*
* @param function
* a CrossOverFunction
* @throws ChangeVetoException
* if the CrossOverFunction
is not allowed to be
* changed
*/
public void setCrossOverFunction(CrossOverFunction function)
throws ChangeVetoException;
/**
* @return the current CrossOverFunction
*/
public CrossOverFunction getCrossOverFunction();
/**
* Sets the current MutationFunction
*
* @param function
* a MutationFunction
* @throws ChangeVetoException
* if the MutationFunction
change is Vetoed by a
* listener.
*/
public void setMutationFunction(MutationFunction function)
throws ChangeVetoException;
/**
* @return the current MutationFunction
*/
public MutationFunction getMutationFunction();
/**
* @return the Current generation number
*/
public int getGeneration();
/**
* Iterates the Algorithm until the stopping criteria are met. For saftey
* implementations should synchronize on this method.
*
* @param stoppingCriteria
* determines when to stop.
* @throws ChangeVetoException
* if the Population being modified is locked
* @throws IllegalAlphabetException
* if the MutationFunction chosen attempts to modify a Symbol from
* one of the Chromosomes to a Symbol outside of its Alphabet.
* @throws IllegalSymbolException
* if the MutationFunction chosen is using the wrong Alphabet.
*/
public void run(GAStoppingCriteria stoppingCriteria)
throws ChangeVetoException, IllegalAlphabetException,
IllegalSymbolException;
public static ChangeType POPULATION = new ChangeType(
"Population changed",
GeneticAlgorithm.class,
"POPULATION");
public static ChangeType FUNCTION = new ChangeType(
"Function changed",
GeneticAlgorithm.class,
"FUNCTION");
public static ChangeType CROSS_OVER_FUNCTION = new ChangeType(
"Cross over function changed",
GeneticAlgorithm.class,
"CROSS_OVER_FUNCTION",
FUNCTION);
public static ChangeType MUTATION_FUNCTION = new ChangeType(
"Mutation function changed",
GeneticAlgorithm.class,
"MUTATION_FUNCTION",
FUNCTION);
public static ChangeType SELECTION_FUNCTION = new ChangeType(
"Selection function changed",
GeneticAlgorithm.class,
"SELECTION_FUNCTION",
FUNCTION);
}