Escolar Documentos
Profissional Documentos
Cultura Documentos
Abstract
This essay discusses some issues which arise in solving the Travelling Salesman Problem (TSP) using a genetic algorithm (GA). Two approaches are described. I've personally implemented both !ailing with the !irst reali"ing my mista#es and succeeding with the second approach. A comparison o! the two approaches is intended to introduce the reader to the importance o! ta#ing the dynamics o! a given problem into account when designing a genetic algorithm to solve it. It is assumed that the reader has a basic #nowledge o! genetic algorithm concepts. The !ollowing is suggested as an e$cellent introduction and re!erence !or this sub%ect& Genetic Algorithms in Search 'ptimi"ation and (achine )earning. *avid +. Goldberg IS,- ./0.1/12343/2
Introduction
Background to Genetic Algorithms
+volution in the natural world displays a remar#able problem solving ability as demonstrated by the !act that a myriad species have evolved on +arth demonstrating a diverse range o! survival strategies. It would there!ore not be unreasonable to deduce that a problem solving strategy inspired by the mechanics o! natural selection and genetics may prove highly e!!ective in solving certain classes o! problems Genetic algorithms emulate the mechanics o! natural selection by a process o! randomi"ed data e$change. In this way they are able to solve o! range o! di!!icult problems which cannot be tac#led by other approaches. The !act that they are able to search in a randomi"ed yet directed manner allows them to reproduce some o! the innovative capabilities o! natural systems ,ecause genetic algorithms were inspired by the behavior o! natural systems the terminology used to describe them is a mi$ !rom both biological and computer !ields. A genetic algorithm manipulates strings o! in!ormation usually called chromosomes. These encode potential solutions to a given problem. 5hromosomes are evaluated and assigned a score (!itness value) in terms o! how well they solve the given problem according to criteria de!ined by the programmer. These !itness values are used as a probability o! survival during a round o! reproduction. -ew chromosomes are produced by combining two (or more) parent chromosomes. This process is designed to lead to a succession o! !itter o!!spring each encoding better solutions until an acceptably good solution is !ound.
Evaluation Function
@e write an evaluation !unction !or our problem which ta#es a trial solution and returns a !itness value. The shorter the route the higher the !itness value. 6owever we only want solutions which describe a route visiting all cities. @e reali"e this and write the !itness !unction to 'punish' with low !itness values those chromosomes which contain multiple visits to any city. I! we didn't do this the GA will !ind that the shortest route is the one which ta#es you nowhere (i.e. visits the same city 1.. times). In addition we punish chromosomes which e$press city numbers which don't e$ist//any allele value above == in our case.
Post"#ortem
Although the GA may yield a viable solution i.e. one in which all cities are visited %ust once no e!!ective attempt will be made to progress toward decreasingly shorter routes. The reason is ?uite simple. The crossover reproduction scheme we have used #ills the viability o! the o!!spring. 5onsider the 1. city chromosome e$amples A and ,. ,oth these are viable because city visits described in each are uni?ue. -ow loo# at the o!!spring A' and ,' and note how some cities are visited twice. The net result o! this approach is a random wal# through a massive problem space (appro$. 4.3e0>.) with little chance o! !inding many viable solutions never mind good ones.
>
A Success$ul Approach
In the previous section we identi!ied that the order in which data is encoded in the chromosome is important !or TSP and that a simple crossover reproduction mechanism is not suitable in these circumstances.
Inversion
(utation is o!ten used in GAs as a way o! adding random variation to the evolving population preventing a total loss o! diversity. In our case it's not so use!ul however as a mutation has a high probability o! resulting in a non/viable city order. @e may still wish to apply a small mutation rate provided o! course we account !or non/viable city orders in the evaluation !unction. 6owever an alternative to mutation is perhaps more appropriate. Inversion re!ers to the randomised e$change o! alleles in chromosomes. This can be made to occur with a given (usually small) probability in much the same way as mutation. As an e$ample let's consider inversion on the ,' chromosome&
2 ,' A 34190=2>8. Allele inde$ 0 is selected !or inversion. The value is simply e$changed with the allele at an additional randomly selected inde$ let's say inde$ 3 as !ollows& ,i A 34>90=218. 6ence allele positions 0 and 3 have been e$changed.
!esults
I've previously tried this approach to the Travelling Salesman Problem and ran it success!ully with city counts o! between 1.. and 1.... In the way o! illustration two outputs ta#en !rom a 1.. city problem are shown below (1... cities would be too cluttered to show). <igure 1a shows an initial randomly ordered route between 1.. randomly positioned points. <igure 1b a!ter around 1. ... generations.
Figure 1a : Initial Random Route Figure 1b : After 1 !! Generations Andy Thomas 0..1 andytEalpha/india2.com Submitted& .4F.3F0..1 Article content copyright G Andy Thomas 0..1.