You are on page 1of 11

I.

Introduction
First Words
Genetic algorithms (GA) are a part of evolutionary computing, which is a
rapidly growing area of artificial intelligence.
As you can guess, genetic algorithms are inspired by Darwin's theory of
evolution. Simply said, problems are solved by an evolutionary process
resulting in a best (fittest) solution (survivor) - in other words, the solution is
evolved.

History
Evolutionary computing was introduced in the 1960s by I. Rechenberg in his
work "Evolution strategies" (Evolutionsstrategie in original). His idea was
then developed by other researchers. Genetic Algorithms (GAs) were
invented by John Holland and developed by him and his students and
colleagues. This lead to Holland's book "Adaption in Natural and Artificial
Systems" published in 1975.
In 1992 John Koza has used genetic algorithm to evolve programs to perform certain
tasks. He called his method "genetic programming" (GP). LISP programs were used,
because programs in this language can expressed in the form of a "parse tree", which is
the object the GA works on.

2. Genetic Algorithm
Basic Description
Genetic algorithms are inspired by Darwin's theory of evolution. Solution to a
problem solved by genetic algorithms uses an evolutionary process (it is
evolved).
Algorithm begins with a set of solutions (represented by chromosomes)
called population. Solutions from one population are taken and used to form
a new population. This is motivated by a hope, that the new population will
be better than the old one. Solutions which are then selected to form new
solutions (offspring) are selected according to their fitness - the more
suitable they are the more chances they have to reproduce.
This is repeated until some condition (for example number of populations or
improvement of the best solution) is satisfied.

Example
As you already know from the chapter about search space, problem solving
can be often expressed as looking for the extreme of a function. We solve
exactly this problem here - a function is given and GA tries to find the
minimum of the function.
Try to run genetic algorithm in the following applet by pressing the Start
button. The graph represents a search space and vertical lines represent
solutions (points in search space). The red line is the best solution, green
lines are the other ones.
The Start button starts the algorithm, Step button performs one step (i.e.
forming one new generation), Stop button stops the algorithm and Reset
button resets the population.

Outline of the Basic Genetic Algorithm


1. [Start] Generate random population of n chromosomes (suitable
solutions for the problem)
2. [Fitness] Evaluate the fitness f(x) of each chromosome x in the
population
3. [New population] Create a new population by repeating following
steps until the new population is complete
1. [Selection] Select two parent chromosomes from a population
according to their fitness (the better fitness, the bigger chance
to be selected)
2. [Crossover] With a crossover probability cross over the parents
to form new offspring (children). If no crossover was performed,
offspring is the exact copy of parents.
3. [Mutation] With a mutation probability mutate new offspring at
each locus (position in chromosome).
4. [Accepting] Place new offspring in the new population
4. [Replace] Use new generated population for a further run of the
algorithm
5. [Test] If the end condition is satisfied, stop, and return the best
solution in population
6. [Loop] Go to step 2

Some Comments
As you can see, the outline of the Basic GA is very general. There are many
parameters and settings that can be implemented differently in various
problems.
The first question to ask is how to create chromosomes and what type of
encoding to choose. We then address Crossover and Mutation, the two
basic operators of GA. Encoding, crossover and mutation are introduced in
next chapter.

The next question is how to select parents for crossover. This can be done
in many ways, but the main idea is to select the better parents (best
survivors) in the hope that the better parents will produce better offspring.
You may think that generating populations from only from two parents may
cause you to loose the best chromosome from the last population. This is
true, and so elitism is often used. This means, that at least one of a
generation's best solution is copied without changes to a new population,
so the best solution can survive to the succeeding generation.
You might be wandering, why genetic algorithms work. It can be partially
explained by the Schema Theorem (Holland), however, this theorem has
been criticized in recent times

3. Operators of GA
Overview
As you can see from the genetic algorithm outline, the crossover and
mutation are the most important parts of the genetic algorithm. The
performance is influenced mainly by these two operators. Before we can
explain more about crossover and mutation, some information about
chromosomes will be given.

Encoding of a Chromosome
A chromosome should in some way contain information about solution that
it represents. The most used way of encoding is a binary string. A
chromosome then could look like this:
Chromosome 1 1101100100110110
Chromosome 2 1101111000011110

Each chromosome is represented by a binary string. Each bit in the string


can represent some characteristics of the solution. Another possibility is that
the whole string can represent a number - this has been used in the basic
GA applet.
Of course, there are many other ways of encoding. The encoding depends
mainly on the solved problem. For example, one can encode directly integer
or real numbers, sometimes it is useful to encode some permutations and
so on.

Crossover
After we have decided what encoding we will use, we can proceed to
crossover operation. Crossover operates on selected genes from parent
chromosomes and creates new offspring. The simplest way how to do that
is to choose randomly some crossover point and copy everything before this
point from the first parent and then copy everything after the crossover point
from the other parent.
Crossover can be illustrated as follows: ( | is the crossover point):

Chromosome 1

1101100100110110
(D936h)

Chromosome 2

1101111000011110
(DE1Eh)

Chromosome 1 11011 | 00100110110


