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.
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 OBJECTGeneticAlgorithmIndividual:set-fitness.
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.
Returns the best fitness seen so far.
Returns the probability of crossover during reproduction.
Returns the current GeneticAlgorithmIndividual subclass instance being evaluated. See also 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.
Returns the duration of a single fitness test. This value can be set with the method set-test-duration. The default value is 20.
Returns the current generation. The generation count begins at 0.
Returns the generation limit. See get-generation-limit for details.
Returns the percent probability of mutation during reproduction. The default value is 75%.
Returns the size of the population. The default value is 30, and can be set with set-population-size.
Returns the percent probability of a new random individual during reproduction. The default value is 5%.
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.
This method performs a tournament selection for reproduction. It is used internally and typically not called by any other object.
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.
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.
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%.
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.
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.
Call this method to specify the class representing an individual in your genetic algorithm. className must be a string representing a subclass of GeneticAlgorithmIndividual.
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.
Sets the probability of mutation to percent%. This specifies the approximate percentage of agents to be generated through mutation. The default value is 75%.
Sets the number of individuals in the population to size.
Sets the probability of creating a new random individual to percent%. The default value is 5%.
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.
Undocumented: it will be our little secret!
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.
Implement this method to perform any setup necessary when the fitness test begins.
Switches to the next indivisual