|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.generation5.bio.GeneticAlgorithm
GeneticAlgorithm will evolve anything that implements the
Evolvable interface. The genetic algorithm implements
Steppable, with each step of the GA being implemented within
doStep.
Currently, only elitism is supported.
Steppable,
Steppable.doStep(),
Evolvable| Field Summary | |
protected double |
averageFitness
The average fitness for this generation. |
protected java.util.LinkedList |
averageFitnesses
The average fitness linked list. |
protected java.util.LinkedList |
bestFitnesses
The best fitness linked list. |
protected int |
currentIteration
The current iteration of the genetic algorithm, incremented upon each call to doStep. |
protected double |
elitePercentage
The percentage of elites to copy to the new population (defaults to 0.05, or 5%). |
protected boolean |
logData
Determines whether average and best fitness data should be logged. |
protected int |
maximumDataPoints
The maximum number of data points to store in the linked lists. |
protected int |
maximumIterations
The maximum number of iterations (currently unused). |
protected double |
mutationRate
The mutation rate (default to 0.05, or 5%). |
protected Evolvable[][] |
population
The population to evolve. |
| Constructor Summary | |
GeneticAlgorithm()
Creates a new instance of GeneticAlgorithm |
|
GeneticAlgorithm(Evolvable[] population)
Create a instance of the genetic algorithm with an initial population. |
|
| Method Summary | |
void |
doStep()
Steps through one iteration of the genetic algorithm. |
protected void |
flipBuffer()
Flips the genetic algorithm buffer. |
double |
getAverageFitness()
Return the average fitness of this generation. |
java.util.LinkedList |
getAverageFitnesses()
Return the average fitness linked list. |
Evolvable |
getBest()
Retrieves the best Evolvable in the population. |
double |
getBestFitness()
Retrieves the best fitness level. |
java.util.LinkedList |
getBestFitnesses()
Return the best fitness linked list. |
int |
getCurrentIteration()
Return the current iteration of the genetic algorithm. |
Evolvable[] |
getCurrentPopulation()
Return the current population (double-buffering taken into account). |
int |
getMaximumDataPoints()
Returns the maximum number of data points the GA is logging. |
double |
getMutationRate()
Retrieve the current mutation rate. |
void |
init()
Initialize the genetic algorithm. |
protected Evolvable[] |
inPopulation()
The current population |
protected Evolvable[] |
outPopulation()
The new population. |
void |
reset()
Resets the genetic algorithm. |
void |
setMaximumDataPoints(int mdp)
Set the maximum number of data points that the GA should log. |
void |
setMutationRate(double mr)
Set the mutation rate (should generally be between 0.0 and 0.2). |
void |
setPopulation(Evolvable[] thisPopulation)
Set the population to an initial array of Evolvables. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Evolvable[][] population
doStep and getBest for more information.
doStep(),
getBest()protected int currentIteration
doStep.
protected int maximumIterations
protected double elitePercentage
protected double mutationRate
protected double averageFitness
protected boolean logData
protected int maximumDataPoints
protected java.util.LinkedList averageFitnesses
PlotPoint,
Plot2Dprotected java.util.LinkedList bestFitnesses
PlotPoint,
Plot2D| Constructor Detail |
public GeneticAlgorithm()
public GeneticAlgorithm(Evolvable[] population)
population - the initial population.| Method Detail |
public java.util.LinkedList getAverageFitnesses()
public java.util.LinkedList getBestFitnesses()
public void setPopulation(Evolvable[] thisPopulation)
thisPopulation - the population to assign to the genetic algorithm.Evolvablepublic Evolvable[] getCurrentPopulation()
protected void flipBuffer()
protected Evolvable[] inPopulation()
protected Evolvable[] outPopulation()
public void doStep()
doStep also implements elitism and mutation.
Note that at the end of the iteration, flipBuffer is called. This
means that the inPopulation returns the new, unsorted population
and outPopulation returns the "current", sorted population.
doStep in interface Steppablepublic void setMutationRate(double mr)
mr - the mutation rate.public double getMutationRate()
public void init()
init in interface Steppablepublic Evolvable getBest()
Evolvable in the population. It is assumed that
getBest is called after doStep, therefore the
best population member will be equal to outPopulation()[0].
Evolvable in the population.outPopulation()public double getBestFitness()
getBest,
so the assumptions remain the same.
public double getAverageFitness()
public void reset()
reset in interface Steppableinit()public int getCurrentIteration()
public void setMaximumDataPoints(int mdp)
mdp - maximum number of data points to log.public int getMaximumDataPoints()
|
This documentation is part of the Generation5 JDK.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||