|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.computing.ai.evolutionary.geneticprogramming.GeneticProgram
public class GeneticProgram
Genetic program implementation.
| Field Summary | |
|---|---|
static int |
GENERATION_FULL
"Full" generation method |
static int |
GENERATION_GROW
"Grow" generation method |
static int |
GENERATION_RAMPED_HALF_AND_HALF
"Ramped Half and Half" generation method |
static int |
SELECTION_FITNESS_PROPORTIONATE
"Fitness-Proportionate" seleciton method |
static int |
SELECTION_TOURNAMENT
"Tournament" selection method |
| Constructor Summary | |
|---|---|
GeneticProgram(int populationSize,
FitnessFunction fitnessFunction,
Terminal[] terminalSet,
Function[] functionSet)
Creates a genetic program with given parameters. |
|
GeneticProgram(int populationSize,
FitnessFunction fitnessFunction,
Terminal[] terminalSet,
Function[] functionSet,
int generationMethod,
int selectionMethod)
Creates a genetic program with given parameters. |
|
| Method Summary | |
|---|---|
void |
createArgumentsForFunction(Function function,
int allowableDepth,
boolean fullP)
Creates arguments for the given function |
Program |
createIndividualProgram(int allowableDepth,
boolean topNodeP,
boolean fullP)
Creates an individual randomly with given pramaters |
void |
createPopulation()
Creates the initial population |
Program[] |
crossover(Program male,
Program female)
Produces two new individuals by crossing over two parents. |
void |
evolve()
Evolves the population for one generation |
Individual |
findIndividual()
Finds an individual based on selection criteria used in this genetic program |
Individual |
findIndividualUsingFitnessProportionateSelection(double afterThisFitness)
Finds an individual using fitness proportionate selection |
Individual |
findIndividualUsingTournamentSelection()
Finds an individual using tournament selection |
double |
getAverageAdjustedFitnessOfCurrentGeneration()
Returns the average adjusted fitness of the current generation |
double |
getAverageNormalizedFitnessOfCurrentGeneration()
Returns the average normalized fitness of the current generation |
double |
getAverageStandardizedFitnessOfCurrentGeneration()
Returns the average standardized fitness of the current generation |
Individual |
getBestIndividual()
Returns the best individual over all generations |
Individual |
getBestIndividualInCurrentGeneration()
Returns the best individual in the current generation |
double |
getCrossoverFraction()
Returns propability of crossover operation |
FitnessFunction |
getFitnessFunction()
Return fitness function used in this genetic program |
Function[] |
getFunctionSet()
Returns function set of this genetic program |
int |
getGenerationMethod()
Returns generation method used in this genetic program |
int |
getGenerationNo()
Returns current generation number |
int |
getGenerationOfBestIndividual()
Returns the genereation number of the best individual over all generations |
int |
getMaxDepthForIndividualAfterCrossover()
Returns the maximum depth for the new individuals created by crossover operation |
int |
getMaxDepthForNewIndividual()
Returns the maximum depth for the new individuals |
int |
getMaxDepthForNewSubtreeInMutant()
Returns the maximum depth for the new subtree created by mutation operation |
double |
getMutationFraction()
Return propability of mutation operation |
Individual[] |
getPopulation()
Returns the individuals in the population |
int |
getPopulationSize()
Returns size of the population |
java.util.Random |
getRandomNumberGenerator()
Returns the random number generator used in this genetic program |
double |
getReproductionFraction()
Return propability of reproduction operation |
int |
getSelectionMethod()
Returns the selection method used in this genetic program |
Terminal[] |
getTerminalSet()
Returns terminal set of this genetic program |
static boolean |
isFunction(Program program)
Returns whether the given program is a function or not |
static boolean |
isProgram(Program program)
Teset a given argument is a program or not |
int |
maxDepthOfTree(Program tree)
Returns the depth of the deepest branch of the given tree. |
Program |
mutate(Program program)
Mutates a given program |
Function |
selectFunction()
Selects a function from terminal set randomly |
Terminal |
selectTerminal()
Selects a terminal from terminal set randomly |
void |
setBestIndividual(int individualNo)
Changes the best individual of this population |
void |
setBestIndividualInCurrentGeneration(int individualNo)
Changes the best individual of the current generation |
void |
setCrossoverFraction(double newValue)
Changes propability of crossover operation |
void |
setFitnessFunction(FitnessFunction function)
Changes the best individual of the current generation |
void |
setFunctionSet(Function[] newSet)
Changes function set of this genetic program |
void |
setGenerationMethod(int newMethod)
Changes generation method used in this genetic program |
void |
setGenerationOfBestIndividual(int generation)
Changes the generation number of the best individual |
void |
setMaxDepthForIndividualAfterCrossover(int newDepth)
Changes the maximum depth for the new individuals created by crossover operation |
void |
setMaxDepthForNewIndividual(int newDepth)
Changes the maximum depth for the new individuals |
void |
setMaxDepthForNewSubtreeInMutant(int newDepth)
Changes the maximum depth for the new subtree created by mutation operation |
void |
setMutationFraction(double newValue)
Changes propability of mutation operation |
void |
setPopulationSize(int newSize)
Changes the size of the population |
void |
setRandomNumberGenerator(java.util.Random randGenerator)
Changes the random number generator used in this genetic program |
void |
setReproductionFraction(double newValue)
Changes the size of the population |
void |
setSelectionMethod(int newMethod)
Changes selection method used in this genetic program |
void |
setTerminalSet(Terminal[] newSet)
Changes terminal set of this genetic program |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int GENERATION_FULL
public static final int GENERATION_GROW
public static final int GENERATION_RAMPED_HALF_AND_HALF
public static final int SELECTION_TOURNAMENT
public static final int SELECTION_FITNESS_PROPORTIONATE
| Constructor Detail |
|---|
public GeneticProgram(int populationSize,
FitnessFunction fitnessFunction,
Terminal[] terminalSet,
Function[] functionSet,
int generationMethod,
int selectionMethod)
populationSize - size of the populationfitnessFunction - fitness function that will be used in this
genetic programterminalSet - terminal set of this genetic programfunctionSet - function set of this genetic programgenerationMethod - generation method used in this genetic programselectionMethod - selection method used in this genetic program
public GeneticProgram(int populationSize,
FitnessFunction fitnessFunction,
Terminal[] terminalSet,
Function[] functionSet)
populationSize - size of the populationfitnessFunction - fitness function that will be used in this
genetic programterminalSet - terminal set of this genetic programfunctionSet - function set of this genetic program| Method Detail |
|---|
public Terminal selectTerminal()
public Function selectFunction()
public void createArgumentsForFunction(Function function,
int allowableDepth,
boolean fullP)
function - function to create argumentsallowableDepth - remaining depth of the tree we can create when we
hit zero we will only select terminals.fullP - indicates whether this individual is to be a full tree
public Program createIndividualProgram(int allowableDepth,
boolean topNodeP,
boolean fullP)
allowableDepth - remaining depth of the tree we can create when we
hit zero we will only select terminals.topNodeP - is ture only when we are being called as the top node in
the tree. This allows us to make sure that we always put a
function at the top of the tree.fullP - indicates whether this individual is to be a full tree
public void createPopulation()
public Program mutate(Program program)
program - program to mutate
public Program[] crossover(Program male,
Program female)
male - first parent programfemale - second parent program
public int maxDepthOfTree(Program tree)
tree - tree to calculate the depth of the maximum branch
public Individual findIndividual()
public Individual findIndividualUsingTournamentSelection()
public Individual findIndividualUsingFitnessProportionateSelection(double afterThisFitness)
afterThisFitness - DOCUMENT ME!
public void evolve()
public static boolean isProgram(Program program)
program - program to test whether it is a function or not
public static boolean isFunction(Program program)
program - program to test whether it is a function or not
public Individual getBestIndividual()
public int getGenerationOfBestIndividual()
public Individual getBestIndividualInCurrentGeneration()
public double getAverageStandardizedFitnessOfCurrentGeneration()
public double getAverageAdjustedFitnessOfCurrentGeneration()
public double getAverageNormalizedFitnessOfCurrentGeneration()
public java.util.Random getRandomNumberGenerator()
public void setRandomNumberGenerator(java.util.Random randGenerator)
randGenerator - new random number generatorpublic Individual[] getPopulation()
public int getGenerationNo()
public int getPopulationSize()
public void setPopulationSize(int newSize)
newSize - new size of the populationpublic int getMaxDepthForNewIndividual()
public void setMaxDepthForNewIndividual(int newDepth)
newDepth - new depth for the new individualspublic int getMaxDepthForIndividualAfterCrossover()
public void setMaxDepthForIndividualAfterCrossover(int newDepth)
newDepth - new value for the new individuals created by crossover
operationpublic int getMaxDepthForNewSubtreeInMutant()
public void setMaxDepthForNewSubtreeInMutant(int newDepth)
newDepth - new value for the maximum depth for the new subtree
created by mutation operationpublic double getCrossoverFraction()
public void setCrossoverFraction(double newValue)
newValue - new value for the propability of crossover operationpublic double getMutationFraction()
public void setMutationFraction(double newValue)
newValue - new value for the propability of mutation operationpublic double getReproductionFraction()
public void setReproductionFraction(double newValue)
newValue - fraction for the reproduction genetic operatorpublic int getGenerationMethod()
public void setGenerationMethod(int newMethod)
newMethod - new value of generation method used in this genetic
programpublic int getSelectionMethod()
public void setSelectionMethod(int newMethod)
newMethod - new selection method used in this genetic programpublic Terminal[] getTerminalSet()
public void setTerminalSet(Terminal[] newSet)
newSet - new terminal set for the genetic programpublic Function[] getFunctionSet()
public void setFunctionSet(Function[] newSet)
newSet - new function set for this genetic programpublic void setBestIndividual(int individualNo)
individualNo - index of the best individual in the current
populationpublic void setGenerationOfBestIndividual(int generation)
generation - generation of best individualpublic void setBestIndividualInCurrentGeneration(int individualNo)
individualNo - index of the best individual in the current
populationpublic FitnessFunction getFitnessFunction()
public void setFitnessFunction(FitnessFunction function)
function - new fitness function
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||