Colorado State University CS540: Artificial Intelligence (Spring, 98)

Computer Science Department
Colorado State University

Assignment 2: Genetic Algorithms

Assigned:  March 16
Due:  April 1
NTU/SURGE Due:  April 15

In this assignment you will develop and use software for searching for optimizing a function.  You will compare three search methods:  genetic algorithms, simulated annealing, and hill climbing.  Each will be applied to optimizing a given function of a single argument.

The Function

The function to be optimized is graphed in the following figure.
This function is generated by the equation
                                           2
              4       -1/(2w) (x/maxx - c )
fitness(x) = Sum v  e                    i
             i=1  i

where v_i = [0.5 0.25 1 0.25],
      c_i = [0.125 0.375 0.625 0.875],
      w = 0.003, and
      maxx = 1073741823.

The Search Algorithms

Use the algorithm descriptions found in the handouts given in class, from the books by Norvig and by Dean.  Experiment with each algorithm to find algorithm parameters that work well.  Spend some time at this stage to make each algorithm work as well as you can on this particular function.

To see what each algorithm is doing, plot the function being optimized, fitness(x), which doesn't change.  On the same graph plot marks that show the progression of values of x that are sampled by the search algorithm.  If you sample values x1, x2, x3, etc., in that order, then plot marks at points (x1,y1), (x2,y2), (x3,y3), etc., where yi = i / numpoints.  The first points sampled will appear low in the graph and the last points will appear near the top of the graph.  This will show you the progression of the search algorithm by showing where the focus of the search shifts with experience.  For the genetic algorithm, for example, you should see more and more points clustering around the highest peak as the marks are plotted higher on the graph.

Results to Collect

 Once you are happy with the algorithms' parameter values, run each algorithm repeatedly, for 10 to 30 times.  During each search, keep track of the best fitness found so far.  Plot the best value so far, averaged over all repetitions, versus the number of values evaluated to show how quickly, on average, each algorithm finds better values.  Make a plot of these averaged curves from the three algorithms, superimposed on one graph.  Describe your results and explain why your results are the way they are.  Add any additional graphs that demonstrate your findings.

Hand In

Hand in a written report, formatted as if you are submitting this to a conference.  Check the comments about Assignment 1 on the CS540 web page.  Double-space your report.  The report should be at least five pages long, not counting the code.  It should include
  1. descriptions of the algorithms you implemented,
  2. comments about how you implemented them,
  3. the function you are optimizing,
  4. graphs of your results and explanations of the graphs,
    1. include at least one graph for each algorithm showing the points evaluated superimposed on the function being optimized, and
    2. a graph showing the best so far values of all three algorithms
  5. your code.

Code

You may use some of this code as a starting place.  

Copyright © 1998 Chuck Anderson
anderson@cs.colostate.edu