Introduction to Genetic Algorithms

This talk is available at http://www.mcs.drexel.edu/~shartley/geneticAlgorithms.html. It has been brazenly excerpted (without permission) from Section 2.6 of a recent book, Concurrent Programming: The Java Programming Language, © 1998 Oxford University Press.

Biology

Genetic algorithms are used in search and optimization, such as finding the maximum of a function over some domain space.

An initial population of random bit strings is generated.

From the initial population of chromosomes, a new population is generated using three genetic operators: reproduction, crossover, and mutation.

The new population generated with these operators replaces the old population.

Genetic algorithms work in many situations because of some hand waving called The Schema Theorem.

Example

To illustrate the manipulation of chromosomes by the genetic operators reproduction, crossover, and mutation, we will look at some sample program output for a very simple problem.

We first see the randomly generated initial population, in which the best fitness is 5.

The GA parameters are:
  populationSize      = 4         numXoverPoints      = 1
  crossoverRate       = 0.7       mutationRate        = 0.1
  doElitism           = false     printPerGens        = 1
  maxGenerations      = 3         Debug.flag          = true
  logFileName         = bit.out
BitCountChromosome: chromosome length is 10
GA: chromosome length = 10
GA: mainLoop
Known solution fitness is 10.0
p0: 0000110100 this chromosome has 3 bits set fitness= 3.0
p1: 1100010110 this chromosome has 5 bits set fitness= 5.0
p2: 1111001000 this chromosome has 5 bits set fitness= 5.0
p3: 0101011001 this chromosome has 5 bits set fitness= 5.0
currentBest (generation=0):
   1100010110 this chromosome has 5 bits set fitness= 5.0
Initial population:
   generation=0 best value=5.0 avg=4.5 stddev=1.0

A proportional selection algorithm called the roulette wheel method is used for reproduction.

Now that we have the new population, it is time to apply crossover and then mutation.

Each chromosome is now given the chance to mutate by generating a random number between 0 and 1 for each of its genes.

This completes the first generation.

After two more generations, the population is again listed.

Click here for the output of one run of the program on a more difficult version of this problem: 100 bits in each chromosome. The fitness is the square of the percentage of bits set to give the GA better guidance.

Applications

Genetic algorithms have been very successful at solving many types of problems.

Here are two example problems, one discrete and one continuous, that are more realistic.

  1. For an arbitrary expression in n Boolean variables, find an assignment of true and false values to the Boolean variables in the expression that make the expression true, if such an assignment exists.
    • This is called the Boolean satisfiability problem (SAT).
    • Each assignment of true and false values to the variables can be encoded in a bit string of length n, 0 for false and 1 for true.
    • The fitness of such a chromosome is how ``close'' to being true the assignment makes the Boolean expression, such as how many clauses in the expression are individually made true by the assignment.
    • Some (in Postscript) SATs are very hard for GAs.
  2. Maximize the function
      f(x1, x2, x3) = 21.5 + x1 sin (4 pi x1) + x2 sin (20 pi x2) + x3
    for x1 in [-3.0,12.1], x2 in [4.1,5.8], and x3 in [0.0,1.0].
    • This function is highly multimodal.
    • A chromosome can be encoded in three real numbers, one for each of x1, x2, and x3, over their respective ranges.
    • The fitness of a chromosome is the value of f(x1,x2,x3) for the x1, x2, and x3 encoded in the chromosome.
    • Click here for the output of one run of the program on this problem.

Difficulties

Hitchhiking.

11111111........................................................
........11111111................................................
................11111111........................................
........................11111111................................
................................11111111........................
........................................11111111................
................................................11111111........
........................................................11111111

Deception.

Java Applet

A very nice Java applet: http://www.taygete.demon.co.uk/java/ga/index.html.

Java Application

An application (stand-alone program) written in Java using genetic algorithms to illustrate various features of object oriented programming: http://www.mcs.drexel.edu/~shartley/ConcProgJava/sequential.html#SIMGA

References and Related Material

A two-part overview of genetic algorithms with an academic, theoretical, and research orientation (in Postscript): Part 1, Part 2.

David E. Goldberg, Genetic Algorithms in Search, Optimization, and Machine Learning, Addison-Wesley, 1989.

Melanie Mitchell, An Introduction to Genetic Algorithms, MIT Press, 1996.

Genetic Algorithms FAQ.
Where to try to get the FAQ if the above does not work.
Other GA sites (this file is a year old so some links in it may not work).
Another GA Web site.
GA archive Web site.