Lesson 2 - Tutorial main page - Algorithm-Based - Component-Based - Programming hints -EO documentation

Tutorial: Lesson 1

This lesson will let you Later you will be asked to


I want to run an Evolutionary Algorithm now

You can choose to run a standard bitstring Genetic Algorithm (as defined in Goldberg's book) or a standard real-valued genetic algorithm, as proposed in Micahlewicz's book.

If you have not already done what was recommended in the Tutorial main page , do it NOW. Then go to the Lesson1 sub-dir of the tutorial dir, and simply type at the system prompt

(myname@myhost) EOdir/Tutorial/Lesson1 % FirstRealGA
or
(myname@myhost) EOdir/Tutorial/Lesson1 % FirstBitGA

and something should happen.

What is happening?

At the moment, the FirstBitGA maximizes the number of ones in the bitstring (also calls the OneMaxfunction, whose solution is, as you can guess, 11111111), and the FirstRealGA is maximizing (the default action for EO is to maximize) the inverse of the sum (i.e. minimizing the sum) of the square of its variables (also called the sphere function, whose solution is ... all zeroes).

And what you see on the screen when running one of these two programs is, in each case, the initial and final population of an Evolutionary run, one individual per line, its fitness first, then the number of items (bits or real numbers) of the genotype, and the genotype itself. The final population hopefully contains the solution in the discrete case, and is close to it in the continuous case.


Browsing the code:

Now you need to take a look at the program codes, either by browsing alone through the  sources for FirstBitGA and FirstRealGA, or by following the guided tour below. You might prefer to go directly to the exercises.


Guided tour:


Exercise 1: maximize your own function

This is very easy - if your search space is that of bitstring or of unbounded real numbers.


Exercise 2: check the differences between both programs

Go and take a look at the code for these programs (Bit - Real). Use the symbolic representation of an Evolutionary Algorithm (you should understand that figure now, otherwise go there and come back) to understand how each part of the EA is coded. Try to spot the differences between both codes: there are not so many!
After you've tried that alone, take a look at the solution :-)


Exercise 3: change the selection procedure

This is rather straightforward ... if you know what other types of selection are available!
At the moment, let's only consider only the following simple ones: Note that all these classes of eoObjects are derived from the abstract class eoSelectOne. To find out exactly how each procedure selects the individuals, read the corresponding component-based page.


Lessons learned:
Lesson 2 - Tutorial main page - Algorithm-Based - Component-Based - Programming hints - EO documentation

Marc Schoenauer

Last modified: Fri Nov 3 18:49:12 CET 2000