|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jgap.Configuration
org.jgap.gp.impl.GPConfiguration
public class GPConfiguration
Configuration for a GP.
| Field Summary |
|---|
| Constructor Summary | |
|---|---|
GPConfiguration()
Constructor utilizing the FitnessProportionateSelection. |
|
GPConfiguration(INaturalGPSelector a_selectionMethod)
Constructor utilizing the FitnessProportionateSelection. |
|
GPConfiguration(java.lang.String a_name)
Constructs a configuration with an informative name but without a unique ID. |
|
GPConfiguration(java.lang.String a_id,
java.lang.String a_name)
|
|
| Method Summary | |
|---|---|
void |
addGeneticOperator(GeneticOperator a_operatorToAdd)
Adds a genetic operator for use in this algorithm. |
void |
clearMemory()
Clears the memory. |
void |
clearStack()
|
java.lang.Object |
clone()
|
int |
compareTo(java.lang.Object a_other)
The compareTo-method. |
void |
createMatrix(java.lang.String a_name,
int a_cols,
int a_rows)
Creates an instance of a matrix with a unique name. |
boolean |
equals(java.lang.Object a_other)
Compares this entity against the specified object. |
void |
flagMaxNodeWarningPrinted()
See ProgramChromosome.growOrFull(...) and GPGenotype.evolve(). |
CrossMethod |
getCrossMethod()
|
double |
getCrossoverProb()
|
double |
getDynamizeArityProb()
|
double |
getFunctionProb()
|
IGPFitnessEvaluator |
getGPFitnessEvaluator()
|
GPFitnessFunction |
getGPFitnessFunction()
|
IGPInitStrategy |
getInitStrategy()
|
IJGAPFactory |
getJGAPFactory()
|
char[][] |
getMatrix(java.lang.String a_name)
Retrieves a named matrix. |
int |
getMaxCrossoverDepth()
|
int |
getMaxInitDepth()
|
int |
getMemorySize()
|
int |
getMinInitDepth()
|
double |
getMutationProb()
|
double |
getNewChromsPercent()
|
INodeValidator |
getNodeValidator()
|
int |
getProgramCreationMaxtries()
|
IGPProgram |
getPrototypeProgram()
|
double |
getReproductionProb()
|
INaturalGPSelector |
getSelectionMethod()
|
Variable |
getVariable(java.lang.String a_varName)
|
protected void |
init(boolean a_fullInit)
Helper for construction. |
boolean |
isMaxNodeWarningPrinted()
|
boolean |
isNoCommandGeneCloning()
|
boolean |
isStrictProgramCreation()
|
boolean |
isUseProgramCache()
|
boolean |
isVerifyPrograms()
|
GPConfiguration |
newInstanceGP(java.lang.String a_id,
java.lang.String a_name)
Creates a new GPConfiguration instance by cloning. |
java.lang.Object |
peekStack()
|
java.lang.Object |
popFromStack()
|
void |
pushToStack(java.lang.Object a_value)
|
GPProgramInfo |
putToProgramCache(GPProgram a_prog)
|
void |
putVariable(Variable a_var)
Stores a Variable. |
java.lang.Object |
readFromMemory(java.lang.String a_name)
Reads a value from the internal memory. |
java.lang.Object |
readFromMemoryIfExists(java.lang.String a_name)
|
java.lang.Object |
readIndexedMemory(int a_index)
Reads a value from the internal indexed memory. |
char |
readMatrix(java.lang.String a_name,
int a_col,
int a_row)
Reads a matrix cell and returns the value. |
java.lang.Object |
readMatrixMemory(int a_x,
int a_y)
Reads a value from the internal matrix memory. |
GPProgramInfo |
readProgramCache(GPProgram a_prog)
|
void |
resetMatrix(java.lang.String a_name,
char a_filler)
Resets the matrix by filling it with a given character. |
void |
setCrossoverMethod(CrossMethod a_method)
Sets the crossover method to use. |
void |
setCrossoverProb(float a_crossoverProb)
|
void |
setDynamizeArityProb(float a_dynArityProb)
|
void |
setFitnessEvaluator(IGPFitnessEvaluator a_fitnessEvaluator)
Set the fitness evaluator (deciding if a given fitness value is better when it's higher or better when it's lower). |
void |
setFitnessFunction(GPFitnessFunction a_functionToSet)
Sets the fitness function to be used for this genetic algorithm. |
void |
setFunctionProb(double a_functionProb)
|
void |
setGPFitnessEvaluator(IGPFitnessEvaluator a_evaluator)
Sets a GP fitness evaluator, such as org.jgap.gp.impl.DefaultGPFitnessEvaluator. |
void |
setInitStrategy(IGPInitStrategy a_strategy)
|
void |
setMatrix(java.lang.String a_name,
int a_col,
int a_row,
char a_value)
Sets a matrix field with a value. |
void |
setMaxCrossoverDepth(int a_maxCrossoverDepth)
|
void |
setMaxInitDepth(int a_maxDepth)
|
void |
setMinInitDepth(int a_minDepth)
|
void |
setMutationProb(float a_mutationProb)
|
void |
setNewChromsPercent(double a_newChromsPercent)
|
void |
setNoCommandGeneCloning(boolean a_noCommandGeneCloning)
Decide whether to clone command genes when creating a new GP program in ProgramChromosome. |
void |
setNodeValidator(INodeValidator a_nodeValidator)
Sets the node validator. |
void |
setProgramCreationMaxTries(int a_maxtries)
|
void |
setPrototypeProgram(IGPProgram a_program)
|
void |
setReproductionProb(float a_reproductionProb)
|
void |
setSelectionMethod(INaturalGPSelector a_method)
Sets the selection method to use. |
void |
setStrictProgramCreation(boolean a_strict)
|
void |
setUseProgramCache(boolean a_useCache)
|
void |
setVerifyPrograms(boolean a_verify)
|
int |
stackSize()
|
CultureMemoryCell |
storeIndexedMemory(int a_index,
java.lang.Object a_value)
Stores a value in the internal indexed memory. |
void |
storeInMemory(java.lang.String a_name,
java.lang.Object a_value)
Stores a value in the internal memory. |
CultureMemoryCell |
storeMatrixMemory(int a_x,
int a_y,
java.lang.Object a_value)
Stores a value in the internal matrix memory. |
boolean |
validateNode(ProgramChromosome a_chrom,
CommandGene a_node,
CommandGene a_rootNode,
int a_tries,
int a_num,
int a_recurseLevel,
java.lang.Class a_type,
CommandGene[] a_functionSet,
int a_depth,
boolean a_grow,
int a_childIndex,
boolean a_fullProgram)
Validates a_node in the context of a_chrom. |
void |
verifyStateIsValid()
Tests the state of this Configuration object to make sure it's valid. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public GPConfiguration()
throws InvalidConfigurationException
InvalidConfigurationException
public GPConfiguration(java.lang.String a_id,
java.lang.String a_name)
throws InvalidConfigurationException
InvalidConfigurationException
public GPConfiguration(java.lang.String a_name)
throws InvalidConfigurationException
a_name - informative name of the configuration, may be null
InvalidConfigurationException
public GPConfiguration(INaturalGPSelector a_selectionMethod)
throws InvalidConfigurationException
a_selectionMethod - the selection method to use
InvalidConfigurationException| Method Detail |
|---|
public void setGPFitnessEvaluator(IGPFitnessEvaluator a_evaluator)
a_evaluator - the fitness evaluator to set
protected void init(boolean a_fullInit)
throws InvalidConfigurationException
a_fullInit - true set event manager, random generator and fitness
evaluator to defauklt
InvalidConfigurationExceptionpublic void setSelectionMethod(INaturalGPSelector a_method)
a_method - the selection method to usepublic void setCrossoverMethod(CrossMethod a_method)
a_method - the crossover method to use
public void verifyStateIsValid()
throws InvalidConfigurationException
Configuration
verifyStateIsValid in class ConfigurationInvalidConfigurationException - if the state of this Configuration
is not valid. The error message in the exception will detail the reason
for invalidity
public void addGeneticOperator(GeneticOperator a_operatorToAdd)
throws InvalidConfigurationException
Configuration
addGeneticOperator in class Configurationa_operatorToAdd - the genetic operator to add.
InvalidConfigurationException - if the genetic operator is null or
if this Configuration object is lockedpublic double getCrossoverProb()
public void setCrossoverProb(float a_crossoverProb)
public double getReproductionProb()
public void setReproductionProb(float a_reproductionProb)
public double getMutationProb()
public void setMutationProb(float a_mutationProb)
a_mutationProb - probability for mutation of a node during growing a
programpublic double getDynamizeArityProb()
public void setDynamizeArityProb(float a_dynArityProb)
a_dynArityProb - probability for dynamizing the arity of a node during
growing a programpublic void setFunctionProb(double a_functionProb)
a_functionProb - probability that a function instead of a terminal
is chosen in crossing over (between 0 and 1)public double getFunctionProb()
public void setNewChromsPercent(double a_newChromsPercent)
public double getNewChromsPercent()
public int getMaxCrossoverDepth()
public void setMaxCrossoverDepth(int a_maxCrossoverDepth)
public INaturalGPSelector getSelectionMethod()
public CrossMethod getCrossMethod()
public int getMaxInitDepth()
public void setMaxInitDepth(int a_maxDepth)
public int getMinInitDepth()
public void setMinInitDepth(int a_minDepth)
public void pushToStack(java.lang.Object a_value)
public java.lang.Object popFromStack()
public java.lang.Object peekStack()
public int stackSize()
public void clearStack()
public void storeInMemory(java.lang.String a_name,
java.lang.Object a_value)
a_name - named index of the memory cella_value - the value to store
public void createMatrix(java.lang.String a_name,
int a_cols,
int a_rows)
a_name - the name of the matrixa_cols - number of columns the matrix should havea_rows - number of rows the matrix should have
public void setMatrix(java.lang.String a_name,
int a_col,
int a_row,
char a_value)
a_name - the name of the matrixa_col - column in the matrixa_row - row in the matrixa_value - the value to set in the matrix at given column and row
public void resetMatrix(java.lang.String a_name,
char a_filler)
a_name - the name of the matrixa_filler - the character to fill the whole matrix with
public char readMatrix(java.lang.String a_name,
int a_col,
int a_row)
a_name - the name of the matrixa_col - the column to reada_row - the row to read
public char[][] getMatrix(java.lang.String a_name)
a_name - the name of the matrix
public CultureMemoryCell storeMatrixMemory(int a_x,
int a_y,
java.lang.Object a_value)
a_x - the first coordinate of the matrix (width)a_y - the second coordinate of the matrix (height)a_value - the value to store
public java.lang.Object readMatrixMemory(int a_x,
int a_y)
a_x - the first coordinate of the matrix (width)a_y - the second coordinate of the matrix (height)
public java.lang.Object readFromMemory(java.lang.String a_name)
a_name - named index of the memory cell to read out
public java.lang.Object readFromMemoryIfExists(java.lang.String a_name)
a_name - the name of the cell to evaluate
public CultureMemoryCell storeIndexedMemory(int a_index,
java.lang.Object a_value)
a_index - index of the cella_value - the value to store
public java.lang.Object readIndexedMemory(int a_index)
a_index - index of the cell
public void clearMemory()
public GPFitnessFunction getGPFitnessFunction()
public void setFitnessEvaluator(IGPFitnessEvaluator a_fitnessEvaluator)
a_fitnessEvaluator - the FitnessEvaluator to be used
public void setFitnessFunction(GPFitnessFunction a_functionToSet)
throws InvalidConfigurationException
a_functionToSet - fitness function to be used
InvalidConfigurationException - if the fitness function is null, or
if this Configuration object is locked.public boolean isStrictProgramCreation()
public void setStrictProgramCreation(boolean a_strict)
a_strict - true: throw an error during evolution in case a situation
is detected where no function or terminal of a required type is declared
in the GPConfiguration; false: don't throw an error but try a completely
different combination of functions and terminalspublic int getProgramCreationMaxtries()
public void setProgramCreationMaxTries(int a_maxtries)
public IGPFitnessEvaluator getGPFitnessEvaluator()
public boolean validateNode(ProgramChromosome a_chrom,
CommandGene a_node,
CommandGene a_rootNode,
int a_tries,
int a_num,
int a_recurseLevel,
java.lang.Class a_type,
CommandGene[] a_functionSet,
int a_depth,
boolean a_grow,
int a_childIndex,
boolean a_fullProgram)
a_chrom - the chromosome that will contain the node, if valida_node - the node selected and to be validateda_rootNode - root node of the node to be validated (may be null)a_tries - number of times the validator has been called, useful for
stopping by returning true if the number exceeds a limita_num - the chromosome's index in the individual of this chromosomea_recurseLevel - level of recursiona_type - the return type of the node neededa_functionSet - the array of available functionsa_depth - the needed depth of the program chromosomea_grow - true: use grow mode, false: use full modea_childIndex - index of the child in the parent node to which it
belongs (-1 if node is root node)a_fullProgram - true: whole program is available in a_chrom
public void setNodeValidator(INodeValidator a_nodeValidator)
a_nodeValidator - sicpublic INodeValidator getNodeValidator()
public boolean equals(java.lang.Object a_other)
equals in class Configurationa_other - the object to compare against
public int compareTo(java.lang.Object a_other)
Configuration
compareTo in interface java.lang.ComparablecompareTo in class Configurationa_other - the other object to compare
public boolean isMaxNodeWarningPrinted()
public void flagMaxNodeWarningPrinted()
public void setPrototypeProgram(IGPProgram a_program)
a_program - IGPProgrampublic IGPProgram getPrototypeProgram()
public int getMemorySize()
public GPProgramInfo readProgramCache(GPProgram a_prog)
public GPProgramInfo putToProgramCache(GPProgram a_prog)
public boolean isUseProgramCache()
public void setUseProgramCache(boolean a_useCache)
public void putVariable(Variable a_var)
a_var - the Variable to storepublic Variable getVariable(java.lang.String a_varName)
a_varName - name of variable to retriebe
public java.lang.Object clone()
clone in interface ICloneableclone in class Configuration
public GPConfiguration newInstanceGP(java.lang.String a_id,
java.lang.String a_name)
a_id - new ID for clonea_name - new name for clone
public IJGAPFactory getJGAPFactory()
getJGAPFactory in class Configurationpublic void setInitStrategy(IGPInitStrategy a_strategy)
a_strategy - IGPInitStrategypublic IGPInitStrategy getInitStrategy()
public void setVerifyPrograms(boolean a_verify)
a_verify - true: verify GP programs for correctness (i.e. is fitness
computation possible without exception?)public boolean isVerifyPrograms()
public void setNoCommandGeneCloning(boolean a_noCommandGeneCloning)
a_noCommandGeneCloning - booleanpublic boolean isNoCommandGeneCloning()
|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||