Class gpjpp.GPVariables
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class gpjpp.GPVariables

java.lang.Object
   |
   +----gpjpp.GPObject
           |
           +----gpjpp.GPVariables

public class GPVariables
extends GPObject
Holds all global configuration parameters for a genetic programming run. All parameters have default values as described below. The GPRun class also automatically reads a configuration file in Java property or Windows .ini format which can be used to set configuration parameters without recompiling an application.

It is common to create a user subclass of GPVariables in order to add problem-specific configuration parameters. Examples include the size and filename for an ant trail, or the number of address lines that form the input to a boolean multiplexer. In other cases it may be useful to add non-configuration variables to a subclass of GPVariables. gpjpp passes a reference to the global variables to all methods that are likely to need them, including the evaluate() method of GP and all of the printOn() methods. Examples that add to GPVariables in this way include the ant "automaton" that responds to command functions and eats food, and the set of data and address inputs for the multiplexer problem.

Version:
1.0

Variable Index

 o AddBestToNewPopulation
Determines whether the best individual is automatically added to the next generation, when SteadyState is false.
 o CheckpointGens
The number of generations between checkpoints saved by GPRun.
 o ComplexityAffectsFitness
A boolean that can be tested by the user evaluate() function to determine whether to incorporate complexity into the fitness calculation.
 o CreationProbability
Percent probability that a creation operation will occur while evolving a new generation.
 o CreationStr
An array of strings used to detect and print the creation type in configuration files and status reports.
 o CreationType
The strategy used to create generation 0.
 o CrossoverProbability
Percent probability that a crossover operation will occur while evolving a new generation.
 o DemeSize
The number of individuals in each demetic group, if DemeticGrouping is true.
 o DemeticGrouping
Determines whether demetic migration is performed.
 o DemeticMigProbability
Percent probability that demetic migration will occur for each demetic group, if DemeticGrouping is true.
 o GoodRuns
GPRun does multiple runs until this many of them terminate with the best individual's fitness below TerminationFitness.
 o GPGREEDYSELECTION
A fitness-based selection type that uses greedy over-selection.
 o GPGROW
A tree creation type that makes every node but those on the bottom level a function and that builds every tree to MaximumDepthForCreation.
 o GPPROBABILISTICSELECTION
A fitness-based selection type that uses a roulette algorithm.
 o GPRAMPEDGROW
A tree creation type that is like GPGROW but starts with a tree depth of two and increases the depth by one for each tree until it reaches MaximumDepthForCreation, at which point it cycles back to two.
 o GPRAMPEDHALF
A tree creation type that builds alternating trees using the GPRAMPEDVARIABLE and GPRAMPEDGROW methods.
 o GPRAMPEDVARIABLE
A tree creation type that is like GPVARIABLE but starts with a tree depth of two and increases the depth by one for each tree until it reaches MaximumDepthForCreation, at which point it cycles back to two.
 o GPTOURNAMENTSELECTION
A fitness-based selection type that uses a tournament algorithm.
 o GPVARIABLE
A tree creation type that selects each non-root node with a 50:50 chance of becoming a function or terminal and that continues building every tree to MaximumDepthForCreation.
 o MaximumComplexity
The largest complexity (number of nodes) allowed in any individual GP, including the main branch and all ADFs.
 o MaximumDepthForCreation
The largest depth allowed for newly created trees.
 o MaximumDepthForCrossover
The largest depth allowed for trees after crossover.
 o NumberOfGenerations
The maximum number of generations in a run.
 o PopulationSize
The number of individuals (GP instances) in a population.
 o PrintDetails
Determines whether a detail file is generated by GPRun.
 o PrintExpression
Determines whether the detail file shows the s-expression for each selected individual after each generation.
 o PrintPopulation
Determines whether the detail file includes every individual in the population (PrintPopulation = true) or just the best and worst individuals in the population (PrintPopulation = false).
 o PrintTree
Determines whether the statistics file shows a pseudo-graphic tree for the best individual of each run.
 o SelectionStr
An array of strings used to detect and print the selection type in configuration files and status reports.
 o SelectionType
The strategy used to select individuals with a probability related to their fitness.
 o ShrinkMutationProbability
Percent probability that shrink mutation will occur for each individual added to a new generation.
 o SteadyState
Determines whether each new generation is created in isolation from the previous generation (SteadyState = false) or is created by replacing the weaker individuals one by one (SteadyState = true).
 o SwapMutationProbability
Percent probability that swap mutation will occur for each individual added to a new generation.
 o TerminationFitness
A run terminates if the best individual in any generation has standardized fitness below this level.
 o TestDiversity
Determines whether gpjpp tests the diversity of genetic populations.
 o TournamentSize