Chromosome 2 11011 | 11000011110
Offspring 1

11011 | 11000011110

Offspring 2

11011 | 00100110110

There are other ways how to make crossover, for example we can choose
more crossover points. Crossover can be quite complicated and depends

mainly on the encoding of chromosomes. Specific crossover made for a


specific problem can improve performance of the genetic algorithm.

Mutation
After a crossover is performed, mutation takes place. Mutation is intended to
prevent falling of all solutions in the population into a local optimum of the
solved problem. Mutation operation randomly changes the offspring resulted
from crossover. In case of binary encoding we can switch a few randomly
chosen bits from 1 to 0 or from 0 to 1. Mutation can be then illustrated as
follows:
Original offspring 1 1101111000011110
Original offspring 2 1101100100110110
Mutated offspring 1 1100111000011110
Mutated offspring 2 1101101100110100
The technique of mutation (as well as crossover) depends mainly on the
encoding of chromosomes. For example when we are encoding
permutations, mutation could be performed as an exchange of two genes.

3-1. Selection
Introduction
As you already know from the GA outline, chromosomes are selected from
the population to be parents for crossover. The problem is how to select
these chromosomes. According to Darwin's theory of evolution the best
ones survive to create new offspring. There are many methods in selecting
the best chromosomes. Examples are roulette wheel selection, Boltzman
selection, tournament selection, rank selection, steady state selection and
some others.
Roulette wheel selection will be described in this chapter.

Roulette Wheel Selection


Parents are selected according to their fitness. The better the chromosomes
are, the more chances to be selected they have. Imagine a roulette wheel
where all the chromosomes in the population are placed. The size of the
section in the roulette wheel is proportional to the value of the fitness
function of every chromosome - the bigger the value is, the larger the
section is. See the following picture for an example.

A marble is thrown in the roulette wheel and the chromosome where it stops
is selected. Clearly, the chromosomes with bigger fitness value will be
selected more times.
This process can be described by the following algorithm.
1. [Sum] Calculate the sum of all chromosome fitnesses in population sum S.
2. [Select] Generate random number from the interval (0,S) - r.
3. [Loop] Go through the population and sum the fitnesses from 0 sum s. When the sum s is greater then r, stop and return the
chromosome where you are.
Of course, the step 1 is performed only once for each population.

3-2. Crossover and Mutation


Introduction

Crossover and mutation are two basic operators of GA. Performance of GA


depends on them very much. The type and implementation of operators
depends on the encoding and also on the problem.
There are many ways how to perform crossover and mutation. In this
chapter we briefly describe some examples and suggestions how to perform
them several encoding.

Binary Encoding
Crossover
Single point crossover - one crossover point is selected, binary string from
the beginning of the chromosome to the crossover point is copied from the
first parent, the rest is copied from the other parent

11001011+11011111 = 11001111

Two point crossover - two crossover points are selected, binary string from
the beginning of the chromosome to the first crossover point is copied from
the first parent, the part from the first to the second crossover point is
copied from the other parent and the rest is copied from the first parent
again

11001011 + 11011111 = 11011111


Uniform crossover - bits are randomly copied from the first or from the
second parent

11001011 + 11011101 = 11011111


Arithmetic crossover - some arithmetic operation is performed to make a
new offspring

11001011 + 11011111 = 11001001 (AND)


Mutation
Bit inversion - selected bits are inverted

11001001 => 10001001

A Genetic Algorithm Example


As a simple example, imagine a population of four strings, each with five
bits. Also imagine an objective function f(x)=2x. The goal is to optimize (in
this case maximize) the objective function over the domain

. Now

imagine a population of the four strings in Table 1, generated at random


before GA execution. The corresponding fitness values and percentages
come from the objective function f(x).
Table 1:

The values in the ``

Four strings and their fitness values.

'' column provide the probability of each string's

selection. So initially 11000 has a 38.1% chance of selection, 00101 has an


7.9% chance, and so on. The results of the selections are given in the
``Actual Count'' column of Table 1. As expected, these values are similar to
those in the ``Expected Count'' column.
After selecting the strings, the GA randomly pairs the newly selected
members and looks at each pair individually. For each pair (e.g. A = 11000
and B = 10110), the GA decides whether or not to perform crossover. If it
does not, then both strings in the pair are placed into the population with
possible mutations (described below). If it does, then a random crossover
point is selected and crossover proceeds as follows:

A=11|000B=10|110
are crossed and become A' = 1 1 1 1 0

B' = 1 0 0 0 0.
Then the children A' and B' are placed in the population with possible
mutations. The GA invokes the mutation operator on the new bit strings very
rarely (usually on the order of

probability), generating a random

number for each bit and flipping that particular bit only if the random number
is less than or equal to the mutation probability.
After the current generation's selections, crossovers, and mutations are
complete, the new strings are placed in a new population representing the
next generation, as shown in Table 2. In this example generation, average
fitness increased by approximately 30% and maximum fitness increased by
25%. This simple process would continue for several generations until a
stopping criterion is met.
Table 2:

The population after selection and crossover.

You might also like