Dr. Mark Humphrys

School of Computing. Dublin City University.

Home      Blog      Teaching      Research      Contact

My big idea: Ancient Brain


CA114      CA170

CA668      CA669      Projects

GA Exercise - Adaptive Landscape

The Adaptive Landscape shown earlier is actually the function:
z = -( abs(sin(x))+abs(sin(2*x))+abs(sin(3*x))+abs(sin(5*x)) ) 
    -( abs(sin(y))+abs(sin(2*y))+abs(sin(3*y))+abs(sin(5*y)) )
over the range x = 2 to 4, y = 0.5 to 2.

It was drawn by the following commands in gnuplot on UNIX:

# gnuplot commands to plot a nice mountainous 3-d surface
set nocontour
set surface
set hidden3d

# fine granularity:
set isosamples 50

splot [2:4] [0.5:2] -( abs(sin(x))+abs(sin(2*x))+abs(sin(3*x))+abs(sin(5*x)) ) -( abs(sin(y))+abs(sin(2*y))+abs(sin(3*y))+abs(sin(5*y)) )

gnuplot is easy to use. Type "gnuplot", then it gives you a command line.
Type   plot sin(x)   just as a demo.
Type   help   for help topics.


  1. Evolve values of x and y that maximise this function over this interval.
  2. Note all fitnesses (z) are negative! You are searching for the least negative fitness.
  3. Do in your own time.
  4. Any programming language.

  5. Demonstrate, using gnuplot or any other plotting program, your population climbing the mountain, generation after generation.
  6. Population size should be 30.
  7. In gnuplot, see   plot file with points   (in   help plot) for how to plot a lot of x,y,z points stored in a file (to plot the individuals on the mountain).

To be handed up:

  1. Tidy, bound printout of full working code, commented, in any language.
    (Hint: Colour printout in landscape mode is normally the best way to print out code.)
  2. Pictures of the landscape, with the 30 individuals climbing on it, generation after generation until they are reasonably converged on the highest peak.
  3. To print from gnuplot, plot into a postscript file, then print it. See   set terminal postscript   and   set output file   (in   help set).

ancientbrain.com      w2mind.org      humphrysfamilytree.com

On the Internet since 1987.

Wikipedia: Sometimes I link to Wikipedia. I have written something In defence of Wikipedia. It is often a useful starting point but you cannot trust it. Linking to it is like linking to a Google search. A starting point, not a destination. I automatically highlight in red all links to Wikipedia and Google search and other possibly-unreliable user-generated content.