An Introduction to Genetic Algorithms - Boente
An Introduction to Genetic Algorithms - Boente
An Introduction to Genetic Algorithms - Boente
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
2.<br />
3.<br />
4.<br />
Chapter 2: <strong>Genetic</strong> <strong>Algorithms</strong> in Problem Solving<br />
make an intelligent guess as <strong>to</strong> a reasonable set of functions and terminals for the problem at hand.<br />
For the orbital−period problem, the function set might be {+, , *, /, ,} and the terminal set might<br />
simply consist of {A}, assuming the user knows that the expression will be an arithmetic function of<br />
A.<br />
Generate an initial population of random trees (programs) using the set of possible functions and<br />
terminals. These random trees must be syntactically correct programs—the number of branches<br />
extending from each function node must equal the number of arguments taken by that function. Three<br />
programs from a possible randomly generated initial population are displayed in figure 2.2. Notice<br />
that the randomly generated programs can be of different sizes (i.e., can have different numbers of<br />
nodes and levels in the trees). In principle a randomly generated tree can be any size, but in practice<br />
Koza restricts the maximum size of the initially generated trees.<br />
Figure 2.2: Three programs from a possible randomly generated initial population for the<br />
orbital−period task. The expression represented by each tree is printed beneath the tree. Also printed<br />
is the fitness f (number of outputs within 20% of correct output) of each tree on the given set of<br />
fitness cases. A is given in units of Earth's semimajor axis of orbit; P is given in units of Earth years.<br />
(Planetary data from Urey 1952.)<br />
Calculate the fitness of each program in the population by running it on a set of "fitness cases" (a set<br />
of inputs for which the correct output is known). For the orbital−period example, the fitness cases<br />
might be a set of empirical measurements of P and A. The fitness of a program is a function of the<br />
number of fitness cases on which it performs correctly. Some fitness functions might give partial<br />
credit <strong>to</strong> a program for getting close <strong>to</strong> the correct output. For example, in the orbital−period task, we<br />
could define the fitness of a program <strong>to</strong> be the number of outputs that are within 20% of the correct<br />
value. Figure 2.2 displays the fitnesses of the three sample programs according <strong>to</strong> this fitness function<br />
on the given set of fitness cases. The randomly generated programs in the initial population are not<br />
likely <strong>to</strong> do very well; however, with a large enough population some of them will do better than<br />
others by chance. This initial fitness differential provides a basis for "natural selection."<br />
29