Number of randomly selected individuals forming a "tournament" when SelectionType is GPTOURNAMENTSELECTION.
 o TreeFontSize
The font size in points used to draw the text in graphic trees enabled by PrintTree.
 o UseADFs
A boolean that can be tested by user functions to determine whether to add ADFs to the branch definition and whether to evaluate them in fitness functions.

Constructor Index

 o GPVariables()
Public null constructor used to create a set of variables with default values and also during stream loading.
 o GPVariables(GPVariables)
A constructor that can be called to clone GPVariables.

Method Index

 o clone()
Implements the Cloneable interface.
 o equals(Object)
Determines whether this set of variables equals another object.
 o getBoolean(Properties, String, boolean)
An internal routine used to convert a property string to a boolean.
 o getCreationType(Properties, String, int)
An internal routine that calls getEnumerated type to convert a property string to the int value for a creation type.
 o getDouble(Properties, String, double)
An internal routine used to convert a property string to a double.
 o getEnumeratedType(Properties, String[], String, int)
An internal routine used to convert a property string to an enumerated type with int values.
 o getInt(Properties, String, int)
An internal routine used to convert a property string to an int.
 o getSelectionType(Properties, String, int)
An internal routine that calls getEnumerated type to convert a property string to the int value for a selection type.
 o isA()
Returns a code identifying the class in a stream file.
 o load(DataInputStream)
Loads the GPVariables from the specified stream.
 o load(Properties)
Loads the values from a Properties container (read from a configuration file) into the GPVariables fields.
 o printOn(PrintStream, GPVariables)
Writes the GPVariables fields in the format of a Properties text file.
 o save(DataOutputStream)
Writes the GPVariables to the specified stream.

Variables

 o GPVARIABLE
  public final static int GPVARIABLE
A tree creation type that selects each non-root node with a 50:50 chance of becoming a function or terminal and that continues building every tree to MaximumDepthForCreation.
 o GPGROW
  public final static int GPGROW
A tree creation type that makes every node but those on the bottom level a function and that builds every tree to MaximumDepthForCreation.
 o GPRAMPEDHALF
  public final static int GPRAMPEDHALF
A tree creation type that builds alternating trees using the GPRAMPEDVARIABLE and GPRAMPEDGROW methods. The default method.
 o GPRAMPEDVARIABLE
  public final static int GPRAMPEDVARIABLE
A tree creation type that is like GPVARIABLE but starts with a tree depth of two and increases the depth by one for each tree until it reaches MaximumDepthForCreation, at which point it cycles back to two. Note that if TestDiversity is enabled many of the shallow trees are duplicates, so the distribution is skewed toward deeper trees than one might expect.
 o GPRAMPEDGROW
  public final static int GPRAMPEDGROW
A tree creation type that is like GPGROW but starts with a tree depth of two and increases the depth by one for each tree until it reaches MaximumDepthForCreation, at which point it cycles back to two. Note that if TestDiversity is enabled many of the shallow trees are duplicates, so the distribution is skewed toward deeper trees than one might expect.
 o CreationStr
  protected final static String CreationStr[]
An array of strings used to detect and print the creation type in configuration files and status reports. The values are "Variable", "Grow", "RampedHalf", "RampedVariable", and "RampedGrow".
 o GPPROBABILISTICSELECTION
  public final static int GPPROBABILISTICSELECTION
A fitness-based selection type that uses a roulette algorithm. The default method.
See Also:
probabilisticSelection
 o GPTOURNAMENTSELECTION
  public final static int GPTOURNAMENTSELECTION
A fitness-based selection type that uses a tournament algorithm.
See Also:
tournamentSelection
 o GPGREEDYSELECTION
  public final static int GPGREEDYSELECTION
A fitness-based selection type that uses greedy over-selection. When this type is enabled, demetic grouping is always disabled.
See Also:
greedySelection
 o SelectionStr
  protected final static String SelectionStr[]
An array of strings used to detect and print the selection type in configuration files and status reports. The values are "Probabilistic", "Tournament", and "Greedy".
 o PopulationSize
  public int PopulationSize
The number of individuals (GP instances) in a population. If SteadyState is false, two populations of this size are created and filled. If SteadyState is true, only one population is created, and weaker individuals are replaced by new individuals as they are created. Default 500.
 o NumberOfGenerations
  public int NumberOfGenerations
The maximum number of generations in a run. If the best individual's standardized fitness drops below TerminationFitness, the run will terminate sooner. Default 51.
 o CreationType
  public int CreationType
The strategy used to create generation 0. Default GPRAMPEDHALF.
 o MaximumDepthForCreation
  public int MaximumDepthForCreation
The largest depth allowed for newly created trees. Default 6. The minimum tree depth is always 2.
 o MaximumDepthForCrossover
  public int MaximumDepthForCrossover
The largest depth allowed for trees after crossover. Default 17. Note that MaximumDepthForCrossover must always be at least as large as MaximumDepthForCreation.
 o MaximumComplexity
  public int MaximumComplexity
The largest complexity (number of nodes) allowed in any individual GP, including the main branch and all ADFs. Although keeping a tight rein on complexity can speed the algorithm and cut memory requirements, be cautious not to limit the complexity too much. This can lead to lack of diversity in the population and to wasted time attempting to create and evolve new individuals. Default 200.
See Also:
create
 o SelectionType
  public int SelectionType
The strategy used to select individuals with a probability related to their fitness. Default GPPROBABILISTICSELECTION.
 o TournamentSize
  public int TournamentSize
Number of randomly selected individuals forming a "tournament" when SelectionType is GPTOURNAMENTSELECTION. Default 7.
 o CrossoverProbability
  public double CrossoverProbability
Percent probability that a crossover operation will occur while evolving a new generation. Default 90.0.
 o CreationProbability
  public double CreationProbability
Percent probability that a creation operation will occur while evolving a new generation. Default 0.0.
 o SwapMutationProbability
  public double SwapMutationProbability
Percent probability that swap mutation will occur for each individual added to a new generation. Default 0.0.
 o ShrinkMutationProbability
  public double ShrinkMutationProbability
Percent probability that shrink mutation will occur for each individual added to a new generation. Default 0.0.
 o TerminationFitness
  public double TerminationFitness
A run terminates if the best individual in any generation has standardized fitness below this level. Default 0.0. Because fitness must always be non-negative, the default value will never cause a run to stop before NumberOfGenerations.
 o GoodRuns
  public int GoodRuns
GPRun does multiple runs until this many of them terminate with the best individual's fitness below TerminationFitness. Set it to 0 if you want just a single run regardless of results. Default 5.
 o UseADFs
  public boolean UseADFs
A boolean that can be tested by user functions to determine whether to add ADFs to the branch definition and whether to evaluate them in fitness functions. Provides a convenient way to test performance without recompiling. This configuration variable is not used by gpjpp itself. Default false.
 o TestDiversity
  public boolean TestDiversity
Determines whether gpjpp tests the diversity of genetic populations. If true, gpjpp guarantees that there are no duplicate individuals in generation 0 and then tracks and reports the diversity of succeeding generations. If false, gpjpp does not verify or measure diversity. Default true.
 o ComplexityAffectsFitness
  public boolean ComplexityAffectsFitness
A boolean that can be tested by the user evaluate() function to determine whether to incorporate complexity into the fitness calculation. When this is done, solutions tend to be parsimonious and average population complexity tends to remain lower. Provides a convenient way to test population statistics without recompiling. This configuration variable is not used by gpjpp itself. Default true.
 o CheckpointGens
  public int CheckpointGens
The number of generations between checkpoints saved by GPRun. If zero, checkpointing is not performed at all, in which case runs cannot be restarted after a crash or system shutdown. If one, a checkpoint is saved after every generation. Default 0.
 o DemeticGrouping
  public boolean DemeticGrouping
Determines whether demetic migration is performed. If true, the overall population is subdivided into groups of size DemeSize. These groups are isolated for the purpose of fitness-based selection. After all the demetic groups of a new generation are created, one individual from each group is fitness-selected and swapped with a fitness-selected individual from the next group, with each swap controlled by the probability DemeticMigProbability. Default false.
 o DemeSize
  public int DemeSize
The number of individuals in each demetic group, if DemeticGrouping is true. PopulationSize must be an exact integer multiple of DemeSize. Default 100.
 o DemeticMigProbability
  public double DemeticMigProbability
Percent probability that demetic migration will occur for each demetic group, if DemeticGrouping is true. Default 100.0.
 o AddBestToNewPopulation
  public boolean AddBestToNewPopulation
Determines whether the best individual is automatically added to the next generation, when SteadyState is false. Default false.
See Also:
generate
 o SteadyState
  public boolean SteadyState
Determines whether each new generation is created in isolation from the previous generation (SteadyState = false) or is created by replacing the weaker individuals one by one (SteadyState = true). Steady state operation reduces peak memory usage by a factor of two. Default false.
See Also:
generate
 o PrintDetails
  public boolean PrintDetails
Determines whether a detail file is generated by GPRun. The detail file includes the population index, heritage, fitness, complexity, depth, and optionally the s-expression for individuals after each generation. Default false.
 o PrintPopulation
  public boolean PrintPopulation
