These pages are auto-generated from self-documenting comments embedded in class files.
For more information on breve and steve, refer to the breve homepage.

## Object : PushGP

This class is included as part of the file PushGP.tz.
To use this class in a simulation, include the line "@use PushGP."

### Class description:

> This class is a special control class used to implement experiments using the Push Genetic Programming (PushGP) system. PushGP is a system which uses genetic programming and the Push programming language to attempt to evolve solutions to a wide variety of problems. For more information on Push and PushGP, see the class PushInterpreter.

> This class is appropriate for evolving Push programs which are only run once per fitness case.

> To implement a PushGP experiment you will need to setup a PushGP object which overrides two methods: setup-fitness-test, which sets up a fitness test and compute-error, which is used to compute the fitness of an individual.

> Additionally, other methods in this class are useful for configuring the genetic programming environment and a variety of parameters including population size, mutation rate, crossover rate, and the Push language interpreter set.

> Finally, you may also wish to add custom instructions to the Push interpreter objects which manipulate data or trigger actions in the simulated world. The Push interpreter can be retrieved using the method get-interpreter, and adding instructions is documented in PushInterpreter.

### Class methods:

> Setting and Retrieving GP Parameters

> - get-crossover-percent
> - get-deletion-percent
> - get-generation-limit
> - get-mutation-percent
> - get-population-size
> - get-tournament-size
> - read-interpreter-config
> - seed-population
> - set-crossover-percent
> - set-deletion-percent
> - set-generation-limit
> - set-mutation-percent
> - set-population-size
> - set-spatial-radius
> - set-tournament-size

> Getting the Push Interpreter Used During Evolution

> - abort-fitness-test
> - auto-simplify
> - compute-diversity
> - get-current-individual
> - get-interpreter
> - get-program-limit-penalty
> - run-tournament

> Methods Overridden by the User To Set Up PushGP Experiments

> - compute-error
> - compute-error-vector-fitness
> - count-fitness-cases
> - examine
> - report
> - reproduce
> - setup-fitness-test

`abort-fitness-test with-fitness fitness = 99999999 (float)`

> Aborts the currently running fitness

`auto-simplify program p (object)`

> Programs generated through genetic programming are often complicated and difficult to understand. This method attempts to simplify an evolved push program while maintaining the same fitness.

> Each time this method is invoked, a random simplification is preformed on the program p. If the simplification does not harm the fitness, p is modified to contain the simplification, otherwise, nothing happens. This method should be called repeatedly -- perhaps 100 times or more to aggressively simplify an unweildy program.

`compute-diversity for-tolerance t (int)`

> Computes the diversity of the current population, as defined by the PushDiversityPool object. Returns the number of unique "species" which differ by less than t points.

`compute-error for-fitness-case n (int) with-interpreter interpreter (object)`

> This method must be overridden by the user in order to run a PushGP experiment. The job of this method is to inspect the state of the PushInterpreter object and determine the fitness (in terms of error) of the specified fitness case. This typically involves comparing values from the interpreter's stacks against desired values.

> For example, with a symbolic regression problem, this method might return the difference between the top of the float stack, and the predetermined "correct" answer for the specified fitness case. For example:

>      return (interpreter get-float-stack-top) - desiredOutputs{ n }.

`compute-error-vector-fitness for-errors errorList (list)`

> This method takes a list of errors returned by compute-error for all fitness cases, and produces a fitness value. The default implementation of this method computes the fitness by summing the absolute values of the errors, which should suffice for most applications.

> Overriding this method is optional.

`count-fitness-cases`

> This method must be overriden by the user in order to run a PushGP experiment. This method should return the number of fitness cases to be run.

`examine program p (object)`

> This method is called when a solution is found. You should override this method to preform any additional analysis you'd like. Typically this involves examining the program for generalization.

> The default implementation simplifies the program p for 1000 iteration using auto-simplify and prints out the result.

`get-crossover-percent`

> Returns the crossover percent. See set-crossover-percent for more information.

`get-current-individual`

> Returns the PushProgram currently being evaluated.

`get-deletion-percent`

> Returns the deletion percent. See set-deletion-percent for more information.

`get-generation-limit`

> Returns the generation limit. See set-generation-limit for more information.

`get-interpreter`

> Returns the PushInterpreter object that this object is using for fitness tests.

`get-mutation-percent`

> Returns the mutation percent. See set-mutation-percent for more information.

`get-population-size`

> Returns the population size. See set-population-size for more information.

`get-program-limit-penalty`

> Returns a penalty value applied to program which hit their evaluation limit. The default value is .1, but you may override this method in order to penalize programs differently according to the problem.

`get-tournament-size`

> Returns the tournament size. See set-tournament-size for more information.

`read-interpreter-config from-file file (string)`

> Reads a configuration file for the interpreter used in the fitness tests. Changing the configuration also reinitializes the evolving population (since instructions sets may be changed).

`report with-best bestIndividual (object)`

> Logs information to the output at every generation. This method may be overridden to provide more (or less) output data.

> The argument bestIndividual is the best individual in the population and is provided so that it may be inspected by the user if this method is overridden.

`reproduce`

> Used internally.

`run-tournament for-index index = -1 (int)`

> Runs a tournament selection from the population. Used internally during reproduction uses the tournament size set with set-tournament-size.

> This method may be overridden to implement a custom tournament selection if desired, though the default implementation should suffice in most situations.

`seed-population with-program pushProgram (object)`

> Uses pushProgram to seed the initial population.

`set-crossover-percent to n (int)`

> Sets the percentage of agents generated by genetic crossover at each generation. This should be a value between 0 and 100. The default value is 40.

`set-deletion-percent to n (int)`

> Sets the percentage of agents generated by genetic deletion at each generation. This should be a value between 0 and 100. The default value is 5.

`set-generation-limit to n (int)`

> Sets the generation limit to n. If no solution is found by the generation limit, the simulation with terminate. The default value is 300.

`set-mutation-percent to n (int)`

> Sets the percentage of agents generated by genetic mutation at each generation. This should be a value between 0 and 100. The default value is 40.

`set-population-size to n (int)`

> Sets the population size to n and reinitializes the population. The default value is 2000.

`set-spatial-radius to n (int)`

> Sets the spatial radius used for tournament selection during reproduction. Setting to 0 disables spatial effects.

`set-tournament-size to n (int)`

> Sets the tournament size to n. The tournament size determines how many individuals are examined during tournament selection. The default value is 7.

`setup-fitness-test for-fitness-case n (int) with-interpreter interpreter (object)`

> This method must be overridden by the user in order to run a PushGP experiment. The job of this method is to prepare to run the specified fitness test. This typically means pushing input values onto the PushInterpreter object's stacks.

> In a symbolic regression problem, for example, this method might push a predetermined input value onto the float stack.

>      interpreter push-float value inputValues{ n }.

Documentation created Fri Aug 8 15:16:49 2008