Genetic Algorithms
Genetic Algorithms
com
Introduction
What Is a Genetic Algorithm
Genetic algorithms are stochastic search algorithms, which act on a
population of possible solutions. They are loosely based on the
mechanics of population genetics and selection. The potential solutions
are encoded as `genes' | strings of characters from some alphabet.
New solutions can be produced by `mutating' members of the current
population, and by `mating' two solutions together to form a new
solution. The better solutions are selected to breed and mutate and the
worse ones are discarded. They are probabilistic search methods; this
means that the states, which they explore, are not determined solely
by the properties of the problems. random process helps to guide the
search. Genetic algorithms are used in arti!cial intelligence li"e other
search algorithms are used in arti!cial intelligence to search a space of
potential solutions to one which sol#es the problem.
Genetic Algorithms in Machine Learning
$n machine learning we are trying to create solutions to some problem
by using data or examples. There are essentially two ways to do this.
%ither the solution is constructed from the data, or some search
method is used to search o#er a class of candidate solutions to !nd an
e&ecti#e one.
Genetic algorithms are important in machine learning for three
reasons. 'irst, they act on discrete spaces, where gradient(based
methods cannot be used. )econd, they are essentially reinforcement
learning algorithms. The performance of a learning system is
determined by a single number, the !tness. 'inally, genetic algorithms
in#ol#e a population and sometimes what one desires is not a single
entity but a group.
History of Evolutionary Computing
Genetic algorithms are one of a class of approaches often called
evolutionary computation methods used in adapti#e aspects of
computation search, optimi*ation, machine learning, parameter
ad+ustment, etc. These approaches are distinguished by the fact that
www.SeminarsTopics.com
they act on a population of potential solutions. ,hereby most search
algorithms ta"e a single candidate solution and ma"e small changes to
that, attempting to impro#e it, e#olutionary algorithms adapt an entire
population of candidate solutions to the problem. These algorithms are
based on biological populations and include selection operators which
increase the number of better solutions in the population and decrease
the number of the
poorer ones; and other operators which generate new solutions.
Genetic algorithms were !rst proposed by -ohn .olland in his boo"
daptation in Natural and rti!cial )ystems/.
The Basics of Genetic Algorithms
Elements of a imple Genetic Algorithm
Representation.
$n order to use a genetic algorithm to search for solutions to a
problem, potential solutions to the problem must be encoded as strings
of characters drawn from some alphabet, A 0 a1a2:::aL. 3ften the
characters are binary, but it is also possible to draw them from larger
alphabets, and real numbers are sometimes used.
The strings, A are called chromosomes. The components of the string,
a1; a2 are called genes. The #alues which each gene can ta"e are
called the alleles. $n the most common case of binary strings, the two
possible alleles are 4 and 1.
Fitness Function.
$t is the tas" of the genetic algorithm to !nd #ery good strings. The
goodness of a string is represented in the G by some function of the
strings, which $ will call the objective function, the 5uantity to be
optimi*ed. nother function which is needed is called the !tness
function. This is a monotonic function of the ob+ecti#e function, and is
what determines how the strings will be multiplied or discarded during
the algorithm. $t is usual to de!ne the !tness function so that the
www.SeminarsTopics.com
algorithm increases the !tness of the strings, so better solutions
correspond to more !t strings.
Population Dynamics
genetic algorithm wor"s on a population of strings. $t starts with a
random population and e#ol#es the population to one containing good
strings. The population at the next time step in such a way that the
o#erall !tness of the population is increased. There are numerous ways
of actually implementing a genetic algorithm.
Three operations that produce a new population from the existing
population are6 selection, crosso#er, and mutation.
7
election!
This operator selects strings from the current population such that
better strings are more li"ely to be chosen. )election does not
introduce any new strings; if applied repeatedly it simply re(proportions
the strings in the population, increasing the number of 8better ones
and decreasing the number of less !t ones.
"ecom#ination$Crossover!
This operation produces o& springs from a pair of parents by
combining parts of each parent. %ach o&spring contains parts of the
strings of each parent.
Mutation!
This operation simply changes characters in the o&spring string at
random. %ach character is changed with a small probability.
%itness &roportional election'
The simplest implementation of selection is to select in proportion to
the !tness. That is, the probability of selecting a string is
www.SeminarsTopics.com
P
0 F
,here F
; 0 exp :E
;
,here is the selection strength parameter .
'itness proportional selection is also called <roulette wheel selection/.
!utation
The mutation operation changes the #alue of each gene with a
mutation probability p
m
. $.e. each character is changed to some other
character with probability p
m
, and left unchanged with probability 1"p
m
.
The mutation probability is ta"en to be small, e.g. 1#L, for strings of
length L. This probability is small
$rossover
=rosso#er wor"s on pairs of strings. 'or each pair crosso#er occurs
with probability >c and with probability 1"Pc the o&spring are identical
to the parents.
commonly used form is called single(point crosso#er. $n this
operation, a crossing site is chosen at random somewhere along the
length of the strings. Two new strings are generated by swapping all of
the components of the two strings on one side of the crossing site.
'or example, if the two strings are
A
1
0 1111111?1111111
A
2
0 4444444?4444444
nd the crosso#er position is between the @th and Ath position :as
mar"ed;, the new strings would be
A
%
0 4444444/1111111
www.SeminarsTopics.com
A
&
0 1111111/4444444
This operation e&ecti#ely means that each o&spring possesses features
from both parents.
Bi"ewise, multi(point crosso#er uses multiple crosso#er points. $.e.
A
1
0 111?111111?11111
A
2
0 444/444444?44444
would yield
A
%
0 444?111111?44444
A
&
0 111/444444?11111:
E(pected #ehavior
Cutation is clearly local random search; it ta"es a solution and
generates a small, unguided change. =rosso#er is more complicated. $t
ta"es a pair of parents and produces two o&spring between the
parents. The two o&spring can be near, or far from the two parents, in
this sense it is said to be a global rather than local search algorithm.
The mean !tness in the population increase until some form of
e5uilibrium is reached. %5uilibrium is where there is a balance between
the impro#ing e&ect of selection and the deleterious e&ects of
mutation and crosso#er. 'igure shows histograms of the !tness
distribution in a population during a G e#olution.
3ne thing that often happens is that a state is reached where there is
#ery little di#ersity in the population. ,hen this happens, impro#ement
is #ery slow because crosso#er has little e&ect on #ery similar strings.
This is called <premature con#ergence/ and is one of the most
important causes of failure of genetic algorithms. population of #ery
www.SeminarsTopics.com
similar strings in the #icinity of a local minimum is #ery stable.
=rosso#er has #ery little e&ect on populations of #ery similar strings
and the time to lea#e a local minimum #ia selection and mutation
alone can be #ery long.
.
'igures show examples of the increase in mean !tness in a population
for a short and longer run.
E(tensions to the Basic Genetic Algorithm
There are many di&erent ways of implementing a genetic algorithm,
and researchers rarely use the simple.
Alternative election chemes
Cost alternati#e selection schemes are designed to a#oid premature
con#ergence.
Elitism! The best members of the population are put into the next
generation at each time step. The best indi#iduals cannot be lost due
to random sampling, and selection strength used to pic" the other
members of the population can be wea"er to maintain di#ersity.
Tournament election! Two members of the population are chosen at
random. The least !t is remo#ed and replaced by a copy of the most !t.
www.SeminarsTopics.com
teady)state selection! Dather than changing all members of the
population at each stage, only a few members of the population are
changed at each time step.
%itness haring! $n order to maintain di#ersity in the population, the
!tness of an indi#idual is shared among all other indi#iduals, which
ha#e similar genotypes.
*iching and Island Models! This is similar to the pre#ious; it is a
method of maintaining di#ersity in a population and pre#enting
premature con#ergence.
Alternative Crossover +perators'
=utting the solutions up into chun"s and recombining them may not
be the best way of creating o&spring. The method of recombination
should reEect the structure of the problem.
,sing the Entire &opulation'
$n most uses of genetic algorithms, the <answer/ is the best member of
the population; the other members of the population are used to help
in the search but are discarded at the end. .owe#er, there are
situations where the entire population is used rather as a solution.
E(amples of Genetic Algorithms in Machine Learning
Learning "ule ets
This was described by Fe-ong and is called G9$B. The genetic
algorithm learns a 9oolean concept by searching for a dis+uncti#e set of
rules. To represent a rule, a string contains a bit for each #alue that
each #ariable can ta"e, and a bit for the concept #alue. 'or example, if
v
1
can ta"e the #alues '
11
; '
12
; '
1G
, and v
2
ta"es the #alues '
21
; '
22
, H
2G
and these are the only two #ariables, then the string
114 41 1
www.SeminarsTopics.com
is used to denote the rule
$' :v
1
0 '
12
; ' :v
1
0 '
1G
; :v
2
0 '
21
; T.%N c 0 ()
where c is the concept.
set of rules is a long string of rules concatenated together. $n order to
allow for a #ariable number of rules, a modi!ed form of crosso#er is
used. Two crosso#er points are selected at random in the 8!rst parent.
The crosso#er points in the second parent can be in any rule, but must
be in the analogous place in the rule as in the rule of the !rst parent.
'or example,
#81 #82 c #81 #82 c #81 #82 c
44|1 11 1 111 4|1 4 114 14 1
then possible crosso#er points in the second parent must be between
the !rst and second attribute bit in a sub string associated with v
1
in
any rule, and the !rst and second attribute bit in a sub string
associated with v
2
in any rule. 'or example,
#81 #82 c #81 #82 c
14|1 1|1 1 441 41 4
would yield as o&spring,
#81 #82 c #81 #82 c
441 11 4 114 14 1
and
#81 #82 c #81 #82 c #81 #82 c
141 11 1 111 41 1 441 41 4
This allows #arying lengths of rule sets to be explored, while preser#ing
the structure of the rules.
$t is worth noting that bits with more 1's are more general rules, and
bits with more 4's are more specifc. Thus, a mutation operator, which
is, biased towards adding more 1's than 4's will generate more general
rule sets.
www.SeminarsTopics.com
Evolving Computer &rograms
Genetic &rogramming' Genetic programming is a form of
e#olutionary computation in which computer programs are e#ol#ed
using a genetic algorithm. -ohn Io*a is credited with its in#ention. The
representation of the program is in terms of trees rather than strings.
%ach tree represents the parse tree of a B$)> expression. The lea#es :or
end nodes; of the tree represents terminals | ob+ects which ta"e no
input. The other nodes represent functions, which ta"e a number of
arguments, where each argument is either a terminal or another
function.
s the representation is in terms of trees, a tree(based crosso#er and
mutation operator is re5uired. The crosso#er is done by replacing one
randomly chosen sub tree from one parent by a sub tree from the other
parent. Cutation occurs by ta"ing a randomly chosen sub tree and
replacing it by a randomly generated sub tree.
n example of crosso#er on trees. The two parents are on top of the
!gure; the dar" lines show the crosso#er points. The two o& springs are
below.
www.SeminarsTopics.com
E*ample " A simulate+ ant
simulated ant can detect food directly in front of it and can mo#e
forward, or turn left or right on a s5uare grid. There is a trail of food
along the grid, with some gaps in the trail. The ant has to collect as
much food as possible. ,here the trail of food is continuous, the ant
must learn to follow the trail. )ince there are gaps in the trail, the ant
must learn some exploration beha#ior, so as to na#igate past the gaps
and !nd the trail again. The complexity of the exploration re5uired
depends upon the si*e of the gaps.
The !tness of a program is the number of pieces of food found by the
ant
:$'('33F(.%F :C3H%;
:>D3GNG :B%'T;
:>D3GN2 :$'('33F(.%F :C3H%;
:D$G.T;;
:>D3GN2 :D$G.T;
:>D3GN2 :B%'T;
:D$G.T;;;;
:>D3GN2 :$'('33F(.%F :C3H%;
:B%'T;;
:C3H%;;;;
$f food is detected ahead the ant mo#es to it. 3therwise it turns left and
loo"s for food. $f no food is there, it turns bac" to the right and the right
again, and so loo"s to the right of its original position. $f no food is
there, it +ust mo#es in the direction it was originally heading. There is
nothing about this rule induction system, which pre#ents redundant
rules li"e this.
Genetic programming has been used in a wide range of applications,
including the design of circuits J1K7, and the prediction of complex time
series.
Genetic Algorithms and *eural *et-or.s
www.SeminarsTopics.com
rti!cial neural networ"s are #ery successful methods in machine
learning. They produce a mapping between an input space and an
output space. This mapping is not represented in terms of rules, but in
terms of non(linear functions of real(#alued parameters called
<weights/. Two learning tas"s are6 !nd the structure of the neural
networ", and !nd the weight #alues of the neural networ" to ma"e it
perform a particular tas". Genetic algorithms to search o#er the
structure space and?or o#er the weight space to train neural networ"s
to perform di&erent tas"s.
Genetic Algorithms to Train %i(ed tructures'
Genetic algorithms are used to search for the weights, which optimi*e
neural networ" performance on an example set for a !xed structure
neural networ". The performance of the networ" is determined by a
single number, the !tness. This approach can focus the search on
those parameters, which contribute to the outputs which are wrong,
and if learning is done after each pattern, the changes can be made.
Genetic Algorithms to earch for *eural *et-or. tructure'
A well-known problem in using neural networks is that one does not know what
structure to use. A structure which is too complex may easily perform well on the
example set without giving good generalization; a structure which is too simple may be
unable to perform the desired task at all.A more standard approach is to train networks of
different architectures, and use cross-validation to determine the expected generalization
of networks of different structures. Then one of the networks from the class with the best-
expected structure is tested and used. any alternative approaches are also being used
depending upon the complexity of the selection.
Genetic Algorithms and "einforcement Learning
Deinforcement learning deals with those situations when the
information the learner gets about its performance is e#aluati#e, rather
then instructi#e. Deinforcement learning is important in adapti#e
www.SeminarsTopics.com
control problems, such as learning to control a mobile robot, learning to
play games, and modeling learning in biological systems. Genetic
algorithms turn learning problems into reinforcement learning
problems, and is perhaps one of the simplest ways to implement a
reinforcement learning method. Thus, reinforcement learning is one of
the most important applications of genetic algorithms in machine
learning
Interaction of Evolution and Learning
Com#ining Genetic Algorithms -ith Local earch Algorithms
Bocal search algorithm combined with an e#olutionary algorithm to
impro#e search. The idea is that the e#olutionary steps mo#e members
of the population near locally optimal solutions, and the local search
algorithm ta"es it the rest of the way. lternati#ely, one could use the
local algorithm as the main search element of the population, adding
occasional crosso#ers as a global element to mo#e indi#iduals away
from locally optimal states.
!tness function :solid line; and the e&ecti#e !tness :dashed line;
when a genetic algorithm is combined with local search.
The Bald-in E/ect
3ne e&ect of the interaction of learning with e#olution was proposed by
-. C. !aldwin. "e argued that ac#uired characteristics could be indirectly inherited. This
occurs in two steps. $irst, plasticity can increase fitness of partial mutation which is
otherwise useless. %ikewise, an organism can be born with the ability to hunt, or it can be
www.SeminarsTopics.com
born with the ability to learn to hunt. The tanning reaction and learning are both examples
of plasticity, which impart increased fitness. The second step of the !aldwin effect is
genetic assimilation. Thus through this two step process, ac#uired characteristics are
inherited.
Conclusions
Genetic algorithms are general purpose search algorithms which act on
a population of candidate solutions. They can be applied to search on
discrete spaces, so can be used to search rule sets, representations of
computer programs or computer structures, neural networ"
architectures, and so forth. ,hen applied to learning, genetic
algorithms turn learning tas"s into reinforcement learning problems; it
is in this domain where they are often used. Genetic algorithms
combine 5uite successfully with local search algorithms or local
machine learning methods.
www.SeminarsTopics.com
"eferences