|
JGAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgap.gp.impl.GPPopulation
public class GPPopulation
Population for GP programs.
Field Summary | |
---|---|
static double |
DELTA
|
Constructor Summary | |
---|---|
GPPopulation()
Default constructor, only for dynamic instantiation. |
|
GPPopulation(GPConfiguration a_config,
int a_size)
|
|
GPPopulation(GPPopulation a_pop)
|
|
GPPopulation(GPPopulation a_pop,
boolean a_keepPrograms)
|
Method Summary | |
---|---|
void |
addFittestProgram(IGPProgram a_toAdd)
Adds a GP program to this Population. |
void |
clear()
Clears the list of programs. |
int |
compareTo(java.lang.Object a_pop)
This method is not producing symmetric results as -1 is more often returned than 1 (see description of return value). |
protected boolean |
containedInArray(IGPProgram[] a_progs,
IGPProgram a_prog)
Checks if a program is contained within an array of programs. |
void |
copyGPPrograms(GPPopulation a_pop)
Sets the GPPrograms of the given population to this population. |
void |
create(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)
Creates a population. |
void |
create(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,
IProgramCreator a_programCreator)
Creates a population. |
void |
create(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,
IProgramCreator a_programCreator,
int a_offset)
Creates a population. |
IGPProgram |
create(java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int[] a_minDepths,
int[] a_maxDepths,
int a_depth,
boolean a_grow,
int a_maxNodes,
boolean[] a_fullModeAllowed,
int a_tries)
Creates a population. |
IGPProgram |
create(int a_programIndex,
java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int[] a_minDepths,
int[] a_maxDepths,
int a_depth,
boolean a_grow,
int a_maxNodes,
boolean[] a_fullModeAllowed,
int a_tries)
|
IGPProgram |
create(int a_programIndex,
java.lang.Class[] a_types,
java.lang.Class[][] a_argTypes,
CommandGene[][] a_nodeSets,
int[] a_minDepths,
int[] a_maxDepths,
int a_depth,
boolean a_grow,
int a_maxNodes,
boolean[] a_fullModeAllowed,
int a_tries,
IProgramCreator a_programCreator)
Creates a valid IGPProgram. |
protected java.lang.String |
decode(java.lang.String a_string)
|
java.util.List |
determineFittestChromosomes(int a_numberOfPrograms)
Sorts the GPPrograms list and returns the fittest n GPPrograms in the population. |
IGPProgram |
determineFittestProgram()
Determines the fittest GPProgram in the population (the one with the highest fitness value) and memorizes it. |
IGPProgram |
determineFittestProgramComputed()
Determines the fittest GPProgram in the population, but only considers programs with already computed fitness value. |
protected java.lang.String |
encode(java.lang.String a_string)
|
boolean |
equals(java.lang.Object a_pop)
The equals-method. |
float |
getFitnessRank(int a_index)
|
float[] |
getFitnessRanks()
|
GPConfiguration |
getGPConfiguration()
|
IGPProgram |
getGPProgram(int a_index)
|
IGPProgram[] |
getGPPrograms()
|
java.lang.String |
getPersistentRepresentation()
|
int |
getPopSize()
|
boolean |
isChanged()
|
boolean |
isFirstEmpty()
|
protected void |
setChanged(boolean a_changed)
Mark that for the population the fittest program may have changed. |
void |
setGPProgram(int a_index,
IGPProgram a_program)
Sets the given GPProgram at the given index in the list of GPProgram's. |
void |
setGPPrograms(GPPopulation a_pop)
Sets the GPPrograms of the given population to this population. |
void |
setGPPrograms(IGPProgram[] a_progs)
Sets the GPPrograms of the given array to this population. |
void |
setGPPrograms(java.util.List a_pop)
Sets the GPPrograms of the given population to this population. |
protected void |
setSorted(boolean a_sorted)
Mark the population as sorted. |
int |
size()
|
void |
sort(java.util.Comparator c)
Sorts the population into "ascending" order using some criterion for "ascending". |
void |
sortByFitness()
Sorts the programs within the population according to their fitness value using GPProgramFitnessComparator. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double DELTA
Constructor Detail |
---|
public GPPopulation() throws java.lang.Exception
java.lang.Exception
public GPPopulation(GPConfiguration a_config, int a_size) throws InvalidConfigurationException
InvalidConfigurationException
public GPPopulation(GPPopulation a_pop) throws InvalidConfigurationException
InvalidConfigurationException
public GPPopulation(GPPopulation a_pop, boolean a_keepPrograms) throws InvalidConfigurationException
a_pop
- the population to retrieve the parameters froma_keepPrograms
- true copy programs of given population to this one
InvalidConfigurationException
Method Detail |
---|
public void sort(java.util.Comparator c)
c
- the Comparator to usepublic void create(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) throws InvalidConfigurationException
a_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 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)
InvalidConfigurationException
public void create(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, IProgramCreator a_programCreator) throws InvalidConfigurationException
a_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 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_programCreator
- service to create new programs with
InvalidConfigurationException
public void create(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, IProgramCreator a_programCreator, int a_offset) throws InvalidConfigurationException
a_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 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_programCreator
- service to create new programs witha_offset
- start index for new programs to put into the configuration
InvalidConfigurationException
public IGPProgram create(java.lang.Class[] a_types, java.lang.Class[][] a_argTypes, CommandGene[][] a_nodeSets, int[] a_minDepths, int[] a_maxDepths, int a_depth, boolean a_grow, int a_maxNodes, boolean[] a_fullModeAllowed, int a_tries) throws InvalidConfigurationException
a_types
- Class[]a_argTypes
- Class[][]a_nodeSets
- CommandGene[][]a_minDepths
- int[]a_maxDepths
- int[]a_depth
- inta_grow
- booleana_maxNodes
- inta_fullModeAllowed
- boolean[]a_tries
- int
InvalidConfigurationException
public IGPProgram create(int a_programIndex, java.lang.Class[] a_types, java.lang.Class[][] a_argTypes, CommandGene[][] a_nodeSets, int[] a_minDepths, int[] a_maxDepths, int a_depth, boolean a_grow, int a_maxNodes, boolean[] a_fullModeAllowed, int a_tries) throws InvalidConfigurationException
a_programIndex
- inta_types
- Class[]a_argTypes
- Class[][]a_nodeSets
- CommandGene[][]a_minDepths
- int[]a_maxDepths
- int[]a_depth
- inta_grow
- booleana_maxNodes
- inta_fullModeAllowed
- boolean[]a_tries
- int
InvalidConfigurationException
public IGPProgram create(int a_programIndex, java.lang.Class[] a_types, java.lang.Class[][] a_argTypes, CommandGene[][] a_nodeSets, int[] a_minDepths, int[] a_maxDepths, int a_depth, boolean a_grow, int a_maxNodes, boolean[] a_fullModeAllowed, int a_tries, IProgramCreator a_programCreator) throws InvalidConfigurationException
a_programIndex
- index of the program in the populationa_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 nodesa_minDepths
- contains the minimum depth allowed for each chromosomea_maxDepths
- contains the maximum depth allowed for each chromosomea_depth
- the maximum depth of the program to createa_grow
- true: grow mode, false: full modea_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 chromosomes
during evolution is allowed (true) or not (false)a_tries
- maximum number of tries to get a valid programa_programCreator
- strategy class to create programs for the
population
InvalidConfigurationException
public int getPopSize()
public GPConfiguration getGPConfiguration()
public void setGPProgram(int a_index, IGPProgram a_program)
a_index
- the index to set the GPProgram ina_program
- the GPProgram to be setpublic IGPProgram getGPProgram(int a_index)
public void setGPPrograms(GPPopulation a_pop)
a_pop
- the population to use as templatepublic void setGPPrograms(IGPProgram[] a_progs)
a_progs
- the programs to setpublic void copyGPPrograms(GPPopulation a_pop)
a_pop
- the population to use as templatepublic void setGPPrograms(java.util.List a_pop)
a_pop
- the population to use as templatepublic IGPProgram[] getGPPrograms()
public int size()
public IGPProgram determineFittestProgram()
public IGPProgram determineFittestProgramComputed()
public java.util.List determineFittestChromosomes(int a_numberOfPrograms)
a_numberOfPrograms
- number of top performer GPPrograms to be
returned
public void sortByFitness()
public float[] getFitnessRanks()
public float getFitnessRank(int a_index)
protected void setChanged(boolean a_changed)
a_changed
- true: population's fittest program may have changed,
false: fittest program evaluated earlier is still validpublic boolean isChanged()
protected void setSorted(boolean a_sorted)
a_sorted
- true: mark population as sortedpublic int compareTo(java.lang.Object a_pop)
compareTo
in interface java.lang.Comparable
a_pop
- the other population to compare
protected boolean containedInArray(IGPProgram[] a_progs, IGPProgram a_prog)
a_progs
- the array to search thrua_prog
- the program to find
public boolean equals(java.lang.Object a_pop)
equals
in class java.lang.Object
a_pop
- the population instance to compare with
public void addFittestProgram(IGPProgram a_toAdd)
a_toAdd
- the program to addpublic void clear()
public boolean isFirstEmpty()
public java.lang.String getPersistentRepresentation()
protected java.lang.String encode(java.lang.String a_string)
protected java.lang.String decode(java.lang.String a_string)
|
JGAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |