|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jgap.gp.impl.GPGenotype
public class GPGenotype
Genotype for GP Programs.
| Constructor Summary | |
|---|---|
GPGenotype()
Default constructor. |
|
GPGenotype(GPConfiguration a_configuration,
GPPopulation a_population,
java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int[] a_minDepths,
int[] a_maxDepths,
int a_maxNodes)
Preferred constructor to use, if not using the static method randomInitialGenotype. |
|
| Method Summary | |
|---|---|
void |
addFittestProgram(IGPProgram a_toAdd)
Adds a GP program to this Genotype. |
void |
calcFitness()
Calculates the fitness value of all programs, of the best solution as well as the total fitness (sum of all fitness values). |
static void |
checkErroneousPop(GPPopulation pop,
java.lang.String s)
|
static void |
checkErroneousPop(GPPopulation a_pop,
java.lang.String a_s,
boolean a_clearFitness)
|
static void |
checkErroneousPop(GPPopulation a_pop,
java.lang.String a_s,
boolean a_clearFitness,
boolean a_active)
|
static void |
checkErroneousProg(IGPProgram prog,
java.lang.String s)
|
static void |
checkErroneousProg(IGPProgram a_prog,
java.lang.String a_s,
boolean a_clearFitness)
|
static void |
checkErroneousProg(IGPProgram a_prog,
java.lang.String s,
boolean a_clearFitness,
boolean a_active)
|
int |
compareTo(java.lang.Object a_other)
Compares this Genotype against the specified object. |
boolean |
equals(java.lang.Object a_other)
Compares this entity against the specified object. |
void |
evolve()
Evolve the population by one generation. |
void |
evolve(int a_evolutions)
Evolves the population n times. |
void |
fillPopulation(int a_num)
Fills up the population with random programs if necessary. |
IGPProgram |
getAllTimeBest()
|
IGPProgram |
getFittestProgram()
Retrieves the GPProgram in the population with the highest fitness value. |
IGPProgram |
getFittestProgramComputed()
Retrieves the GPProgram in the population with the highest fitness value. |
GPConfiguration |
getGPConfiguration()
|
GPPopulation |
getGPPopulation()
|
static GPConfiguration |
getStaticGPConfiguration()
|
double |
getTotalFitness()
|
Variable |
getVariable(java.lang.String a_varName)
|
int |
hashCode()
Hashcode function for the genotype, tries to create a unique hashcode for the chromosomes within the population. |
protected void |
init()
|
void |
outputSolution(IGPProgram a_best)
Outputs the best solution until now. |
void |
putVariable(Variable a_var)
Stores a Variable. |
static GPGenotype |
randomInitialGenotype(GPConfiguration a_conf,
java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int[] a_minDepths,
int[] a_maxDepths,
int a_maxNodes,
boolean a_verboseOutput)
Creates a genotype with initial population for the world set. |
static GPGenotype |
randomInitialGenotype(GPConfiguration a_conf,
java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int[] a_minDepths,
int[] a_maxDepths,
int a_maxNodes,
boolean[] a_fullModeAllowed,
boolean a_verboseOutput)
Creates a genotype with a randomly created initial population. |
static GPGenotype |
randomInitialGenotype(GPConfiguration a_conf,
java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int[] a_minDepths,
int[] a_maxDepths,
int a_maxNodes,
boolean[] a_fullModeAllowed,
boolean a_verboseOutput,
IPopulationCreator a_popCreator)
Allows to use a custom mechanism for population creation. |
static GPGenotype |
randomInitialGenotype(GPConfiguration a_conf,
java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int a_maxNodes,
boolean a_verboseOutput)
Creates a genotype with initial population for the world set. |
void |
run()
Default implementation of method to run GPGenotype as a thread. |
void |
setGPConfiguration(GPConfiguration a_configuration)
Sets the configuration to use with the Genetic Algorithm. |
protected void |
setGPPopulation(GPPopulation a_pop)
|
static void |
setStaticGPConfiguration(GPConfiguration a_configuration)
Sets the static configuration to use with the Genetic Programming. |
void |
setVerboseOutput(boolean a_verbose)
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GPGenotype()
throws InvalidConfigurationException
InvalidConfigurationException
public GPGenotype(GPConfiguration a_configuration,
GPPopulation a_population,
java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int[] a_minDepths,
int[] a_maxDepths,
int a_maxNodes)
throws InvalidConfigurationException
a_configuration - the configuration to usea_population - the initialized population to usea_types - the type for each chromosome, the length of the array
represents the number of chromosomesa_argTypes - the types of the arguments to each chromosome, must be an
array of arrays, the first dimension of which is the number of chromosomes
and the second dimension of which is the number of arguments to the
chromosomea_nodeSets - the nodes which are allowed to be used by each chromosome,
must be an array of arrays, the first dimension of which is the number of
chromosomes and the second dimension of which is the number of nodesa_minDepths - contains the minimum depth allowed for each chromosomea_maxDepths - contains the maximum depth allowed for each chromosomea_maxNodes - reserve space for a_maxNodes number of nodes
InvalidConfigurationException| Method Detail |
|---|
protected void init()
public static GPGenotype randomInitialGenotype(GPConfiguration a_conf,
java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int a_maxNodes,
boolean a_verboseOutput)
throws InvalidConfigurationException
a_conf - the configuration to usea_types - the type of each chromosome, the length is the number of
chromosomesa_argTypes - the types of the arguments to each chromosome, must be an
array of arrays, the first dimension of which is the number of chromosomes
and the second dimension of which is the number of arguments to the
chromosomea_nodeSets - the nodes which are allowed to be used by each
chromosome, must be an array of arrays, the first dimension of which is the
number of chromosomes and the second dimension of which is the number of
nodes. Note that it is not necessary to include the arguments of a
chromosome as terminals in the chromosome's node set. This is done
automaticallya_maxNodes - reserve space for a_maxNodes number of nodesa_verboseOutput - true: output status information to console
InvalidConfigurationException
public static GPGenotype randomInitialGenotype(GPConfiguration a_conf,
java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int[] a_minDepths,
int[] a_maxDepths,
int a_maxNodes,
boolean a_verboseOutput)
throws InvalidConfigurationException
a_conf - the configuration to usea_types - the type of each chromosome, the length is the number of
chromosomesa_argTypes - the types of the arguments to each chromosome, must be an
array of arrays, the first dimension of which is the number of chromosomes
and the second dimension of which is the number of arguments to the
chromosomea_nodeSets - the nodes which are allowed to be used by each
chromosome, must be an array of arrays, the first dimension of which is the
number of chromosomes and the second dimension of which is the number of
nodes. Note that it is not necessary to include the arguments of a
chromosome as terminals in the chromosome's node set. This is done
automaticallya_minDepths - array of minimum depths to use: for each chromosome
one entrya_maxDepths - array of maximum depths to use: for each chromosome
one entrya_maxNodes - reserve space for a_maxNodes number of nodesa_verboseOutput - true: output status information to console
InvalidConfigurationException
public static GPGenotype randomInitialGenotype(GPConfiguration a_conf,
java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int[] a_minDepths,
int[] a_maxDepths,
int a_maxNodes,
boolean[] a_fullModeAllowed,
boolean a_verboseOutput)
throws InvalidConfigurationException
a_conf - the configuration to usea_types - the type of each chromosome, the length is the number of
chromosomesa_argTypes - the types of the arguments to each chromosome, must be an
array of arrays, the first dimension of which is the number of chromosomes
and the second dimension of which is the number of arguments to the
chromosomea_nodeSets - the nodes which are allowed to be used by each
chromosome, must be an array of arrays, the first dimension of which is the
number of chromosomes and the second dimension of which is the number of
nodes. Note that it is not necessary to include the arguments of a
chromosome as terminals in the chromosome's node set. This is done
automaticallya_minDepths - array of minimum depths to use: for each chromosome
one entrya_maxDepths - array of maximum depths to use: for each chromosome
one entrya_maxNodes - reserve space for a_maxNodes number of nodesa_fullModeAllowed - array of boolean values. For each chromosome there
is one value indicating whether the full mode for creating chromosome
generations during evolution is allowed (true) or not (false)a_verboseOutput - true: output status information to console
InvalidConfigurationException
public static GPGenotype randomInitialGenotype(GPConfiguration a_conf,
java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int[] a_minDepths,
int[] a_maxDepths,
int a_maxNodes,
boolean[] a_fullModeAllowed,
boolean a_verboseOutput,
IPopulationCreator a_popCreator)
throws InvalidConfigurationException
a_conf - the configuration to usea_types - the type of each chromosome, the length is the number of
chromosomesa_argTypes - the types of the arguments to each chromosome, must be an
array of arrays, the first dimension of which is the number of chromosomes
and the second dimension of which is the number of arguments to the
chromosomea_nodeSets - the nodes which are allowed to be used by each
chromosome, must be an array of arrays, the first dimension of which is the
number of chromosomes and the second dimension of which is the number of
nodes. Note that it is not necessary to include the arguments of a
chromosome as terminals in the chromosome's node set. This is done
automaticallya_minDepths - array of minimum depths to use: for each chromosome
one entrya_maxDepths - array of maximum depths to use: for each chromosome
one entrya_maxNodes - reserve space for a_maxNodes number of nodesa_fullModeAllowed - array of boolean values. For each chromosome there
is one value indicating whether the full mode for creating chromosome
generations during evolution is allowed (true) or not (false)a_verboseOutput - true: output status information to consolea_popCreator - mechanism fior creating the population
InvalidConfigurationExceptionpublic GPConfiguration getGPConfiguration()
public static GPConfiguration getStaticGPConfiguration()
public static void setStaticGPConfiguration(GPConfiguration a_configuration)
a_configuration - the static configuration to usepublic void evolve(int a_evolutions)
a_evolutions - number of evolutionpublic void calcFitness()
public IGPProgram getAllTimeBest()
public void outputSolution(IGPProgram a_best)
a_best - the fittest ProgramChromosomepublic void evolve()
public GPPopulation getGPPopulation()
public double getTotalFitness()
public void run()
run in interface java.lang.Runnablepublic IGPProgram getFittestProgram()
public IGPProgram getFittestProgramComputed()
protected void setGPPopulation(GPPopulation a_pop)
public void setGPConfiguration(GPConfiguration a_configuration)
a_configuration - the configuration to usepublic boolean equals(java.lang.Object a_other)
equals in class java.lang.Objecta_other - the object to compare against
public int compareTo(java.lang.Object a_other)
compareTo in interface java.lang.Comparablea_other - the object to compare against
public int hashCode()
hashCode in class java.lang.Objectpublic void setVerboseOutput(boolean a_verbose)
a_verbose - true: output status information to consolepublic 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 void addFittestProgram(IGPProgram a_toAdd)
a_toAdd - the program to add
public void fillPopulation(int a_num)
throws InvalidConfigurationException
a_num - the number of programs to add
InvalidConfigurationException
public static void checkErroneousPop(GPPopulation pop,
java.lang.String s)
public static void checkErroneousPop(GPPopulation a_pop,
java.lang.String a_s,
boolean a_clearFitness)
public static void checkErroneousPop(GPPopulation a_pop,
java.lang.String a_s,
boolean a_clearFitness,
boolean a_active)
public static void checkErroneousProg(IGPProgram prog,
java.lang.String s)
public static void checkErroneousProg(IGPProgram a_prog,
java.lang.String a_s,
boolean a_clearFitness)
public static void checkErroneousProg(IGPProgram a_prog,
java.lang.String s,
boolean a_clearFitness,
boolean a_active)
|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||