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 : GeneticAlgorithm

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

Class description:

The GeneticAlgorithm class allows you to set up a genetic algorithm, in which strategies can be evolved to solve a wide variety of problems.

To run a genetic algorithm, you will need to a create custom subclass of this object, GeneticAlgorithm, and of its companion object GeneticProgrammingIndividual.

Your subclass of GeneticAlgorithm must implement two important methods: start-fitness-test and end-fitness-test. These methods are automatically called at the beginning and end of the fitness tests respectively.

Class methods:

Getting and Setting Parameters for the Genetic Algorithm

Methods Used Internally by the Genetic Algorithm

Methods for Cluster Migration

Methods to Override in Custom Subclasses



end-fitness-test of individual (object)

In this method, you should perform any cleanup neccessary when the fitness test ends. You should also make sure that the individual's fitness value is set using set-fitness (GeneticAlgorithmIndividual).


examine individual currentIndividual (object)

Called automatically during each generation's report, this method examines and outputs information about an individual in the population. The default implementation simply prints out the object variable, but you may override this method to print out more information about the individual.


get-best-fitness

Returns the best fitness seen so far.


get-crossover-percent

Returns the probability of crossover during reproduction.


get-current-individual

Returns the current GeneticAlgorithmIndividual subclass instance being evaluated. See also get-current-individual-index.


get-current-individual-index

Returns the index of the individual currently being tested. Returns -1 before any fitness tests have been run. See also get-current-individual.


get-fitness-test-duration

Returns the duration of a single fitness test. This value can be set with the method set-test-duration. The default value is 20.


get-generation

Returns the current generation. The generation count begins at 0.


get-generation-limit

Returns the generation limit. See get-generation-limit for details.



get-mutation-percent

Returns the percent probability of mutation during reproduction. The default value is 75%.


get-population-size

Returns the size of the population. The default value is 30, and can be set with set-population-size.


get-randomize-percent

Returns the percent probability of a new random individual during reproduction. The default value is 5%.


get-tournament-size

Returns the tournament size. The tournament size specifies how many individuals are considered in a single selection "tournament". The larger the tournament size, the more competative selection becomes. The tournament size can be set with set-tournament-size. The default value is 5.


non-spatial-tournament-select

This method performs a tournament selection for reproduction. It is used internally and typically not called by any other object.


prepare-for-generation number n (int)

This method is called when a generation is setup. The default implementation does nothing, but the method may be overriden in order to carry out any preparations necessary for a new generation.


report at-generation generation (int) with-best-individual bestIndividual (object) with-average-fitness fitness (double)

Prints out a report of the progress at each generation, with the most fit object passed in as bestIndividual. The default implementation of this method simply prints out the generation number, best fitness and calls examine on the best individual, but you may override the method to print out any other desired information.


set-crossover-percent to percent (int)

Sets the probability of crossover to percent%. This specifies the approximate percentage of agents to be generated through crossover during reproduction. Crossover is not enabled by default, so the default value is 0%.


set-fitness-test-duration to duration (double)

Sets the duration of a single fitness test. Specifies that a single individual should be allowed to run for duration simulated seconds before assessing its fitness and switching to the next individual. The default value is 20.


set-generation-limit to newLimit (int)

Sets the generation limit to newLimit. The simulation will end after newLimit generations have passed. If newLimit is 0, then the generation limit is disabled.


set-individual-class to className (string)

Call this method to specify the class representing an individual in your genetic algorithm. className must be a string representing a subclass of GeneticAlgorithmIndividual.



set-migration-percent to percent (int)

Sets the probability of migration to percent%. This specifies the approximate percentage that individuals will migrate to another host during reproduction, if migration is enabled.



set-mutation-percent to percent (int)

Sets the probability of mutation to percent%. This specifies the approximate percentage of agents to be generated through mutation. The default value is 75%.


set-population-size to size (int)

Sets the number of individuals in the population to size.


set-randomize-percent to percent (int)

Sets the probability of creating a new random individual to percent%. The default value is 5%.


set-seed-individual to theSeed (object)

The seed individual is used to start the genetic algorithm at a specfic location in the search space by using the seed individual's paramters as a starting point.


set-tournament-size to tsize (int)

Sets the tournament size to tsize. The tournament size specifies how many individuals are considered in a single selection "tournament". The larger the tournament size, the more competative selection becomes. The default value is 5.


start-fitness-test of individual (object)

Implement this method to perform any setup necessary when the fitness test begins.


switch-individual

Switches to the next indivisual


Documentation created Sun Oct 7 19:13:02 2007