Help Topics Concepts Package Class

## Genetic Search Agent Properties and Use

### Properties

The Genetic Search Agent panel provides these options:

Class Name
  Enter the name of the class of the Genetic Object that represents the population members and implements the genetic operators and fitness values. Specify it in package form, such as

      com.ibm.package.subpackage.classname

  The class should inherit from the AbleGeneticObject. Pressing the Init button will cause the class to be instantiated and populate the Genetic Operators and Fitness Values list. The class must be in your CLASSPATH.

Population Size
  Enter the size of the population for each generation.
No duplicates
  Select this checkbox to insure that only one population member will have a given chromosome configuration.
Replacement Size
  Enter the the number of population members to replace in each generation. The most fit member of each generation is always retained, even if replacment size equals population size.
Normalized fitness
  Select this checkbox to use linear-normalized fitness values to select individuals for reproduction. If not selected, raw fitness values are used.
Maximum Passes
  Enter the maximum number of generations to create during evolution. Evolution will stop when either the Maximum Passes or the Fitness Threshold value of the best population member is reached.
Fitness Threshold
  When any population member reaches the fitness value, evolution has progressed sufficiently and will stop. Evolution will stop when either the Maximum Passes or Fitness Threshold value is reached. This value is unique to te specified Genetic Object class.
Genetic Operators and Fitness Values
  This lists the operators available for use from this GeneticObject class as well as the probabilities for their selection.
Crossover Rate
  Enter the rate that a crossover operator will actually be applied once the operator is selected. This is a decimal number between 0 and 1.
Mutation Rate
  Enter the rate that a bit or gene will be mutated once the mutate operator is selected. This is a decimal number between 0 and 1.

### Use

The Genetic Search Agent panel is used to create generations until one member satisfies the desired fitness level, or the number of generations created reaches a predefined limit. The population property Vector is maintained in order of highest fitness first.

Steps in using the panel include:

1. Enter the name of the class that extends the AbleGeneticObject. Sample objects are provided in the

       com.ibm.able.examples.genetic

   package. Providing a class name enables the Set button.

2. Select any other options to use before initializing the agent by pressing the Initialize button. This will create the necessary beans and connections between the beans.
3. Edit the Genetic Operators as needed to specify the probability that they will be selected during evolution.
4. Set the Crossover and Mutation Rates as desired.
5. Press the Start Evolving button to begin creating generations and evaluating their members for fitness. Once evolution has begun, this button will toggle to Stop Evolving. Evolution will continue until the toggled button is pressed, the number of generations created reaches the Maximum Passes value, or a population member reaches the specified Fitness Threshold. The example TstGeneticFunction1 uses a chromosome analogy and its fitness function is maximizing the sum of the chromosome value. Since its chromosome length is 20, the maximum possible fitness is also 20.
6. You may wish to press the Stop Evolving button, change a property or two, and start again. Press the Reset Beans button to re-intialize the population before starting again if you wish.

The most useful inspection parameters include:

- AvgFitness, which displays the average fitness value calculated during evolution.
- ChromosomeLength, whose value represents the maximum possible fitness obtainable.
- FitnessThreshold - when at least one member of the population reaches this value, evolution completes.
- MaxFitness, the maximum fitness value observed during evolution.
- MinFitness, the minimum fitness value observed during evolution.
- NumPasses, the number of population replacements, or generations. Evolution will stop when this value reaches the maximum passes.
- Population, an array displayed as the chromosome string and fitness value. Since the array is ordered from best or highest fitness to lowest, displaying index 0 shows the population member with the highest fitness value in the current population.