genetic algorithm for travelling salesman problem - csnow.in · no: 22220379 has carried out her...
TRANSCRIPT
A PROJECT REPORT
ON
Genetic Algorithm for Travelling Salesman Problem
A Project Work (MS-405)
Submitted to Assam University, Silchar in partial fulfillment of the requirements for
the award of degree of Master of Science in Computer Science
Under the Guidance of
Dr.(Mrs.) ShahinAra Begum
Associate Professor
Department of Computer Science,
Assam University, Silchar
Submitted by
BishakhaChakrabarty
M.Sc. (2 years) 4th
Semester
Roll 101614 No 22220379
Regn. No.: 01-100008467 of 2010-2011
(Paper Code: MS-405)
Department of Computer Science
Assam University, Silchar- 788011
May 2016
DECLARATION
I, BishakhaChakrabarty, student of 4th
semester(M.Sc. 2 years), Department of Computer
Science do hereby solemnly declare that I have duly worked on my project entitled
―Genetic Algorithm for Travelling Salesman Problem‖ under the supervision of Dr.(Mrs.)
ShahinAra Begum, Associate Professor, Department of Computer Science, Assam
University, Silchar. This project work is submitted in the partial fulfillment of the
requirements for the award of degree of Master of Science in Computer Science. The
results embodied in this thesis have not been submitted to any other university or
institution for the award of any degree or diploma.
Date: (BishakhaChakrabarty)
Place: Assam University, Silchar Semester- 4th
sem(Msc 2 years)
Roll: 101614 No: 22220379
Regn. No: 01-100008467 of 2010-2011
Assam University, Silchar
CERTIFICATE
This is to certify that Miss. BishakhaChakrabarty, student of 4th
semester(M.Sc. 2 years),
Department of Computer Science, Assam University, Silchar, bearing the Roll: 101614
No: 22220379 has carried out her project work entitled ―Genetic Algorithm for
Travelling Salesman Problem‖ under my guidance in the partial fulfillment of the
requirement for the award of degree of Master of Science in Computer Science during the
period January 2016 to May 2016.
The project is the result of her investigation and neither the report as a whole, nor any
part of it has been submitted to any other university or institution for any degree or
diploma.
Date:Dr.(Mrs.) ShahinAra Begum
Place: Associate Professor,
Department of Computer Science,
Assam University, Silchar.
CERTIFICATE
This is to certify that Miss. BishakhaChakrabarty, student of 4th
semester(M.Sc. 2 years),
Department of Computer Science, Assam University, Silchar, bearing the Roll: 101614
No: 22220379 has carried out her project work entitled ―Genetic Algorithm for
Travelling Salesman Problem‖ under the guidance of Dr.(Mrs.) ShahinAra Begum,
Associate Professor, Department of Computer Science, Assam University, Silchar, in the
partial fulfillment of the requirement for the award of degree of Master of Science in
Computer Science during the period January 2016 to May 2016.
The project is the result of her investigation and neither the report as a whole, nor any
part of it has been submitted to any other university or institution for any degree or
diploma.
Date:Dr.BipulShyamPurkayastha
Place: Head of Department,
Department of Computer Science,
Assam University, Silchar.
ACKNOWLEDGEMENT
I would like to take the opportunity to extend my heartfelt gratitude to my project guide
Dr.(Mrs.) ShahinAra Begum, Associate Professor, Department of Computer Science,
Assaam University, Silchar, for her valuable time and for being always supportive to my
work and giving me the freedom of thought always.
I wish to express my deep sense of gratitude and indebtedness to Prof.
BipulShyamPurkayastha, Head, Department of Computer Science, Assam University,
Silchar, for providing me the opportunity to utilize the facilities of the Department of
Computer Science.
I would like to thank all the teachers of the Department of Computer Science, Assam
University, Silchar, for their useful discussion and advice throughout my project.
I am grateful to my parents, for their support, concern and help as and when required. I
thank all my friends and classmates for their support.
(BishakhaChakrabarty)
CONTENTS
Page No.
Declaration…………………………………………………………………… i
Certificates……………………………………………………………………. ii
Acknowledgement……………………………………………………….. iv
List of figures………………………………………………………………… vii
List of tables………………………………………………………………….. viii
Abstract…………………………………………………………………………. ix
Chapter-1 Introduction....................................................................... 1-7
1.1 Aim of the project…………………………………………………. 2
1.2 Search Techniques…………………………………………………. 3-7
Chapter-2 Literature Survey…………………………………………………………..8-9
Chapter-3 Genetic Algorithm…………………………………………………………. 10-16
3.1 Introduction…………………………………………………………… 10
3.2 Parameters of Genetic Algorithm……………………………. 11
3.3 Crossover Methods………………………………………………… 12
3.4 Mutation……………………………………………………………….. 13
3.5 Selection……………………………………………………………….. 13-14
3.6 Algorithm……………………………………………………………… 14
3.7 Flowchart……………………………………………………………… 15
3.8 Advantages and Disadvantages of GA…………………….. 16
3.9 Applications of GA………………………………………………….. 16
Chapter-4 Travelling Salesman Problem…………………………………… 17-22
4.1 Introduction…………………………………………………………. 17
4.2 Mathematical Formulation of TSP………………………… 17-18
4.3 Methods to solve TSP…………………………………………… 18-21
4.4 Applications of TSP………………………………………………. 22
Chapter- 5 Implementation…………………………………………………….. 23-25
5.1 Solving Travelling Salesman Problem using GA…….. 23
Chapter- 6 Results and Discussions…………………………………………. 26-31
Chapter- 7 Conclusions and Future Scope……………………………….. 32
7.1 Conclusion…………………………………………………………… 32
7.2 Future Scope……………………………………………………….. 32
References……………………………………………………………......................... 33-34
Appendices……………………………………………………………………………………. 35-39
Appendix A: Snapshots of I/O Screen……………………………. 35-38
Appendix B: Development Platform……………………………… 39
LIST OF FIGURES
Fig 1 Different search techniques to solve optimization problems ……… 3
Fig 2 Flowchart of Genetic Algorithm…………………………………..15
Fig 3 Snapshots of I/O screen……………………………………………35
LIST OF TABLES
Table 6.1(a) Results based on Roulette wheel selection for Uniform crossover ..26
Table 6.1(b) Results based on Roulette wheel selection for One point crossover.27
Table 6.1(c) Results based on Roulette wheel selection for Two point crossover.27
Table 6.2(a) Results based on Rank selection for Uniform crossover…………...28
Table 6.2(b) Results based on Rank selection for One point crossover………….29
Table 6.2(c) Results based on Rank selection for Two point crossover………….29
Table 6.3(a) Results based on Tournament selection for Uniform crossover……30
Table 6.3(b) Results based on Tournament selection for One point crossover…..30
Table 6.3(c) Results based on Tournament selection for Two point crossover….31
ABSTRACT
Genetic Algorithm is a search technique used in computing to find the optimal solution to
a computational problem that maximizes or minimizes a particular function. Genetic
Algorithm is used to solve the Travelling Salesman Problem where one has to find the
shortest route among the cities from the origin.
Genetic Algorithm is computer algorithm that search for good solutions to a problem
from various possible solutions. The basic elements of Genetic Algorithm are
chromosomes, fitness function, selection, crossover and mutation.
The Travelling Salesman Problem (TSP) is well known in the field of combinatorial
optimization. Since it is an NP-complete problem, there is no efficient method to solve
this problem and give the best result. Many algorithms are used to solve travelling
salesman problem. Some algorithms give optimal solution, but some other algorithms
give the nearest optimal solution. The genetic algorithm is a heuristic method which is
used to improve the solution space for the Travelling Salesman Problem. The genetic
algorithm results in nearest optimal solution within a reasonable time. This project
mainly focuses on the comparative study of different selection methods and crossover
operators in genetic algorithm to solve Travelling Salesman Problem and finally report
the results.
CHAPTER- 1
INTRODUCTION
Genetic Algorithm is used to solve the Travelling Salesman Problem where one
has to find the shortest route among the cities from the origin.
Genetic Algorithms are computer algorithm that search for good solutions to a problem
from various possible solutions. The basic elements of Genetic Algorithm are
chromosomes, fitness function, selection, crossover and mutation.
The computational paradigms of GA were inspired by the mechanics of natural
evolution, including survival of the fittest, reproduction, and mutation. These mechanics
are well suited to resolve a variety of practical problems, including computational
problems, in many fields.Some applications of Genetic Algorithm are combinatorial
optimization, automatic programming, machine learning and economics.
In the present work, a comparative study among three selection methods has been
carried out. Fitness costs are used to conduct a comparison test of performance among the
three selection methods. The results obtained from the comparison test are tabulated and
the best performance is found with Roulette Wheel Selection.
The project report is organized as follows: Chapter-1 introduces the aim and objectives of
the project, followed by a brief description of various search techniques. Chapter-2
describes the literature survey of Genetic Algorithm and Travelling Salesman Problem.
Chapter-3 describes the Genetic Algorithm, followed by a brief description of its basic
parameters, operators, working, applications and flowchart. In Chapter-4 the basic
concept of Travelling Salesman Problem is described, followed by mathematical
formulation, methods to solve Travelling Salesman Problem and its applications.
Chapter-5 describes the implementation of Travelling Salesman Problem using Genetic
Algorithm and description of GUI implementation in Java followed by the results and
analysis of three selection methods based on fitness measure in Chapter-6. Chapter-7
describes the conclusion and future work.
1.1AIM OF THE PROJECT
The aim of this project is to solve the Travelling Salesman Problem using Genetic
Algorithm.
The present study has been undertaken with the following objectives:
To study genetic algorithm.
To study various parameters and operators of genetic algorithm.
To study travelling salesman problem.
To find the solution of travelling salesman problem using genetic algorithm and its
operators.
To make a comparative study of different selection methods and crossover
operators and finally report the results.
1.2 SEARCH TECHNIQUES
There are various search techniques for solving optimization problems. The different
search techniques are shown in the figure 1. Among the various search techniques I have
chosen genetic algorithm to solve the travelling salesman problem.
Fig 1: Different search techniques to solve optimization problems.
Soft Computing
Fuzzy Systems Neural NetworksEvolutionary Computation
Genetic Algorithm
Genetic Programming
Machine Learning
1.2.1 SOFT COMPUTING:-
It is the fusion of methodologies that were designed to model and enable solutions to real
world problems, which are not modeled, or too difficult to model, mathematically.It is
associated with fuzzy, complex and dynamic system with uncertain parameters.
Quality of Service Networking is an example of the class of complex, fuzzy and dynamic
systems with uncertain parameters, which soft computing is intended to model and
compute.
Current Applications of Soft Computing include:-
Handwriting Recognition
Image Processing and Data Compression
Automotive Systems and Manufacturing
Decision –Support Systems
Neurofuzzy Systems
Fuzzy Logic Control
1.2.2EVOLUTIONARY COMPUTATION:-
Evolutionary computation simulates evolution on a computer. The result of such a
simulation is a series of optimization algorithms, usually based on a simple set of
rules. Optimization iteratively improves the quality of solutions until an optimal, or at
least feasible, solution is found.
Evolutionary Computations can be studied under 2 categories:
Genetic Algorithm
Genetic programming
GENETIC ALGORITHM
Genetic Algorithm is a branch of Artificial Intelligence stochastic search technique that is
widely used in the field of optimization. GA‘s are computer algorithms that search for
good solutions to a problem from various possible solutions. This is well suited to resolve
variety of practical problems, computational problems.
It randomly generates a set of possible solutions to a problem, representing each as a
fixed length character string. It then test each possible solution against the problem using
a fitness function to evaluate each solution. Keep the best solutions, and use them to
generate new possible solutions. Repeat the previous two steps until either an acceptable
solution is found.
GENETIC PROGRAMMING
In artificial intelligence, genetic programming (GP) is an evolutionary algorithm-based
methodology inspired by biological evolution to find computer programs that perform a
user-defined task. Essentially GP is a set of instructions and a fitness function to measure
how well a computer has performed a task. It is a specialization of genetic algorithms
(GA) where each individual is a computer program. It is a machine learning technique
used to optimize a population of computer programs according to a fitness landscape
determined by a program's ability to perform a given computational task. GP evolves
computer programs, traditionally represented in memory as tree structures. Trees can be
easily evaluated in a recursive manner. Every tree node has an operator function and
every terminal node has an operand, making mathematical expressions easy to evolve and
evaluate.
FUZZY SYSTEM
A fuzzy control system is a control system based on fuzzy logic—a mathematical system
that analyzes analog input values in terms of logical variables that take on continuous
values between 0 and 1, in contrast to classical or digital logic, which operates on discrete
values of either 1 or 0 (true or false, respectively) The term "fuzzy" refers to the fact that
the logic involved can deal with concepts that cannot be expressed as the "true" or "false"
but rather as "partially true". Although alternative approaches such as genetic algorithms
and neural networks can perform just as well as fuzzy logic in many cases, fuzzy logic
has the advantage that the solution to the problem can be cast in terms that human
operators can understand, so that their experience can be used in the design of the
controller. This makes it easier to mechanize tasks that are already successfully
performed by humans.
NEURAL NETWORK
a neural network is a system of programs and data structures that approximates the
operation of the human brain. A neural network usually involves a large number of
processors operating in parallel, each with its own small sphere of knowledge and access
to data in its local memory. Typically, a neural network is initially "trained" or fed large
amounts of data and rules about data relationships (for example, "A grandfather is older
than a person's father"). A program can then tell the network how to behave in response
to an external stimulus (for example, to input from a computer user who is interacting
with the network) or can initiate activity on its own (within the limits of its access to the
external world). neural networks use several principles, including gradient-based training,
fuzzy logic, genetic algorithms, and Bayesian methods.
MACHINE LEARNING
Machine learning is a subfield of computer science that evolved from the study of pattern
recognition and computational learning theory in artificial intelligence. Machine learning
explores the study and construction of algorithms that can learn from and make
predictions on data. Such algorithms operate by building a model from example inputs in
order to make data-driven predictions or decisions, rather than following strictly static
program instructions.
Machine learning is closely related to computational statistics; a discipline that aims at
the design of algorithms for implementing statistical methods on computers. It has strong
ties to mathematical optimization, which delivers methods, theory and application
domains to the field. Machine learning is employed in a range of computing tasks where
designing and programming explicit algorithms is infeasible. Example applications
include spam filtering, optical character recognition (OCR), search engines and computer
vision.
In the present work I have chosen genetic algorithm to solve the travelling salesman
problem. In the next chapter a survey on solving travelling salesman problem has been
carried out.
CHAPTER – 2
LITERATURE SURVEY
Varshika et al.,(2012) proposed the work which uses TSP domain and it is solved
using genetic algorithm operators. The genetic algorithm is used for the purpose of
improving the solution space. The crossover is the important stage in the genetic
algorithm.
Naveen et al.,(2012) have done the survey on the travelling salesman problem
using various genetic algorithm operators. The proposed work solves the travelling
salesman problem using various genetic algorithm operators. The various methods for the
genetic algorithm operators like selection methods, crossover methods and mutation
methods are also mentioned in the paper.
Omar et al.,(2009) proposed an improved genetic algorithm where the new
crossover operation, population reformulation operation, multi-mutation operation, partial
local optimal mutation operation, and rearrangement operations are used to solve the
Traveling Salesman Problem.
Chetan et al.,(2011) solved the travelling salesman problem using genetic
algorithm operators. The paper also includes a comparative study on various parent
selection methods such as Roulette Wheel, Elitism and Tournament selection methods for
Travelling Salesman problem. This paper concludes that all the three selection methods
give similar solution when the population size is small but when the population size is
large Elitism method gives the better result.
A. Arananayakgi(2014) solvedthe travelling problem using genetic algorithm
operators to reduce the total distance and time. This is achieved by generating the fittest
criteria using selection, crossover and mutation operators. The main aim of the proposed
method is to produce the high quality solutions in reasonable time. So a new crossover
method, the Sequential Constructive Crossover method is used. This method will selects
the better edges from the parent chromosome and produce a new offspring which may
have same edges as the parents or it may have new edges which is not present in the
parent chromosomes.
Kasassbeh et al.,(2012) proposed a new crossover method which is used and it is
called as a Shared Crossover method. This method is simple and fast and the main aim is
to reduce the execution time. This new technique depends on passing as many as possible
of the shared paths between cities to the next generation with a guarantee that none of the
cities will appear in the child chromosome more than once after applying the crossover
method. The experimental results also show the greater reduction in the time
consumption.
In chapter-3, genetic algorithm, parameters of genetic algorithm and the various operators
of genetic algorithm has been discussed.
CHAPTER - 3
GENETIC ALGORITHM
3.1 INTRODUCTION
Genetic Algorithm is a branch of Artificial Intelligence stochastic search technique that is
widely used in the field of optimization. GA‘s are computer algorithms that search for
good solutions to a problem from various possible solutions. This is well suited to resolve
variety of practical problems, computational problems.
It randomly generates a set of possible solutions to a problem, representing each as a
fixed length character string. It then test each possible solution against the problem using
a fitness function to evaluate each solution. Keep the best solutions, and use them to
generate new possible solutions. Repeat the previous two steps until either an acceptable
solution is found.
GA was proposed by John Holland, his students and his colleagues at the University of
Michigan. Carrasco et al (2001) Genetic Algorithm (GA) model introduced by John
Holland in 1975 triggered a wide interest in the application of types of heuristic, which
mimic the natural evolutionary characteristic present in the biological species with the
purpose of solving optimization problem efficiently.
Randy et al (1998) GAs is a branch of artificial intelligence‘s stochastic search technique
that is widely used in the field of optimization.
According to Biesbroek (1999) the study of GA was originated from studies done on
cellular automata, which took place when Goldberg was at the University of Michigan.
John Koza(1992) has used genetic algorithm to evolve programs to perform certain tasks.
He called his method ―genetic programming‖ (GP).
3.2 PARAMETRS OF GENETIC ALGORITHM:-
CHROMOSOME:- A set of genes; chromosome contains the solution in the form of
genes.
GENE:- A part of chromosome; a gene contains a part of solution. It determines the
solution. For e.g- 10011 is a chromosome and 1,0,0,1,1 are its genes.
POPULATION SIZE:-It says how many chromosomes are in population.It depends on
the type of encoding and the problem. If there are only few chromosomes, then GA
would have a few possibilities to perform crossover and only a small part of search space
is explored. If there are many chromosomes then GA slows down.
REPRODUCTION:- It is usually the first operator applied on population. Chromosomes
are selected from the population of parents to cross over and produce offspring. It is
based on Darwin‘s evolution theory of ―Survival of the fittest‖. Therefore, this operator is
also known as ‗Selection Operator‘.
CROSS OVER:-After reproduction phase, population is enriched with better
individuals. It makes clones of good strings but does not create new ones. Cross over
operator is applied with a hope that it would create better strings.
MUTATION:-After cross over, the strings are subjected to mutation. Mutation of a bit
involves flipping it,changing 0 to 1 and vice-versa.
3.3 CROSSOVER METHODS:-
3.3.1 Single Point Crossover
A commonly used method for crossover is called single point crossover. In this method,
a single point crossover position is chosen at random and the parts of two parents after
the crossover position are exchanged to form two offspring.
Parent 1: 1 0 1 1 | 1 1 1
Parent 2: 0 1 0 1 | 0 0 1
Offspring 1: 1 0 1 1 1 0 0 1
Offspring 2: 0 1 0 1 0 1 1 1
3.3.2 Multipoint Crossover
It is a generalization of single point crossover, introducing a higher number of cut
points.
Parent 1: 1 0 0 |1 0 1| 1 1
Parent 2: 0 1 1 |1 0 0 | 0 1
Offspring 1: 1 0 0 1 0 0 1 1
Offspring 2: 0 1 1 1 0 1 0 1
3.3.3 Uniform Crossover
It doesn‘t use cut points, but simply uses a global parameter to indicate the
likelihood that each variable should be exchanged between two parents.
Parent 1: 1 0 1 0 0 0 1 1 1 0
Parent 2: 0 0 1 1 0 1 0 0 1 0
Offspring 1: 0 0 1 1 0 0 1 0 1 0
Offspring 2: 1 0 1 0 0 1 0 1 1 0
3.4 MUTATION:-
It represents a change in the gene. The mutation operator flips a randomly selected gene
in a chromosome. It changes the bit 0 to 1 and vice-versa.
Original Offspring: 1 0 1 1 0 1 1 1
Mutated Offspring: 1 0 1 1 0 0 1 1
3.5 SELECTION:-
It is the process of determining the number of times a particular individual is chosen for
reproduction and thus the number of offspring that an individual will produce.
3.5.1 Types of Selection Method
I. Roulette Wheel Selection
II. Tournament Selection
III. Half-Truncation Selection
Roulette Wheel Selection:-
The simplest selection scheme is roulette wheel selection, also called stochastic sampling
with replacement. This is a stochastic algorithm and involves the following technique:
The individuals are mapped to contiguous segments of a line, such that each individual‘s
segment is equal in size to its fitness. A random number is generated and the individual
whose segment spans the random number is selected. The process is repeated until the
desired number of individuals is obtained(called mating population).
Tournament Selection:-
In tournament selection a number Tour of individuals is chosen randomly from the
population and the best individual from this group is selected as parent. This process is
repeated as often as individuals to choose. These selected parents produce uniform at
random offspring. The parameter for tournament selection is the tournament size Tour.
Tour takes values ranging from 2- Nind(number of individuals in population).
Half-Truncation Selection:-
Compared to the previous selection methods modeling natural selection is an artificial
selection method. It is used by breeders for large population/mass selection. In truncation
selection individuals are sorted according to their fitness. Only the best individuals are
selected for parents. These selected parents produce uniform at random offspring. The
parameter for truncation selection is the truncation threshold Trunc. Trunc indicates the
proportion of the population to be selected as parents and takes values ranging from 50%-
100%. Individuals below the truncation threshold do not produce offspring.
3.6 PSEUDO CODE OF GENETIC ALGORITHM
Begin
INITIALIZE population with random candidate solutions;
EVALUATE each candidate;
Repeat
SELECT parents;
RECOMBINE pairs of parents;
MUTATE the resulting children;
EVALUATE children;
SELECT individuals for the next generation
Until TERMINATION-CONDITION is satisfied
End
3.7 FLOWCHART
Fig 2: Flowchart for Genetic Algorithm.
3.8ADVANTAGES AND DISADVANTAGES OF GA:-
3.8.1 ADVANTAGES
1. Easy to understand.
2. Unlike older AI systems, the GA‘s do not break easily even if the inputs changed
slightly.
3. GA can be employed for a wide variety of optimization problems.
4. GA performs very well for large scale optimization problems which may be very
difficult or impossible to solve by other traditional methods.
3.8.2 DISADVANTAGES
1. Sometimes have trouble finding the exact global optimum because there is no
guaranty to find best solution.
2. It requires large number of fitness function evaluations depending on the number
of individuals and the number of generations.
3. GA may take long time to evaluate the individuals.
3.9APPLICATIONS OF GENETIC ALGORITHM
I. Scheduling: Facility, Production, Job and Transport Scheduling.
II. Design: Circuit board layout, Communication Network design, Parametric
design in aircraft.
III. Control: Missile evasion, Gas pipeline control, Pole balancing.
IV. Machine Learning: Designing Neural Networks, Classifier Systems, Learning
rules.
V. Robotics: Trajectory Planning, Path Planning.
VI. Combinatorial Optimization: TSP, Bin Packing, Set Covering, Routing.
VII. Image Processing: Pattern recognition.
VIII. Medical: Studying health risks for a population exposed to toxins.
In chapter-4, Travelling Salesman problem(TSP), mathematical formulation of TSP and
various methods to solve TSP has been discussed.
CHAPTER- 4
TRAVELLING SALESMAN PROBLEM
4.1 INTRODUCTION
Travelling salesman problem(TSP) is a well- known classic problem from computer
science. Its mathematical formulation is simple, and one can state a simple strategy to
solve. Such a strategy is often impractical and as yet there is no efficient algorithm for
this problem that works consistently in all instances.TSP is a choice problem for
combinatorial optimization problems and one that has received the most attention.
Another thing to note is that one can‘t find for the Travelling Salesman Problem a
consistently efficient method of solution, as it belongs to a set of combinatorial
problem that are called NP-complete problems. NP-complete problems have the
distinction that there is no known algorithm that is efficient, practical and works in all
instances.
The Travelling Salesman Problem is easy to state: given a finite number of cities along
with the cost of travel between each pair of them, TSP is the search of the shortest tour
that visits the given cities exactly once.
4.2 MATHEMATICAL FORMULATION OF TSP
Mathematically, the goal of this problem is to find a tour, among all the possible tours,
that minimizes the total distance the salesman travels. The other criterion that the
problem has to satisfy is that each city should be visited once and only once, except that
he returns to the city from which the salesman starts.
TSP can be formulated as an integer linear program. Label the cities with the numbers
0,…,n. For n cities to visit, let xij be the variable that has a value 1 if the salesman goes
from city i to city j and a value 0 if the salesman does not go from city i to city j. Letdijbe
the distance from city i to city j.
Then the TSP can be stated as-
Minimize the linear objective function:
𝑍 = 𝑥𝑛𝑗≠𝑖 𝑗=0
𝑛𝑖=0 ijdij
0≤xij≤1 i, j= 0,…,n
Subject to the constraint,
𝑥𝑛𝑖=0,𝑖≠𝑗 ij=1 j=0,…n
𝑥𝑛𝑗=0,𝑗≠𝑖 ij=1 i=0,…,n
4.3 METHODS TO SOLVE TSP
4.3.1 Total enumeration method
In principle it is a combinatorial solution. The method rests in evaluation of all potential
routes (sequences) in the total number of (n – 1)!. Theadvantage is that a global optimum
is always found, however, it is not employable if higher numbers of visited places are
considered. With every added element (node) the amount of possible solutions grows
exponentially and not even nowadays do we have computers powerful enough for being
able to provide optimum solution within reasonable time.
4.3.2 Branch and Bound method
This method belongs to the oldest ones and the most often used algorithms for the TSP
solutions. The merit of the method rests in a gradual decomposition of a possible solution
set into a number of mutually disjunctive subsets labelled asbranches. In each step the
following is estimated:
The upper limit of the objective function that is most often the value of the objective
function zHwithout respecting limits and maximum lower bound of an objective function
zDof acceptable solutions which are known to us within the step.
Both the estimates can be employed for seeking non-prospective directions of further
procedures: if for any branch zH<zD, then the given direction canbe excluded. However,
this method is also, especially for higher n, too laborious and does not always guarantee
an optimum solution at the first attempt.
4.3.3 Clarke and Wright Algorithm
A significant progress in TSP solutions was provided by the Clarke‘s and Wright‘s
method. The initial situation assumes that each place is supplied individually and always
a return to the starting base follows. The essential idea is based on thecalculation of
economies achieved through integrating other places into the circular route. An
indisputable asset of this algorithm is its function to respect further restrictions often
generated by the practice, e.g. the need to optimize more orbitalroutes, to use more
vehicles while respecting their various capacities etc.
Guerra, Murino and Romano worked with thisalgorithm for optimize the routing phase in
a Location-Routing Problem (LRP) in. LRP can by assimilate to a Vehicle Routing
Problem (VRP) and after that they combine and balance VRP with TSP. Both problems
were solved with Clarke and Wright saving algorithm and the Branch and Bound model.
4.3.4 Ant Colony Optimization(ACO) Algorithm
ACO is one of the metaheuristic methods for solving TSP. Jalali, Afshar and Marino
described ACO as observation of real ants, and upon finding food return to their colony
while laying down pheromone trails. If other ants find such a path, they are likely not to
keep travelling at random, but to instead follow the trail, returning and reinforcing it if
they eventually find food. There is a higher probability that the trail with a higher
pheromone concentration will be chosen.
The pheromone trail allows ants to find their wayback to the food source and in the
opposite way.The trail is used by other ants to locate food sourcediscovered by any ant.
When a number of pathsavailable from the nest to a food source, a colony ofants may by
able to exploit the pheromone trail leftby individual members of the colony to
discoverthe shortest path from the nest to the food sourceand back. As more ants choose a
path to follow, thepheromone on the path builds up, making it moreattractive to be
followed by other ants.
To solve TSP, we keep the strength of pheromone trail _i,jfor each combination of two
points. The role of each ant is to find a valid solution, thuspossible routes. From the
starting point, the ant gradually repeats a move when it chooses a place where it has not
been yet while moving to it fromits current location. Once there are no more vacancies
left, the ant returns to the starting location. ACO is one of the Swarm Intelligence
systems which include many other algorithms such as Particle Swarm Optimization and
River formationdynamics.
4.3.5 Particle Swarm Optimization(PSO) Algorithm
PSO proceed from the social behavior of organisms such as bird flocking and fishing
schooling. Through cooperation between individuals, the group often can achieve their
goal efficiently and effectively. PSO simulates this social behavior asan optimization tool
to solve some optimization problems. Each particle flies in the search spacewith a
velocity that is dynamically adjusted basedon its own flying experience and its
companions‘flying experience. In other word, every particle willutilize both the present
best position information of its own (pbest) and the global best position information
(gbest) that swarm has searched up-tonowto change its velocity and thus arrives in the
new position.
4.3.6 Genetic algorithms(GA)
In recent years there have been attempts to use so called genetic algorithms for TSP
solutions. Simply stated, genetic algorithms transfer evolution principles in living
organisms into intelligent searching and model optimization in other fields.
Biological terminology is applied also to this very description of the algorithm. Genetic
algorithm, as well as nature, works with population of individuals (P) defined by one or
more mathematical genes – chromosomes (i.e. sequencesof numbers in binary notation.
The genetic algorithm (GA) uses the following steps:
1. Generate a population- The GA randomly samples values of the changing cells
between the lower and upper bounds to generate a set of (usually at least 50)
chromosomes. The initial set of chromosomes is called the population.
2. Create a new generation- In the new generation, chromosomes with a smaller
fitness function (in a minimization problem) have a greater chance of surviving to
the next generation. Crossover and mutation are used to generate chromosomes for
the next generation.
3. Stopping conditions- At each generation, the best value of the fitness function in
the generation is recorded, and the algorithm repeats step 2. If no improvement in the
best fitness value is observed after many consecutive generations GA terminates.
4.4 APPLICATIONS OF TSP:-
VEHICLE ROUTING:-
Suppose that in a city ‗n‘ mail boxes have to be emptied everyday within a certain period
of time, say one hour. The problem is to do the particular work with less number of
vehicles in minimum time.
SCHOOL BUS ROUTING PROBLEM:-
The objective of this problem is to obtain a bus loading pattern such that the number of
routes is minimized.The total distance travelled by all buses is kept at minimum.
MISSION PLANNING PROBLEM:-
The objective is to determine an optimal path for army men to accomplish the goals of
the mission in the minimum possible time.
PRINTING PRESS SCHEDULING PROBLEM:-
One of the major and primary applications of the mTSP arises in scheduling a printing
press for a periodical with multi-editions. Here, there exist five pairs of cylinders between
which the paper rolls and both sides of a page are printed simultaneously. There exist
three kind of forms, namely 4-, 6- and 8-page forms, which are used to print the editions.
The scheduling problem consists of deciding which form will be on which run and the
length of each run. In the mTSP vocabulary, the plate change costs are the inter-city
costs.
CREW SCHEDULING PROBLEM:-
An application for deposit carrying between different branch banks is reported by
Svestka&Huckfeldt (1973). Here, deposits need to be picked up at branch banks and
returned to the central office by a crew of messengers. The problem is to determine the
routes having a total minimum distance.
CHAPTER- 5
IMPLEMENTATION
5.1 Solving Travelling Salesman Problem using Genetic Algorithm
Finding a solution to the travelling salesman problem requires that we set up genetic
algorithm in a specialized way. For instance, a valid solution would need to represent a
route where every location is included at least once and only once. If a route contain a
single location more than once, or missed out a location completely then it wouldn't be
valid .To ensure the genetic algorithm does indeed meet this requirement special types of
mutation and crossover methods are needed.Firstly, the mutation method should only be
capable of shuffling the route, it shouldn't ever add or remove a location from the route,
otherwise it would create an invalid solution. One type of method we can use is swap
mutation.With swap mutation two location in the route are selected at random then their
positions are simply swapped. Because swap mutation is only swapping pre-existing
values, it will never create a list which has missing or duplicate values when compared to
the original, and that's exactly what we want for the Travelling Salesman Problem. One
crossover method that's able to produce a valid route is ordered crossover.
In this project locations are typically referred to as cities, and routes are referred to as
tours.In this crossover method we select a subset from the first parent, and then add that
subset to the offspring. Any missing values are then added to the offspring from the
second parent in the order they are found.
Parents:
Offspring:
Representation of the cities
In our project cities are represented with the help of X- coordinates and Y-coordinates of
a particular point, which looks as follows:
Cities:
0 1 2 3
20|30 5|10 10|20 40|50
Selection functions
In the implementation of this project, we tried three selection methods: Roulette wheel
selection, Tournament selection and Half truncation selection, where the fittest
chromosomes are copied without changes to the new population, so the best solutions
found will not be lost.
Fitness Cost
It is a type of function that is used to summarise how close a solution is from the desired
solution.
Fitness Cost= 1/ Distance
Complexity of the program
An exhausted search for a TSP has an exponential time complexity. Suppose that ‗n‘ is
the number of vertices. An exact solution takes O(n!) time, which is prohibitively long.
Therefore, polynomial-time heuristic search approaches are proposed. Heuristic or local
search algorithms have complexities ranging from O(n2)(e.g., nearest neighbour, double
ended nearest neighbour and nearest insertion), O(n2log(n)) (e.g.,shortest edge first).
The genetic algorithms with specialized operators have time complexity O(kmn2) where
‗k‘ is the generation number and ‗m‘ is the population size. The n2 factor is due to the fact
that all the repair procedures need to scan all the possible pairs of the vertices which is
O(n2).(P Merz& B Freisleben, 1997)
GUI Implementation in JAVA
The project was implemented in Java. The graphical user interface (GUI) was designed to
solve the Travelling Salesman Problem using Genetic Algorithm which has two popup
menu for choosing selection and crossover method. The provision for dynamic user input
was also made to provide basic elements of GA such as number of generations, number
of cities and mutation rate to find the new population from the randomly created initial
population. After selecting a method from both the selection and crossover methods and
on submitting the input values, the initial distance and the final distance are evaluated. It
also shows the X-coordinates and Y-coordinates of the cities. A city map is generated
with the help of X-coordinates and Y-coordinates of the cities. The city map shows the
shortest route taken by the salesman to complete his tour.
Source code Details
The source code that implemented on Java has two packages tspGA and TspGui. The
files included in these packages are as follows:
City.java models a city. TourManager.java holds the tour of the cities. Tour.java
stores a candidate tour. Population.java manages the population of candidate tours.
GA.java, it adds the cities and evolve a tour for travelling salesman
problem.TspGuidisplays the main window where all the operations are performed by the
user using graphical user interface.
CHAPTER- 6
RESULTS AND DISCUSSIONS
This chapter describes the performance of Genetic Algorithm for solving Travelling
Salesman Problem based on three Selection methods. The initial population is generated
randomly. A comparative analysis was done among the three selection methods.
Number of Cities : 10
Number of Generations: 100
Mutation Rate : 0.012
The table 6.1 (a-c) shows the performance based on Roulette wheel selection. After
mutation, the new population and their fitness cost are generated from the initial
population for uniform crossover, one point crossover and two point crossover method.
The results obtained are analyzed. The minimum fitness cost obtained in this selection
method is 0.00123 which is for two point crossover method.
Table 6.1(a): Results based on Roulette wheel Selection with Uniform crossover
City=10 X- coordinate Y- coordinate Fitness cost(uniform
crossover)
1 47 191 0.00216
2 49 193 0.00216
3 41 197 0.00328
4 43 137 0.00414
5 65 135 0.00460
6 67 117 0.00558
7 66 127 0.00558
8 42 123 0.00621
9 45 119 0.00621
10 55 141 0.00621
Table 6.1(b): Results based on Roulette wheel Selection with One point crossover
City=10 X- coordinate Y- coordinate Fitness-cost(one-
point crossover)
1 55 135 0.00127
2 30 108 0.00127
3 100 62 0.00135
4 132 55 0.00135
5 159 12 0.00135
6 152 120 0.00143
7 196 198 0.00143
8 158 216 0.00144
9 97 208 0.00144
10 29 248 0.00144
Table 6.1(c): Results based on Roulette wheel Selection with Two point crossover
City=10 X- coordinate Y- coordinate Fitness-cost(two
point crossover)
1 53 151 0.00123
2 73 130 0.00132
3 164 28 0.00135
4 103 1 0.00135
5 20 66 0.00140
6 33 110 0.00141
7 13 127 0.00141
8 18 192 0.00141
9 122 241 0.00141
10 89 167 0.00141
Table 6.2(a): Results based on Rank Selection with Uniform crossover
City=10 X- coordinate Y- coordinate Fitness
cost(uniform)
1 161 158 0.00152
2 161 158 0.00210
3 161 158 0.00210
4 153 171 0.00210
5 153 171 0.00324
6 153 171 0.00324
7 153 171 0.00354
8 88 230 0.00490
9 88 230 0.00490
10 153 171 0.00490
Table 6.2(b): Results based on Rank Selection with One point crossover
City=10 X- coordinate Y-coordinate Fitness-cost(one
point crossover)
1 180 211 0.00127
2 91 215 0.00134
3 87 246 0.00134
4 14 234 0.00147
5 4 225 0.00147
6 23 127 0.00149
7 16 94 0.00156
8 31 69 0.00156
9 78 71 0.00156
10 88 133 0.00167
Table 6.2(c): Results based on Rank Selection with Two point crossover
City=10 X- coordinate Y- coordinate Fitness-cost(two
point crossover)
1 99 76 0.00124
2 7 31 0.00125
3 28 136 0.00127
4 50 170 0.00127
5 107 203 0.00140
6 187 193 0.00140
7 151 135 0.00140
8 139 144 0.00142
9 160 91 0.00146
10 143 8 0.00146
The table 6.2 (a-c) shows the performance based on Rank selection. After mutation, the
new population and their fitness cost are generated from the initial population for uniform
crossover, one point crossover and two point crossover methods. The resultsobtained are
analyzed. The minimum fitness cost obtained in this selection method is 0.00124 which is
for two point crossover method.
Table 6.3(a): Results based on Tournament Selection with Uniform crossover
City=10 X- coordinate Y- coordinate Fitness
cost(uniform)
1 140 153 0.00131
2 140 153 0.00156
3 140 153 0.00194
4 187 97 0.00196
5 192 103 0.00219
6 192 103 0.00228
7 192 103 0.00387
8 192 103 0.00387
9 148 206 0.00408
10 148 206 0.00408
Table 6.3(b): Results based on Tournament Selection with One point crossover
City=10 X- coordinate Y- coordinate Fitness-cost(one
point crossover)
1 100 199 0.00142
2 73 231 0.00142
3 46 233 0.00153
4 28 167 0.00162
5 86 44 0.00167
6 75 20 0.00179
7 114 27 0.00179
8 150 33 0.00179
9 131 72 0.00183
10 98 163 0.00183
Table 6.3(c): Results based on Tournament Selection with Two point crossover
City=10 X- coordinate Y- coordinate Fitness- cost(two
point crossover)
1 180 202 0.00130
2 199 164 0.00137
3 194 135 0.00137
4 137 165 0.00137
5 137 138 0.00137
6 171 67 0.00137
7 119 11 0.00140
8 11 82 0.00140
9 30 103 0.00140
10 109 239 0.00140
The table 6.3(a-c) shows the performance based on Tournament selection. After
mutation, the new population and their fitness cost are generated from the initial
population for uniform crossover, one point crossover and two point crossover methods.
The results obtained are analyzed. The minimum fitness cost obtained in this selection
method is 0.00130 which is for two point crossover method.
Considering the overall performance, the fitness cost are evaluated for Roulette wheel
selection, Rank selection and Tournament selection methods. The minimum fitness cost
and hence the best solution was given by the Roulette wheel selection method where the
fitness cost is minimum i.e., 0.00123. Also, the best crossover method found is two point
crossover method.
CHAPTER- 7
CONCLUSION AND FUTURE SCOPE
7.1 CONCLUSION
In this project, the three selection methods viz. Roulette wheel selection, Rank selection
and Tournament selection methods and the three crossover methodsviz.uniformcrossover,
one point crossover and two point crossover methods are implemented. A city map is
drawn to show the cities travelled by the salesman. It also shows the route taken to visit
all the cities. The results obtained are analyzed and tabulated for Roulette wheel
selection, Rank selection and Tournament selection using Uniform crossover, One point
crossover and Two point crossover methods. The best selection method was found to be
Roulette wheel selection based on the analysis of fitness cost. The minimum fitness cost
found is 0.00123 which is for Two point crossover method.
7.2 FUTURE SCOPE
In this project, basic genetic algorithm is used to solve the Travelling Salesman Problem.
As a future work, it can also be extended for hybrid genetic algorithm and parallel genetic
algorithm. The performance between the two algorithms can also be analyzed based on
the selection methods and crossover operators.
REFERENCES
[1] VarshikaDwivedi, TarunaChauhan, SanuSaxena and PrincieAgrawal, ―Travelling
Salesman Problem using Genetic Algorithm‖, National Conference on Development of
Reliable Information Systems, Techniques and Related Issues (DRISTI) 2012.
[2] Naveen kumar, Karambir and Rajiv Kumar, ―A Genetic Algorithm Approach to Study
Travelling Salesman Problem‖, Journal of Global Research in Computer Science,
Volume 3, No. 3, March 2012, ISSN-2229-371X.
[3] Omar M. Sallabi and Younis EI-Haddad, ―An Improved Genetic Algorithm to Solve
the Traveling Salesman Problem‖, World Academy of Science, Engineering and
Technology Volume 3, 2009.
[4] ChetanChudasama, S. M. Shah and Mahesh Panchal, ―Comparison of Parents
Selection Methods of Genetic Algorithm for TSP‖, International Conference on
Computer Communication and Networks CSI- COMNET-2011.
[5] A. Arananayakgi, ―Reduce Total Distance and Time UsingGenetic Algorithm in
Traveling Salesman Problem‖,International Journal of Computer Science &
EngineeringTechnology, ISSN : 2229-3345, Vol. 5 No. 08 Aug 2014.
[6] Mouhammd Al kasassbeh, Ahmad Alabadleh and TahsenAl-Ramadeen, ―Shared
Crossover Method for SolvingTraveling Salesman Problem‖, IJICS Volume 1, Issue
6September 2012.
[7] http://www.slideshare/genetic algorithm
[8] http://www.slideshare/travelling salesman problem
[9] www.cis.njit.edu/~czumaj//CIS786/Homework1/TSP.html
[10] E.J.W. Boers et al., ―Applications of Evolutionary Compting‖, p.50-59.
[11] Jenna Carr(2014),‖An Introduction to Genetic Algorithms‖.
[12] Elaine Rich & Kevin Knight(1991), Artificial Intelligence, Tata McGraw Hill
Edition.
[13] E.L. Lawler et al. The Travelling Salesman Problem: A Guided Tour of
Combinatorial Optimization, Wiley(1986).
[14]Hahsler, Michael; Hornik, Kurt (2007), ‖TSP Infrastructure for the Traveling
Salesman Problem.
[15] E. Balas (1989). ‖The Prize Collecting Traveling Salesman Problem,‖ Networks 19,
621-636.
[16] E.L. Lawler, J.K. Lenstra, A.H.G. RinnooyKan, and D.B. Shmoys, eds. (1985). The
Travelling Salesman Problem, John Wiley, Chichester.
[17] P Merz, B Freisleben,1997, Evolutionary Computation, IEEE International
Conference on 1997.
APPENDIX A
SNAPSHOTS OF I/O SCREEN
Fig 3: Performing selection and crossover operation to get the optimal solution and the
city map.
APPENDIX B
DEVELOPMENT PLATFORM
B.1 Operating System:
Windows 7
B.2 Software Tools:
Platform used- Java Netbeans IDE 7.0.1
Testing- Java Netbeans IDE 7.0.1
Java is a set of computer software and specifications developed by Sun Microsystems,
which was later acquired by the Oracle Corporation, that provides a system for
developing application software and deploying it in a cross- platform computing
environment.
B.3 Hardware Configuration:
Processor: Intel(R) Core(TM)i3-2370M CPU @ 2.40GHz 2.40GHz
RAM: 4.00 GB
System Type: 32-bit operating system