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.
Exercise
- Evolve values of x and y that maximise
this function over this interval.
- Note all fitnesses (z) are negative!
You are searching for the least negative fitness.
-
Do in your own time.
- Any programming language.
- Demonstrate, using gnuplot or any other plotting program,
your population climbing the mountain,
generation after generation.
- Population size should be 30.
-
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:
- 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.)
-
Pictures of the landscape, with the 30 individuals
climbing on it, generation after generation
until they are reasonably converged on the highest peak.
-
To print from gnuplot,
plot into a postscript file, then print it.
See set terminal postscript
and set output file
(in help set).