Algorithms

Spring 2007
course
navigation

may 7

genetic algorithms

Last time there was interest in discussing how "evolutionary algorithms" work.
The name comes from thinking of biological evolution as a search for the "fittest" DNA sequence.
Consider each member of a population as a potential solution to a problem you're trying to solve. Then seaching for a good solution to the problem may be done in a manner than mimics evolution. The general approach looks like this:
(1) Generate a population. (Typically random initially.) (2) Grow the population either by combining individuals (e.g. sexual reproduction) or by mutating individuals or both. Essentially this is a "local" search, searching for small incremental improvements. (3) Shrink the population by keeping the best. ("Survival of the fittest.") (4) Repeat steps (2) and (3) many times.
For a good example, google search "genetic traveling salesman":
To run TSPGA (Johannes Sarg's 1998 Java visualization) on cs:
$ cd TSPGA $ java TSPGA # Simulation > Initialize ... (Set up default values) # Options > Set Problem... (add towns) # Options > GA Parameters... (mutate, recombine options, population size, ...) # Simulation > Generation... (one time through grow/shrink loop; cntl-shift-G) # repeat last and/or Simulation/Run...
To run pygene's TSP on cs:
$ cd pygene/pygene-0.2.1 $ ./demo_salesman.py gen=0 best=6654.28258914 avg=7432.50187619 gen=1 best=5158.4389665 avg=6204.96477575 ... cntl-C Best solution: ...
Running Steven Tanimoto's lisp version (from Hampshire 2000 AI course; see comments at end of source code for invocations) :
$ cd lisp-TSP $ clisp [1]> (load "genetic-salesman") T [2]> (ga-salesman *sp* 10 2) [3]> (ga-salesman *sp* 20 20)
There are lots of examples of this out there, including general purpose libraries for dealing with problems using this method.
Unix libraries :
$ apt-cache search genetic python-genetic - genetic algorithms in Python libevocosm-dev - a C++ framework for developing evolutionary algorithms ...
http://cs.marlboro.edu/ courses/ spring2007/algorithms/ notes/ may_7
last modified Monday May 7 2007 11:41 am EDT