Você está na página 1de 11

Implementation paper on Optimal Route Finder

Using Genetic Algorithm


Rahul Verma1, Nimesh Khawas2, Anup Rai3, Arvind Lal4, Preeti Gupta5

12345Center for Computers and Communication Technology


Chisopani, South Sikkim
#
First-Fifth Department,
Address Including Country Name
rahulvermahllo12345@gmail.com

nimeshkhawas1994@gmail.com

anupfullbuster123@gmail.com 

arvindlal21@gmail.com

technoinceptra07@gmail.com 
Abstract— In a large scale network, shortest distance query is a stored in 2 dimensional matrix, even the calculated data is
primary operation. Travelling salesman problem is a stored in matrix format.
major problem faced by salesman. Through this
paper we describe how the travelling salesman Following are the important factors of this project:
problem is solved by the method of genetic
algorithms. Genetic algorithms are the evolutionary
1. NP-hard Problem
techniques for finding the fittest gene amongst all the 2. Matrix
combination of chromosomes using crossover and mutations 3. MATLAB
4. Roulette Wheel
over the chromosomes. The purpose is to find the
5. Chromosomes
most approximate solution that gives us the
least distance, which is the shortest route for NP-hard Problem: It stands for nondeterministic
traversing the cities. polynomial time. A decision problem H comes under
This problem a salesman has to traverse n number of cities in
NP-hard problems which is not possible to solve in
such way that it gives a ‘uni’ directed graph and each city is
polynomial-time which means exact solution cannot
visited only once. We accomplish this by carrying out
the algorithm through generating a fitness be found by a computer. Only an optimal solution
formula and can be obtained.
with the help of genetic operators like selection,
crossover and mutation.
Matrix: Matrix are mathematical method for
keeping a similar kind of data together. Matrices are

Keywords— genetic algorithm, genetic operators, of various type, but the matrix used here is

travelling salesman problem. 2Dimensional matrix.

I. INTRODUCTION MATLAB: The name MATLAB stands for Matrix


Genetic Algorithm (GA) is an algorithm which is basically Laboratory. MATLAB was written originally to
used in the optimization tasks. This algorithm follows the provide easy access to matrix software which was
theory, given by Charles Darwin which is “Survival of the developed by the LINPACK (linear system package)
fittest”. GA consists of many functions which are similar to and EISPACK (Eigen system package) projects.
the processes which occurs in genetics. MATLAB is a high-performance language for
Travelling Salesman Problem (TSP) is one of the most technical computing. It integrates computation,
popular optimization problem studied in the world, it is a visualization, and programming environment.
nondeterministic polynomial time (NP) –hard problem which Furthermore MATLAB is a modern programming
cannot be exactly solved in polynomial time. In TSP a language environment; it has sophisticated data
salesman has to choose a shortest path for traversing n structures, contains built-in editing and debugging
number of cities without repeating any path and without tools, and supports object-oriented programming.
visiting any city more than once. TSP can be solved easily These factors make MATLAB an excellent tool for
when the number of cities are less in number, whereas the teaching and research.
complexity increases as increase in number of cities. TSP can
be used in many fields like circuit designing, military, traffic Roulette Wheel: Fitness proportionate selection,
etc. also known as roulette wheel selection, is a genetic
This project is to code the GA in order to satisfy the need operator used in genetic algorithms for selecting
of Travelling Salesman Problem and to find an optimal path potentially useful solutions for recombination. In
for the salesman or the user that he/she can used to traverse. fitness proportionate selection, as in all selection
GA is used to perform all the computations for finding the methods, the fitness function assigns a fitness to
optimal path. We have used MATLAB as platform as it only possible solutions or chromosomes.
work with matrices and mathematical problem. All the data of
nodes, displacement, gene combination, node coordinates are
Chromosomes: In genetic algorithms, a
chromosome (also sometimes called a genotype) is a No
set of parameters which define a proposed solution
to the problem that the genetic algorithm is trying to Display the Output
solve. The set of all solutions is known as the
population. The chromosome is often represented as Figure 1: Flowchart of Applied GA.
a binary string, although a wide variety of other data
III. IMPLEMENTATION OF TSP USING GA
structures are also used.

II. GENETIC ALGORITHM 4.1 Encoding: Firstly for implementing TSP using GA the
Genetic Algorithm was proposed by John Holland in chromosomes length is considered as the total number of
1970. This algorithm mainly came in use at middle of 1980’s. nodes, which are cities. Five cities or nodes are considered
This is the algorithm which is based on the principle of and all the possible chromosomes are:
Charles Darwin which stated that “select the best and discard
the rest”.
This algorithm generates n number of offspring depending Chromosome 1: 2 4 5 3 1
upon the parents with the help of mutation and crossover and
the selects the best chromosome which is most fit amongst Chromosome 2: 3 1 2 5 4
all.
For Example: If there are certain number of animals of same Chromosome 3: 3 5 2 1 4
species and in which some of them are more fit physically
and mentally and due some factor the resources to them are Chromosome 4: 2 5 1 4 3
limited, then the chances of the survival for the less fit
animals becomes harder and leads to extinction. The same Chromosome 5: 2 4 5 3 1
above concept is used in the genetic algorithm.
Generate Initials Population of
Chromosomes Table 1: Distance Matrix of 5 cities

City 1 2 3 4 5
1 0 4.4531 4.1502 6.2789 2.4564
Apply Roulette Wheel
2 4.4531 0 6.9994 2.8626 6.8143
Selection to the population
3 4.1502 6.9994 0 9.5985 4.8619
4 6.2789 2.8626 9.5985 0 8.2254
5 2.4564 6.8143 4.8619 8.2254 0

Apply Crossover to the


4.3 Fitness Function: The main motive of fitness function is
selected population
to choose if a chromosome is good. The criteria in the
travelling salesman problem for good chromosome are its
length. The fitness function will be the total cost of the tour
Apply Mutation to the represented by each chromosome. This can be calculated as
selected population the sum of the distances traversed in each travel segment.
Lesser the sum, fitter is the solution.
Yes

Number of Iterations
4.3 Selection: It is used to select the chromosome whose
fitness value is small. We have used the tournament selection
by using Sorting method. Selection is used to pick the
chromosome whose fitness value is less. Here we have used
the tournament selection. As the name reflects tournaments
are played between two solutions and the superior solution is
selected and placed in the mating pool.

2 4 5 3 1

4.4 Mutation: A few number of cities or genes


from a chromosomes are selected and then are
exchanged with each he exchange process is done
only when the exchange process is done only when
the exchange of this genes or cities increases the
fitness value of chromosomes. This process is done
only to the most fit chromosome in order to get the
most fit path or chromosomes.

2 4 5 3 1 Output:

1 4 5 3 2

Figure 2. New Mutated Chromosome

4.5 Crossover: One point - part of the first parent is copied


and the rest is taken in the same order as in the second parent.
Two point - two parts of the first parent are copied and the
rest between is taken in the same order as in the second
parent.
IV. LITERATURE SURVEY

[1] Gilbert Laporte, “The Traveling Salesman Problem:


An overview of exact and approximate algorithms”,
European Journal of Operational Research 59 (1992) 231-
247 North-Holland, Centre de recherche sur les transports,
Universit~ de Montr&l, C.P. 6128, Station A, Montreal,
Canada H3C M7 Received May 1991; received July 1991.

This paper surveys on some of the main known


algorithms for the traveling salesman problem. It presents
an integrated overview of some of the best exact and
approximate algorithms which includes Integrated Linear
Programming and Branch and Bound algorithm. The
paper concludes that problems involving a few hundred
vertices can be solved routinely to an optimal solution.
The instances involving more than 2000 vertices have also
been solved exactly by means of these algorithms.

[2] X.H. Shi a, Y.C. Liang a,b,∗


, H.P. Lee b,c
, C. Lu b, Q.X.
Wang a, “Particle swarm optimization-based algorithm for
TSP and generalized TSP”, a College of Computer Science
and Technology, Jilin University, Key Laboratory of
Symbol Computation and Knowledge Engineering of the
b
Ministry of Education, Changchun 130012, China,
Institute of High Performance Computing, Singapore This paper states that Genetic Algorithm gives better
c
117528, Singapore, Department of Mechanical results in terms of the distance travelled whereas the ACO
Engineering, National University of Singapore, 9 gives the better result when the complexity increases or
Engineering Drive 1, Singapore 119260, Singapore, the number of nodes increases.
Received 31 July 2005; received in revised form 10
February 2007.
[5] Naixue Xiong 1,2, Wenliang Wu 1 and Chunxue Wu
This paper surveys on particle swarm optimization (PSO)-
1*, “An Improved Routing Optimization Algorithm Based
based algorithm for the traveling salesman problem. It
on Travelling Salesman Problem for Social Networks”, 1
presents an overview of solving TSP using an uncertain
School of Optical-Electrical and Computer Engineering,
searching strategy in which crossover is eliminated to
University of Shanghai for Science and Technology,
accelerate the convergence speed. The paper concludes
Military Road, No. 516, Shanghai 200093, China;
that the modified PSO algorithm is effective and can solve
xiongnaixue@gmail.com (N.X.); wwl@st.usst.edu.cn
the larger size problems than the existing PSO algorithm.
(W.W.) 2 Department of Mathematics and Computer
[3] Elizabeth F. G. Goldbarg, Marco C. Goldbarg and Science, Northeastern State University Address: 611 N,
Givanaldo R. de Souza, “Particle Swarm Optimization Grand Ave, Tahlequah, OK 74464, USA, Received: 5
Algorithm for the Traveling Salesman Problem”, April 2017; Accepted: 6 June 2017; Published: 8 June
University Campus STeP Ri Slavka Krautzeka 83/A 51000 2017.
Rijeka, Croatia, Published online 01, September, 2008.
This paper focuses on a routing optimization algorithm.
This paper provides an overview for the optimization of This paper provides an improved scheme for considering
Particle Swarm Optimization algorithm by using a new the about searching next better city, even new parameters
velocity operator for discrete PSO by which the positions are introduced to improve the probability of selection. It
of cities or nodes are updated by means of velocity states that Ant colony algorithm is proposed to solve this
operators that direct the search to exact (promising) problem effectively, but random selection strategy of the
regions of the space of solutions. The unary and a binary traditional algorithm causes evolution speed to be slow.
concept of velocity operators also solves the problem for This paper discusses on the new parameters for the
distinguishing pbest or gbest which the particle requires to pheromone in Ant Colony Optimization algorithm to
know. increase the selection probability. Improvement in the
sensitivity of the shortest path to find the shortest path is
[4] Khushboo Arora, Mamta Arora, “Better Result for
done and hence Ant Colony algorithm is optimized in it
Solving TSP: GA versus ACO”, International Journal of
selection optimization and to find the short path.
Advanced Research in Computer Science and Software
Engineering, Volume 6, Issue 3, March 2016.

This paper surveys on the comparison on some main


heuristic algorithms for travelling salesman problem. It
presents an overview of the Genetic Algorithm and Ant
Colony Optimization algorithms. The GA uses the fitness
function whereas the ACO use the pheromone concept.
Table 3: Literature survey with Limitations
Serial
Author name and publisher Title of the paper Technique used Limitation
no.
Gilbert Laporte. The Traveling Salesman Complexity analysis, Exact solution of path
Problem: An overview of Exact algorithms, is present up to 2000
1. European Journal of Operational exact and approximate Heuristic Algorithms. nodes.
Research 59 (1992) 231-247 North- algorithms.
Holland
X.H. Shi a, Y.C. Liang a,b,∗, H.P. Lee b,c, Particle swarm An uncertain It is only effective in
b
C. Lu , Q.X. Wang , a
optimization-based searching strategy in larger problems in
algorithm for TSP and which crossover is terms of number of
“Particle swarm optimization-based generalized TSP eliminated to cities.
algorithm for TSP and generalized accelerate the
TSP”, a College of Computer Science convergence speed.
and Technology, Jilin University, Key Generalized
Laboratory of Symbol Computation chromosome
and Knowledge Engineering of the technique has been
Ministry of Education, Changchun used.
2. 130012, China, b
Institute of High
Performance Computing, Singapore
c
117528, Singapore, Department of
Mechanical Engineering, National
University of Singapore, 9
Engineering Drive 1, Singapore
119260, Singapore, Received 31 July
2005; received in revised form 10
February 2007.

Elizabeth F. G. Goldbarg, Marco C. Particle Swarm It uses new velocity The unary and a
Goldbarg and Givanaldo R. de Souza Optimization Algorithm operator to direct the binary concept of
for the Traveling search. velocity operators
University Campus STeP Ri Slavka Salesman Problem does not solve the
3. Krautzeka 83/A 51000 Rijeka, problem for
Croatia, Published online 01, distinguishing pbest
September, 2008 or gbest effectively.

Khushboo Arora, Mamta Arora Better Result for Solving Phermone concept of Genetic algorithms
TSP: GA versus ACO Ant Colony result are not effective
International Journal of Advanced Optimization and when nodes increases
4. Research in Computer Science and Crossover, Mutation of and ACO does not
Software Engineering, Volume 6, Genetic Algorithm. provide effective
Issue 3, March 2016. result in terms of
distance travelled.
Naixue Xiong 1,2, Wenliang Wu 1 An Improved Routing New parameter for Effective results
and Chunxue Wu 1 Optimization Algorithm pheromone in Ant cannot be generated in
Based on Travelling Colony Optimization terms of the distance
School of Optical-Electrical and Salesman Problem for Algoritm. travelled.
Computer Engineering, University of Social Networks
Shanghai for Science and Technology,
Military Road, No. 516, Shanghai
200093, China;
5. xiongnaixue@gmail.com (N.X.);
wwl@st.usst.edu.cn (W.W.) 2
Department of Mathematics and
Computer Science, Northeastern State
University Address: 611 N, Grand
Ave, Tahlequah, OK 74464, USA,
Received: 5 April 2017; Accepted: 6
June 2017; Published: 8 June 2017
European Journal Engineering,
of Operational National
Research 59 (1992) University of
V. CONCLUSION
231-247 North- Singapore, 9
Holland, Centre de Engineering Drive
This project is based
recherche sur les 1, Singapore
Travelling Salesman
transports, 119260, Singapore,
Problem which is a NP-hard
Universit~ de Received 31 July
problem and cannot be
Montr&l, C.P. 2005; received in
exactly solved in
6128, Station A, revised form 10
polynomial time, so an
Montreal, Canada February 2007.
optimal result can only be
H3C M7 Received [3] Elizabeth F. G.
found. The use of Genetic
May 1991; Goldbarg, Marco
Algorithm promises to solve
received July 1991. C. Goldbarg and
this problem more a
[2] X.H. Shi , Y.C. Givanaldo R. de
effectively than other
Liang a,b,∗
, H.P. Lee Souza, “Particle
optimization algorithm due b,c
, C. Lu b, Q.X. Swarm
to its robustness. Genetic
Wang a
, “Particle Optimization
algorithm has the best
swarm Algorithm for the
combinational techniques
optimization-based Traveling Salesman
which are crossover and
algorithm for TSP Problem”,
mutation which is based on
and generalized University Campus
natural selection. Travelling
TSP”, a
College of STeP Ri Slavka
Salesman Problem is one of
Computer Science Krautzeka 83/A
the hardest problem in NP-
and Technology, 51000 Rijeka,
complete. The
Jilin University, Croatia, Published
implementation work is
Key Laboratory of online 01,
done in MATLAB software
Symbol September, 2008.
due to its inbuilt features
Computation and
[4] Khushboo Arora,
like number generator and
Knowledge
Mamta Arora,
graph plotter.
Engineering of the
“Better Result for
Ministry of
Solving TSP: GA
REFERENCES Education,
versus ACO”,
Changchun
International
b
130012, China,
[1] Gilbert Laporte, Journal of
Institute of High
“The Traveling Advanced
Performance
Salesman Problem: Research in
Computing,
An overview of Computer Science
Singapore 117528,
exact and and Software
c
Singapore,
approximate Engineering,
Department of
algorithms”,
Mechanical
Volume 6, Issue 3,
March 2016.
[5] Naixue Xiong 1,2,
Wenliang Wu 1 and
Chunxue Wu 1*,
“An Improved
Routing
Optimization
Algorithm Based
on Travelling
Salesman Problem
for Social
Networks”, 1
School of Optical-
Electrical and
Computer
Engineering,
University of
Shanghai for
Science and
Technology,
Military Road, No.
516, Shanghai
200093, China;
xiongnaixue@gmai
l.com (N.X.);
wwl@st.usst.edu.c
n (W.W.) 2
Department of
Mathematics and
Computer Science,
Northeastern State
University
Address: 611 N,
Grand Ave,
Tahlequah, OK
74464, USA,
Received: 5 April
2017; Accepted: 6
June 2017;
Published: 8 June
2017.

Você também pode gostar