Determines whether the detail file includes every individual in the population (PrintPopulation = true) or just the best and worst individuals in the population (PrintPopulation = false). Default false.
 o PrintExpression
  public boolean PrintExpression
Determines whether the detail file shows the s-expression for each selected individual after each generation. Also determines whether the statistics file includes the s-expression for the best individual of each run. Default true.
See Also:
showGeneration
 o PrintTree
  public boolean PrintTree
Determines whether the statistics file shows a pseudo-graphic tree for the best individual of each run. Also determines whether gif files are created showing the best individual of each run in true graphic format. Default true.
See Also:
showFinalGeneration
 o TreeFontSize
  public int TreeFontSize
The font size in points used to draw the text in graphic trees enabled by PrintTree. The typeface is always Courier, a monospaced font. Default 12.

Constructors

 o GPVariables
  public GPVariables()
Public null constructor used to create a set of variables with default values and also during stream loading.
 o GPVariables
  public GPVariables(GPVariables gpo)
A constructor that can be called to clone GPVariables. Normally not used.

Methods

 o clone
  protected synchronized Object clone()
Implements the Cloneable interface. This clones GPVariables but is normally not used.
Returns:
the cloned object.
Overrides:
clone in class GPObject
 o isA
  public byte isA()
Returns a code identifying the class in a stream file.
Returns:
the ID code VARIABLESID.
Overrides:
isA in class GPObject
 o equals
  public boolean equals(Object obj)
Determines whether this set of variables equals another object. It returns true if obj is not null, is an instance of GPVariables (or a descendant), and contains the same field values. This function is called when a checkpoint is loaded by GPRun, to determine whether the program and the checkpoint are consistent. One can think of various harmless changes made to GPVariables that would still allow a checkpoint to continue (increasing the number of generations, for example), but this is not allowed here.
Parameters:
obj - any Java object reference, including null.
Returns:
true if this and obj are equivalent.
Overrides:
equals in class Object
 o getInt
  protected int getInt(Properties props,
                       String proStr,
                       int def)
An internal routine used to convert a property string to an int. If the numeric conversion fails, the default value is used.
 o getBoolean
  protected boolean getBoolean(Properties props,
                               String proStr,
                               boolean def)
An internal routine used to convert a property string to a boolean. Acceptable boolean values in a configuration file are 0/non-zero, false/true, and FALSE/TRUE. If the conversion fails, the default value is used.
 o getDouble
  protected double getDouble(Properties props,
                             String proStr,
                             double def)
An internal routine used to convert a property string to a double. If the numeric conversion fails, the default value is used.
 o getEnumeratedType
  protected int getEnumeratedType(Properties props,
                                  String EnumStr[],
                                  String proStr,
                                  int def)
An internal routine used to convert a property string to an enumerated type with int values. Either the integer value or the string representation is acceptable, and string matching is not case sensitive. If the conversion fails, the default value is used.
 o getCreationType
  protected int getCreationType(Properties props,
                                String proStr,
                                int def)
An internal routine that calls getEnumerated type to convert a property string to the int value for a creation type.
See Also:
CreationStr
 o getSelectionType
  protected int getSelectionType(Properties props,
                                 String proStr,
                                 int def)
An internal routine that calls getEnumerated type to convert a property string to the int value for a selection type.
See Also:
SelectionStr
 o load
  public synchronized void load(Properties props)
Loads the values from a Properties container (read from a configuration file) into the GPVariables fields. If the property strings are invalid, default values for the affected fields remain unchanged. If props is null, nothing happens.
See Also:
getInt, getBoolean, getDouble, getCreationType, getSelectionType
 o load
  protected synchronized void load(DataInputStream is) throws ClassNotFoundException, IOException, InstantiationException, IllegalAccessException
Loads the GPVariables from the specified stream.
Throws: ClassNotFoundException
if the class indicated by the stream's ID code is not registered with GPObject.
Throws: InstantiationException
if an error occurs while calling new or the null constructor of the specified class.
Throws: IllegalAccessException
if the specified class or its null constructor is not public.
Throws: IOException
if an error occurs while reading the stream.
Throws: RuntimeException
if the ID code read next in the stream doesn't match the ID code returned by isA().
Overrides:
load in class GPObject
 o save
  protected void save(DataOutputStream os) throws IOException
Writes the GPVariables to the specified stream.
Throws: IOException
if an error occurs while writing the stream.
Overrides:
save in class GPObject
 o printOn
  public void printOn(PrintStream os,
                      GPVariables cfg)
Writes the GPVariables fields in the format of a Properties text file.
Overrides:
printOn in class GPObject

All Packages  Class Hierarchy  This Package  Previous  Next  Index