|
Orbital library | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object orbital.algorithm.evolutionary.GeneticAlgorithm
public abstract class GeneticAlgorithm
A base class for genetic algorithms. Genetic algorithms can be used as an evolutionary search algorithm exploring (with a large population) or exploiting (with a small population) an almost arbitrary search space.
A genetic algorithm provides the following operators:
After implementing the GeneticAlgorithmProblem
interface use the
evolutionary genetic algorithm like:
Configuration config = new GeneticAlgorithm.Configuration(geneticAlgorithmProblem, Selectors.rouletteWheel(), maximumRecombination, maximumMutation, IncrementalGeneticAlgorithm.class); Population solution = (Population) config.solve();Or, if you need any additional control of the single steps, use something like:
ga = new IncrementalGeneticAlgorithm(); ga.setEvaluation(fitnessEvaluation); ga.setSelection(Selectors.rouletteWheel()); ga.setPopulation(initialPopulation); PopulationImpl pop = (PopulationImpl) ga.getPopulation(); pop.setParentCount(2); pop.setChildrenCount(2); pop.setMaximumRecombination(maximumRecombination); pop.setMaximumMutation(maximumMutation); // evolve until stop condition while (!isSolution()) { ga.evolve(); System.out.println(ga.getPopulation()); }With a problem-specific implementation of the stop condition
isSolution()
which could simply consider the number-of-generations, goodness-of-best-solution or convergence-of-population.
GeneticAlgorithmProblem
,
HillClimbing
,
Random
,
"Goldberg, D. E. Genetic Algorithms in Search, Optimization and Machine Learning. .1989.",
"Friedberg, R.M. A learning machine: Part I. IBM Journal, 2:2-13, 1958.",
"Holland, J. H. Adaption in Natural and Artificial Systems. University of Michigan Press. 1975.",
Serialized FormNested Class Summary | |
---|---|
static class |
GeneticAlgorithm.Configuration
Algorithmic configuration objects for genetic algorithms. |
Constructor Summary | |
---|---|
protected |
GeneticAlgorithm()
Construct a new GeneticAlgorithm. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Returns a deep copy of this exact type of genetic algorithm. |
Function |
complexity()
Measure for the asymptotic time complexity of the central solution operation in O-notation. |
boolean |
equals(java.lang.Object o)
|
abstract void |
evolve()
evolves to the next generation for this population. |
Function |
getEvaluation()
Get the evaluation function. |
Population |
getPopulation()
Get the Population for this GeneticAlgorithm. |
abstract double |
getPopulationGrowth()
Get the population growth factor. |
java.util.Random |
getRandom()
Get the random-generator used as probabilistic random source. |
Function |
getSelection()
Get the selection scheme to apply while evolving. |
int |
hashCode()
|
boolean |
isCorrect()
Whether this algorithm is correct. |
void |
setEvaluation(Function fitnessEvaluation)
Set the evaluation function. |
void |
setPopulation(Population pop)
Set the Population for this GeneticAlgorithm. |
void |
setRandom(java.util.Random randomGenerator)
Set the random-generator to use as probabilistic random source. |
void |
setSelection(Function selector)
Set the selection scheme to apply while evolving. |
java.lang.Object |
solve(AlgorithmicProblem gproblem)
Solve a genetic algorithm problem. |
Function |
spaceComplexity()
Measure for the asymptotic space complexity of the central solution operation in O-notation. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected GeneticAlgorithm()
Method Detail |
---|
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public abstract double getPopulationGrowth()
public Function getSelection()
public void setSelection(Function selector)
selector
- the selection function Population→Genome for selecting parents.Selectors
public Population getPopulation()
public void setPopulation(Population pop)
public Function getEvaluation()
public void setEvaluation(Function fitnessEvaluation)
fitnessEvaluation
- the evaluation function that specifies the algorithm for evaluation of a Genome's fitness.
It must be set before use and is concrete problem-specific.public java.util.Random getRandom()
ProbabilisticAlgorithm
getRandom
in interface ProbabilisticAlgorithm
public void setRandom(java.util.Random randomGenerator)
ProbabilisticAlgorithm
Especially called to change the random source to a previous, more secure, or more realistic generator.
setRandom
in interface ProbabilisticAlgorithm
public boolean isCorrect()
ProbabilisticAlgorithm
isCorrect
in interface ProbabilisticAlgorithm
public Function complexity()
AlgorithmicTemplate
complexity
in interface AlgorithmicTemplate
AlgorithmicTemplate.solve(AlgorithmicProblem)
public Function spaceComplexity()
AlgorithmicTemplate
spaceComplexity
in interface AlgorithmicTemplate
AlgorithmicTemplate.solve(AlgorithmicProblem)
public java.lang.Object solve(AlgorithmicProblem gproblem)
selector
has already been set.
solve
in interface AlgorithmicTemplate
gproblem
- algorithmic problem hook class which must fit the concrete
algorithmic template framework implementation.
isSolution
.setEvaluation(Function)
,
GeneticAlgorithmProblem.getEvaluation()
,
setPopulation(Population)
,
GeneticAlgorithmProblem.getPopulation()
,
evolve()
public abstract void evolve()
selection
,
Genome.recombine(Gene[],int,double)
,
PopulationImpl.getMaximumRecombination()
,
PopulationImpl.getMaximumMutation()
|
Orbital library 1.3.0: 11 Apr 2009 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |