• Data Structures
  • Linked List
  • Binary Tree
  • Binary Search Tree
  • Segment Tree
  • Disjoint Set Union
  • Fenwick Tree
  • Red-Black Tree
  • Advanced Data Structures
  • Shortest Path Properties
  • Count the number of walks of length N where cost of each walk is equal to a given number
  • Check if a cycle exists between nodes S and T in an Undirected Graph with only S and T repeating | Set - 2
  • Difference Between sum of degrees of odd and even degree nodes in an Undirected Graph
  • Travelling Salesman Problem implementation using BackTracking
  • Samsung Semiconductor Institute of Research(SSIR Software) intern/FTE | Set-3
  • Find the maximum value permutation of a graph
  • Bidirectional Search
  • Maximum number of nodes which can be reached from each node in a graph.
  • Relabel-to-front Algorithm
  • Shortest Path Faster Algorithm
  • Transitive closure of a graph using Floyd Warshall Algorithm
  • Check whether given degrees of vertices represent a Graph or Tree
  • Maximum number of groups of size 3 containing two type of items
  • Maximize the number of uncolored vertices appearing along the path from root vertex and the colored vertices
  • Shortest Superstring Problem | Set 2 (Using Set Cover)
  • Introduction to Push Relabel Algorithm
  • The Role of Algorithms in Computing
  • Josephus Problem when k is 2

Traveling Salesman Problem using Genetic Algorithm

AuPrerequisites: Genetic Algorithm , Travelling Salesman Problem In this article, a genetic algorithm is proposed to solve the travelling salesman problem .  Genetic algorithms are heuristic search algorithms inspired by the process that supports the evolution of life. The algorithm is designed to replicate the natural selection process to carry generation, i.e. survival of the fittest of beings. Standard genetic algorithms are divided into five phases which are:   

  • Creating initial population.
  • Calculating fitness.
  • Selecting the best genes.
  • Crossing over.
  • Mutating to introduce variations.

These algorithms can be implemented to find a solution to the optimization problems of various types. One such problem is the Traveling Salesman Problem . The problem says that a salesman is given a set of cities, he has to find the shortest route to as to visit each city exactly once and return to the starting city.  Approach: In the following implementation, cities are taken as genes, string generated using these characters is called a chromosome, while a fitness score which is equal to the path length of all the cities mentioned, is used to target a population. Fitness Score is defined as the length of the path described by the gene. Lesser the path length fitter is the gene. The fittest of all the genes in the gene pool survive the population test and move to the next iteration. The number of iterations depends upon the value of a cooling variable. The value of the cooling variable keeps on decreasing with each iteration and reaches a threshold after a certain number of iterations. Algorithm:    

Pseudo-code    

How the mutation works? Suppose there are 5 cities: 0, 1, 2, 3, 4. The salesman is in city 0 and he has to find the shortest route to travel through all the cities back to the city 0. A chromosome representing the path chosen can be represented as:   

travelling salesman problem genetic algorithm

This chromosome undergoes mutation. During mutation, the position of two cities in the chromosome is swapped to form a new configuration, except the first and the last cell, as they represent the start and endpoint.   

travelling salesman problem genetic algorithm

Original chromosome had a path length equal to INT_MAX , according to the input defined below, since the path between city 1 and city 4 didn’t exist. After mutation, the new child formed has a path length equal to 21 , which is a much-optimized answer than the original assumption. This is how the genetic algorithm optimizes solutions to hard problems.  

Below is the implementation of the above approach:  

Time complexity:  O(n^2) as it uses nested loops to calculate the fitness value of each gnome in the population.  Auxiliary Space : O(n)

Please Login to comment...

Similar reads.

author

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

Traveling Salesman Problem with Genetic Algorithms

17 minute read

The traveling salesman problem (TSP) is a famous problem in computer science. The problem might be summarized as follows: imagine you are a salesperson who needs to visit some number of cities. Because you want to minimize costs spent on traveling (or maybe you’re just lazy like I am), you want to find out the most efficient route, one that will require the least amount of traveling. You are given a coordinate of the cities to visit on a map. How can you find the optimal route?

The most obvious solution would be the brute force method, where you consider all the different possibilities, calculate the estimated distance for each, and choose the one that is the shortest path. While this is a definite way to solve TSP, the issue with this approach is that it requires a lot of compute—the runtime of this brute force algorithm would be $O(n!)$, which is just utterly terrible.

In this post, we will consider a more interesting way to approach TSP: genetic algorithms. As the name implies, genetic algorithms somewhat simulate an evolutionary process, in which the principle of the survival of the fittest ensures that only the best genes will have survived after some iteration of evolutionary cycles across a number of generations. Genetic algorithms can be considered as a sort of randomized algorithm where we use random sampling to ensure that we probe the entire search space while trying to find the optimal solution. While genetic algorithms are not the most efficient or guaranteed method of solving TSP, I thought it was a fascinating approach nonetheless, so here goes the post on TSP and genetic algorithms.

Problem and Setup

Before we dive into the solution, we need to first consider how we might represent this problem in code. Let’s take a look at the modules we will be using and the mode of representation we will adopt in approaching TSP.

The original, popular TSP requires that the salesperson return to the original starting point destination as well. In other words, if the salesman starts at city A, he has to visit all the rest of the cities until returning back to city A. For the sake of simplicity, however, we don’t enforce this returning requirement in our modified version of TSP.

Below are the modules we will be using for this post. We will be using numpy , more specifically a lot of functions from numpy.random for things like sampling, choosing, or permuting. numpy arrays are also generally faster than using normal Python lists since they support vectorization, which will certainly be beneficial when building our model. For reproducibility, let’s set the random seed to 42.

Representation

Now we need to consider the question of how we might represent TSP in code. Obviously, we will need some cities and some information on the distance between these cities.

One solution is to consider adjacency matrices, somewhat similar to the adjacency list we took a look at on the post on Breadth First and Depth First Search algorithms. The simple idea is that we can construct some matrix that represent distances between cities $i$ and $j$ such that $A_{ij}$ represents the distance between those two cities. When $i=j$, therefore, it is obvious that $A_{ii}$ will be zero, since the distance from city $i$ to itself is trivially zero.

Here is an example of some adjacency matrix. For convenience purposes, we will represent cities by their indices.

Genetic Algorithm

Now it’s time for us to understand how genetic algorithms work. Don’t worry, you don’t have to be a biology major to understand this; simple intuition will do.

The idea is that, we can use some sort of randomized approach to generate an initial population, and motivate an evolutionary cycle such that only superior genes will survive successive iterations. You might be wondering what genes are in this context. Most typically, genes can be thought of as some representation of the solution we are trying to find. In this case, an encoding of the optimal path would be the gene we are looking for.

Evolution is a process that finds an optimal solution for survival through competition and mutation. Basically, the genes that have superior traits will survive, leaving offspring into the next generation. Those that are inferior will be unable to find a mate and perish, as sad as it sounds. Then how do these superior or inferior traits occur in the first place? The answer lies in random mutations. The children of one parent will not all have identical genes: due to mutation, which occurs by chance, some will acquire even more superior features that puts them far ahead of their peers. Needless to say, such beneficiaries of positive mutation will survive and leave offspring, carrying onto the next generation. Those who experience adversarial mutation, on the other hand, will not be able to survive.

In genetic algorithm engineering, we want to be able to simulate this process over an extended period of time without hard-coding our solution, such that the end result after hundred or thousands of generations will contain the optimal solution. Of course, we can’t let the computer do everything: we still have to implement mutational procedures that define an evolutionary process. But more on that later. First, let’s begin with the simple task of building a way of modeling a population.

Implementation

First, let’s define a class to represent the population. I decided to go with a class-based implementation to attach pieces of information about a specific generation of population to that class object. Specifically, we can have things like bag to represent the full population, parents to represent th chosen, selected superior few, score to store the score of the best chromosome in the population, best to store the best chromosome itself, and adjacency_mat , the adjacency matrix that we will be using to calculate the distance in the context of TSP.

Here is a little snippet of code that we will be using to randomly generate the first generation of population.

Let’s see if this everything works as expected by generating a dummy population.

Now we need some function that will determine the fitness of a chromosome. In the context of TSP, fitness is defined in very simple terms: the shorter the total distance, the fitter and more superior the chromosome. Recall that all the distance information we need is nicely stored in self.adjacency_mat . We can calculate the sum of all the distances between two adjacent cities in the chromosome sequence.

Next, we evaluate the population. Simply put, evaluation amounts to calculating the fitness of each chromosome in the total population, determining who is best, storing the score information, and returning some probability vector whose each element represents the probability that the i th element in the population bag is chosen as a parent. We apply some basic preprocessing to ensure that the worst performing chromosome has absolutely no chance of being selected.

When we call pop.evaluate() , we get a probability vector as expected. From the result, it appears that the last element is the best chromosome; the second chromosome in the population bag is the worst.

When we call pop.best , notice that we get the last element in the population, as previously anticipated.

We can also access the score of the best chromosome. In this case, the distance is said to be 86.25. Note that the lower the score, the better, since these scores represent the total distance a salesman has to travel to visit all the cities.

Now, we will select k number of parents to be the basis of the next generation. Here, we use a simple roulette model, where we compare the value of the probability vector and a random number sampled from a uniform distribution. If the value of the probability vector is higher, the corresponding chromosome is added to self.parents . We repeat this process until we have k parents.

As expected, we get 4 parents after selecting the parents through pop.select() .

Now is the crucial part: mutation. There are different types of mutation schemes we can use for our model. Here, we use a simple swap and crossover mutation. As the name implies, swap simply involves swapping two elements of a chromosome. For instance, if we have [a, b, c] , we might swap the first two elements to end up with [b, a, c] .

The problem with swap mutation, however, is the fact that swapping is a very disruptive process in the context of TSP. Because each chromosome encodes the order in which a salesman has to visit each city, swapping two cities may greatly impact the final fitness score of that mutated chromosome.

Therefore, we also use another form of mutation, known as crossovers. In crossover mutation, we grab two parents. Then, we slice a portion of the chromosome of one parent, and fill the rest of the slots with that of the other parent. When filling the rest of the slots, we need to make sure that there are no duplicates in the chromosome. Let’s take a look at an example. Imagine one parent has [a, b, c, d, e] and the other has [b, a, e, c, d] . Let’s also say that slicing a random portion of the first parent gave us [None, b, c, None, None] . Then, we fill up the rest of the empty indices with the other parent, paying attention to the order in which elements occur. In this case, we would end up with [a, b, c, e, d] . Let’s see how this works.

Now, we wrap the swap and crossover mutation into one nice function to call so that we perform each mutation according to some specified threshold.

Let’s test it on pop . When we call pop.mutate() , we end up with the population bag for the next generation, as expected.

Now it’s finally time to put it all together. For convenience, I’ve added some additional parameters such as print_interval or verbose , but for the most part, a lot of what is being done here should be familiar and straightforward. The gist of it is that we run a simulation of population selection and mutation over n_iter generations. The key part is children = pop.mutate(p_cross, p_mut) and pop = Population(children, pop.adjacency_mat) . Basically, we obtain the children from the mutation and pass it over as the population bag of the next generation in the Population constructor.

Now let’s test it on our TSP example over 20 generations. As generations pass, the fitness score seems to improve, but not by a lot.

Let’s try running this over an extended period of time, namely 100 generations. For clarity, let’s also plot the progress of our genetic algorithm by setting return_history to True .

After something like 30 iterations, it seems like algorithm has converged to the minimum, sitting at around 86.25. Apparently, the best way to travel the cities is to go in the order of [4, 1, 3, 2, 0] .

Example Applications

But this was more of a contrived example. We want to see if this algorithm can scale. So let’s write some functions to generate city coordinates and corresponding adjacency matrices.

generate_cities() generates n_cities number of random city coordinates in the form of a numpy array. Now, we need some functions that will create an adjacency matrix based on the city coordinates.

Let’s perform a quick sanity check to see if make_mat() works as expected. Here, give vertices of a unit square as input to the function. While we’re at it, let’s also make sure that generate_cities() indeed does create city coordinates as expected.

Now, we’re finally ready to use these functions to randomly generate city coordinates and use the genetic algorithm to find the optimal path using genetic_algorithm() with the appropriate parameters. Let’s run the algorithm for a few iterations and plot its history.

We can see that the genetic algorithm does seems to be optimizing the path as we expect, since the distance metric seems to be decreasing throughout the iteration. Now, let’s actually try plotting the path along with the corresponding city coordinates. Here’s a helper function to print the optimal path.

And calling this function, we obtain the following:

At a glance, it’s really difficult to see if this is indeed the optimal path, especially because the city coordinates were generated at random.

I therefore decided to create a much more contrived example, but with many coordinates, so that we can easily verify whether the path decided on by the algorithm is indeed the optimal path. Namely, we will be arranging city coordinates to lie on a semi-circle, using the very familiar equation

Let’s create 100 such fake cities and run the genetic algorithm to optimize the path. If the algorithm does successfully find an optimal path, it will be a single curve from one end of the semi-circle fully connected all the way up to its other end.

The algorithm seems to have converged, but the returned best does not seem to be the optimal path, as it is not a sorted array from 0 to 99 as we expect. Plotting this result, the fact that the algorithm hasn’t quite found the most optimal solution becomes clearer. This point notwithstanding, it is still worth noting that the algorithm has found what might be referred to as optimal segments: notice that there are some segments of the path that contain consecutive numbers, which is what we would expect to see in the optimal path.

An optimal path would look as follows.

Comparing the two, we see that the optimal path returned by the genetic algorithm does contain some wasted traveling routes, namely the the chords between certain non-adjacent cities. Nonetheless, a lot of the adjacent cities are connected (hence the use of the aforementioned term, optimal segments). Considering the fact that there are a total of $100!$ possibilities, the fact that the algorithm was able to narrow it down to a plausible route that beats the baseline is still very interesting.

Genetic algorithms belong to a larger group of algorithms known as randomized algorithms. Prior to learning about genetic algorithms, the word “randomized algorithms” seemed more like a mysterious black box. After all, how can an algorithm find an answer to a problem using pseudo-random number generators, for instance? This post was a great opportunity to think more about this naive question through a concrete example. Moreover, it was also interesting to think about the traveling salesman problem, which is a problem that appears so simple and easy, belying the true level of difficulty under the surface.

There are many other ways to approach TSP, and genetic algorithms are just one of the many approaches we can take. It is also not the most effective way, as iterating over generations and generations can often take a lot of time. The contrived semi-circle example, for instance, took somewhere around five to ten minutes to fully run on my 13-inch MacBook Pro. Nonetheless, I think it is an interesting way well worth the time and effort spent on implementation.

I hope you’ve enjoyed reading this post. Catch you up in the next one!

You May Also Enjoy

16 minute read

August 20 2023

I recently completed another summer internship at Meta (formerly Facebook). I was surprised to learn that one of the intern friends I met was an avid read...

Hacking Word Hunt

7 minute read

August 21 2022

Update: The code was modified with further optimizations. In particular, instead of checking the trie per every DFS call, we update the trie pointer along...

20 minute read

April 11 2022

Note: This blog post was completed as part of Yale’s CPSC 482: Current Topics in Applied Machine Learning.

Reflections and Expectations

5 minute read

December 27 2021

Last year, I wrote a blog post reflecting on the year 2020. Re-reading what I had written then was surprisingly insightful, particularly because I could see ...

Trending Articles on Technical and Non Technical topics

  • Selected Reading
  • UPSC IAS Exams Notes
  • Developer's Best Practices
  • Questions and Answers
  • Effective Resume Writing
  • HR Interview Questions
  • Computer Glossary

Travelling Salesman Problem using Genetic Algorithm

The Travelling Salesman Problem (TSP) finds the shortest path between a collection of cities and the starting point. Due of its combinatorial nature and exponentially increasing number of routes as cities rise, it is a difficult task.The Genetic Algorithm (GA) is a genetically inspired heuristic. Emulating natural selection solves the TSP. The GA uses routes to illustrate prospective city tours.Selection, crossover, and mutation develop the population in the GA. Selection favours pathways with higher fitness, indicating quality or near to the ideal solution. Mutation introduces random modifications to explore new solution spaces, whereas crossover mixes genetic information from parent routes to produce children.

Methods Used

Genetic algorithm.

Natural selection and genetics inspired the strong heuristic Genetic Algorithm (GA). It copies evolution to solve TSP efficiently. Each path in the GA is a possible solution. Fitness determines a route's quality and optimality. The GA develops new populations by selecting, crossing, and mutating routes with higher fitness values.

Define cities, maximum generations, population size, and mutation rate.

Define a city structure with x and y coordinates.

Define a route structure with a vector of city indices (path) and fitness value.

Create a method to determine city distances using coordinates.

Create a random route function by swapping city indices.

Create a function that sums city distances to calculate route fitness.

Create a function to crossover two parent routes to create a child route.

Mutate a route by exchanging cities with a mutation rate−based function.

Implement a fitness−based route finding tool.

Finally, the Genetic Algorithm (GA) solves the Travelling Salesman Problem (TSP) and other combinatorial optimisation issues. The GA iteratively searches a wide search space of viable solutions, improving route fitness and arriving on a good solution using genetics and evolution concepts.Exploration and exploitation balance the GA's TSP management. The GA promotes better pathways and preserves population variety through selection, crossover, and mutation. The GA can effectively search the solution space and avoid local optima.

Ayush Singh

Related Articles

  • Travelling Salesman Problem
  • Travelling Salesman Problem (TSP) Using Reduced Matrix Method
  • Proof that travelling salesman problem is NP Hard
  • C++ Program to Solve Travelling Salesman Problem for Unweighted Graph
  • C++ Program to Implement Traveling Salesman Problem using Nearest Neighbour Algorithm
  • Python Program to solve Maximum Subarray Problem using Kadane’s Algorithm
  • What is a Simple Genetic Algorithm (SGA) in Machine Learning?
  • Solution for array reverse algorithm problem JavaScript
  • The algorithm problem - Backtracing pattern in JavaScript
  • How to Explain Steady State Genetic Algorithm (SSGA) in Machine Learning?
  • Mutation Genetic Change
  • Producer Consumer Problem using Semaphores
  • Combination sum problem using JavaScript
  • Travelling Wave
  • Lock & Key problem using Hash-map

Kickstart Your Career

Get certified by completing the course

Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications

A Solution to the Travelling Salesman Problem using Genetic Algorithms

andretri/tsp-genetic-algorithm

Folders and files, repository files navigation, solving the travelling salesman problem (tsp) using genetic algorithms, an introduction to the problem, the genetic algorithm, algorithm convergence, code implementation, graph class, genetic algorithm class, code execution.

The Travelling Salesman Problem (TSP) is finding the minimal path that traverses though all cities so that a salesman can travel with the minimal cost. The solution to this - classic in algorithms - problem can be achieved with many different approaches ( Greedy and Brute Force to name a few) but all these have one common drawback: The Search Space of the Problem itself!

For example, given a weighted graph G with |V| vertices and |E| edges, finding the minimal route that traverses though all vertices of the graph is equivalent to finding all possible permutations of the graph's vertices and taking the path with the minimum cost, that is factorial(|V|) = |V|!.

In other words these types of algorithms can't be used to solve the TSP because they find the solution in exponential time, unfeasible in real-life tasks.

That's where the Genetic Algorithms are used, to provide approximately optimal solutions in feasible time.

The Genetic Algorithm is a Possibilistic Algorithm inspired by the Darwinean Theory of Evolution . It searches through the space of possible solutions so as to find acceptable - according to some criteria - solutions.

To use a Genetic Algorithm to a Problem, one must define:

In this problem the population is a list of strings (genomes) that each letter (allele) is a vertex of the given graph.

Example: For a Graph with vertices V = {a,b,c,d,e}, an allele is any of the elements in V, a genome is any permutation of the elements in V and a population is a list of N genomes.

Fitness Function

It's the measure used to compare genomes to each other. For this problem a fitness function (and the one we use in this implementation) is the sum of the edge's weights through the graph for a certain path - encoded in the genome.

Each generation must have N genomes at a time. To achieve evolution we select some at the genomes to Crossover them and produce Offsprings that will be part of the new population. To select them there are many techniques, two of which are:

  • Roulette Selection:
  • Tournament Selection:

Now that we have our parent genomes from the Selection procedure, now we crossover them to produce - potentially - fitter offsprings.

There are many options and techniques that the Crossover may be done, but the one that we use in our implementation is the following:

After making the offsprings of the next generation, to finalize the creation of the new population we must mutate the genomes.

To mutate a genome we just select two random alleles and swap them in a genome

Note: the mutation does not occur always. It occurs with a user-defined probability.

In Genetic Algorithms sometimes the fittest genomes from the current generation are passed directly to the next, contesting with the offsprings and crossover to - potentially - fitter solutions.

This step occurs during the calculation of the Fitness function value for each genome. When all values are computed the genome with the minimum value is appended directly to the next generation's population.

The Algorithm stops if:

  • All genomes in the population are the same or
  • Reached the max. Generation limit

These cases indicate that the algorithm has converged to a minima (global or local) .

Note: To make the algorithm more consistent it is recommended to have a sufficient large population and mutation rate.

Warning : Setting the mutation rate too high increases the probability of searching more areas in search space, however, prevents population to converge to any optimum solution. [Source] Likewise setting the elititsm rate too high decreases the probability of searching more areas in search space, leading the population to converge faster to a solution but - potentially - preventing it from reaching any optimum.

The Code makes use of two Classes:

This Class is responsible for:

  • Creating a graph
  • Setting Vertices and Edges
  • Getting Vertices and Edges
  • Computing the Cost from a Vertex to another given a path

The Functions that make the above possible are:

graph: The Graph Dictionary {'vertex':{'adjacent': edge_weight}}
  • setVertex (self, vertex)
  • setAdjacent (self, vertex, adj, weight=0)
  • getVertices (self)
  • getAdjacent (self, vertex)
  • getPathCost (self, path)
  • Initiating a Genetic Algorithm with Certain Parameters
  • Running the Evolution Cycle for self.generations Generations and returning the best path along with its travel cost.

The functions that make this possible are:

  • __init__ (self, generations=100, population_size=10, tournamentSize=4, mutationRate=0.1, elitismRate=0.1)
Note: the referenced scripts were tested with Python 3.5.4 via Anaconda3.

To execute the genetic algorithm for TSP write in Terminal:

Note: to initiate the TSP for another graph, please change the code @__main__ function inside the GeneticAlgorithmTSP.py script.
  • Python 100.0%

Advertisement

Advertisement

Genetic algorithms for the travelling salesman problem: a crossover comparison

  • Original Research
  • Published: 02 November 2019
  • Volume 12 , pages 209–213, ( 2020 )

Cite this article

travelling salesman problem genetic algorithm

  • Tariq Alzyadat 1 ,
  • Mohammad Yamin   ORCID: orcid.org/0000-0002-3778-3366 2 &
  • Girija Chetty 1  

752 Accesses

7 Citations

Explore all metrics

This paper addresses an application of genetic algorithms (GA) for solving the travelling salesman problem (TSP), it compares the results of implementing two different types of two-point (1 order) genes crossover, the static and the dynamic approaches, which are used to produce new offspring. By changing three factors; the number of cities, the number of generations and the population size, the goal is to show which approach is better in terms of finding the optimal solution (the shortest path) in as short time as possible as a result of these changes. Besides, it will explore the effect of changing the above factors on finding the optimal solution.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price includes VAT (Russian Federation)

Instant access to the full article PDF.

Rent this article via DeepDyve

Institutional subscriptions

travelling salesman problem genetic algorithm

Similar content being viewed by others

travelling salesman problem genetic algorithm

A review on genetic algorithm: past, present, and future

travelling salesman problem genetic algorithm

Multi-objective Geometric Mean Optimizer (MOGMO): A Novel Metaphor-Free Population-Based Math-Inspired Multi-objective Algorithm

travelling salesman problem genetic algorithm

An exhaustive review of the metaheuristic algorithms for search and optimization: taxonomy, applications, and open challenges

Abbreviations.

Analysis of variance

The cycle crossover

Edge recombination crossover

  • Genetic algorithms

Generalized N-point crossover

Nondeterministic polynomial time problem

Sequential constructive crossover

  • Travelling salesman problem

Laporte G (1992) The traveling salesman problem: an overview of exact and approximate algorithms. Eur J Oper Res 59:231–247

Article   MathSciNet   Google Scholar  

Holland JH (1992) Adaptation in natural and artificial systems: an introductory analysis with applications to biology, control and artificial intelligence. MIT Press, Cambridge

Book   Google Scholar  

Goldberg DE (1989) Genetic algorithms in search, optimization and machine learning. Addison-Wesley Longman Publishing Co., Inc, Boston

MATH   Google Scholar  

Biggs N, Lloyd EK, Wilson RJ (1986) Graph theory, 1736–1936. Clarendon Press, Oxford

K. Bryant and A. Benjamin, “Genetic Algorithms and the Traveling Salesman Problem Genetic Algorithms and the Traveling Salesman Problem Acknowledgments,” 2000

Moscato P (1989) On genetic crossover operators for relative order preservation. Caltech Concurrent Computation Program, Report C3P-7781989

Syswerda G (1989) Uniform crossover in genetic algorithms. In: Presented at the proceedings of the 3rd international conference on genetic algorithms, pp 2–9

Jaafar O (2011) A comparative study of adaptive crossover operators for genetic algorithms to resolve the traveling salesman problem. Int J Comput Appl 31:49–57

Google Scholar  

Oliver IM, Smith DJ, Holland JRC (1987) A study of permutation crossover operators on the traveling salesman problem. In: Presented at the proceedings of the second international conference on genetic algorithms on genetic algorithms and their application, Cambridge, Massachusetts, USA, 1987

Ahmed ZH (2010) Genetic algorithm for the traveling salesman problem using sequential constructive crossover operator. Int J Biometr Bioinform (IJBB) 3:96–105

Groba C, Sartal A, Vázquez XH (2015) Solving the dynamic traveling salesman problem using a genetic algorithm with trajectory prediction: an application to fish aggregating devices. Comput Oper Res 56:22–32

Wang LY, Zhang J, Li H (2007) An improved genetic algorithm for TSP. In: 2007 International conference on machine learning and cybernetics. IEEE, Hong Kong, China. https://doi.org/10.1109/ICMLC.2007.4370274

Baker JE (1987) Reducing bias and inefficiency in the selection algorithm. In: Presented at the proceedings of the second international conference on genetic algorithms on genetic algorithms and their application, Cambridge, Massachusetts, USA, 1987

Salam RAZA (2014) Travelling salesman problem using dynamic approach. Int J Comput Appl 94:20–23

Whitley D (1994) A genetic algorithm tutorial. Stat Comput 4:65–85

Article   Google Scholar  

Kumar KRV (2014) Solving travelling salesman problem using genetic algorithm based on heuristic crossover and mutation operator. Int J Res Eng Technol 2:27–34

Download references

Acknowledgements

We thank the Statistical consultant Mr. Julio Romero for his assistance in the statistical analysis of the data in this experiment.

Author information

Authors and affiliations.

University of Canberra, Canberra, Australia

Tariq Alzyadat & Girija Chetty

Faculty of Economics and Administration, King Abdulaziz University, Jeddah, Saudi Arabia

Mohammad Yamin

You can also search for this author in PubMed   Google Scholar

Corresponding author

Correspondence to Mohammad Yamin .

Rights and permissions

Reprints and permissions

About this article

Alzyadat, T., Yamin, M. & Chetty, G. Genetic algorithms for the travelling salesman problem: a crossover comparison. Int. j. inf. tecnol. 12 , 209–213 (2020). https://doi.org/10.1007/s41870-019-00377-9

Download citation

Received : 20 July 2019

Accepted : 23 October 2019

Published : 02 November 2019

Issue Date : March 2020

DOI : https://doi.org/10.1007/s41870-019-00377-9

Share this article

Anyone you share the following link with will be able to read this content:

Sorry, a shareable link is not currently available for this article.

Provided by the Springer Nature SharedIt content-sharing initiative

  • Dynamic crossover
  • Permutation
  • Static crossover
  • Find a journal
  • Publish with us
  • Track your research

A Study of Solving Traveling Salesman Problem with Genetic Algorithm

Ieee account.

  • Change Username/Password
  • Update Address

Purchase Details

  • Payment Options
  • Order History
  • View Purchased Documents

Profile Information

  • Communications Preferences
  • Profession and Education
  • Technical Interests
  • US & Canada: +1 800 678 4333
  • Worldwide: +1 732 981 0060
  • Contact & Support
  • About IEEE Xplore
  • Accessibility
  • Terms of Use
  • Nondiscrimination Policy
  • Privacy & Opting Out of Cookies

A not-for-profit organization, IEEE is the world's largest technical professional organization dedicated to advancing technology for the benefit of humanity. © Copyright 2024 IEEE - All rights reserved. Use of this web site signifies your agreement to the terms and conditions.

Paper Information

  • Paper Submission

Journal Information

  • About This Journal
  • Editorial Board
  • Current Issue
  • Author Guidelines

Electrical and Electronic Engineering

p-ISSN: 2162-9455    e-ISSN: 2162-8459

2020;  10(2): 27-31

doi:10.5923/j.eee.20201002.02

Received: Nov. 28, 2020; Accepted: Dec. 20, 2020; Published: Dec. 28, 2020

Solving Traveling Salesman Problem by Using Genetic Algorithm

Ripon Sorma 1 , Md. Abdul Wadud 1 , S. M. Rezaul Karim 1 , F. A. Sabbir Ahamed 2

1 Department of EEE, International University of Business Agriculture and Technology, Uttara Dhaka, Bangladesh

2 Department of Physics, International University of Business Agriculture and Technology, Uttara Dhaka, Bangladesh

Copyright © 2020 The Author(s). Published by Scientific & Academic Publishing.

This analysis investigated the appliance of the Genetic algorithmic rule capable of finding the representative drawback. Genetic Algorithms square measure able to generate in turn shorter possible tours by victimization info accumulated among the type of a secretion path deposited on the perimeters of the representative drawback graph. pc Simulations demonstrate that the Genetic algorithmic rule is capable of generating batter solutions to each bilaterally symmetric and uneven instances of the representative drawback. the tactic is Associate in Nursing example, like simulated tempering Associate in Nursing organic process computation of the productive use of a natural figure to vogue an optimization algorithmic rule. A study of the genetic algorithmic rule explains its performance and shows that it's about to be seen as a parallel variation of tabu search, with implicit memory. The genetic algorithmic rule is that the best in machine time however least economical in memory consumption. The Genetic algorithmic rule differs from the nearest neighborhood heuristic in that it considers the closest route of the neigh-boyhood heuristic considers the closest path. The Genetic algorithmic rule needs a system with parallel design and its optimum implementation. The activities of every genetic algorithmic rule ought to be run as a separate OS method.

Keywords: Genetic Algorithm, Fuzzy system, Machine learning, Applying Genetic Algorithm, Mat Lab work

Cite this paper: Ripon Sorma, Md. Abdul Wadud, S. M. Rezaul Karim, F. A. Sabbir Ahamed, Solving Traveling Salesman Problem by Using Genetic Algorithm, Electrical and Electronic Engineering , Vol. 10 No. 2, 2020, pp. 27-31. doi: 10.5923/j.eee.20201002.02.

Article Outline

1. introduction, 2. genetic algorithm, 2.1. control parameters, 2.2. fuzzy system, 2.3. neural network, 2.4. machine learning, 3. literatures review, 4. research methodology, 5. result and discussion, 6. conclusions.

IMAGES

  1. Tutorial : Introduction to Genetic Algorithm n application on Traveling Sales Man Problem (TSP)

    travelling salesman problem genetic algorithm

  2. Using a Genetic Algorithm for Traveling Salesman Problem in Python

    travelling salesman problem genetic algorithm

  3. Three different methods to solve the travelling salesman problem

    travelling salesman problem genetic algorithm

  4. Genetic Algorithm with Python

    travelling salesman problem genetic algorithm

  5. Traveling Salesman Problem (TSP) with Miller-Tucker-Zemlin (MTZ) in

    travelling salesman problem genetic algorithm

  6. Travelling Salesman Problem done with Genetic Algorithm

    travelling salesman problem genetic algorithm

VIDEO

  1. Genetic Algorithm for TSP

  2. What Is The Traveling Salesman Problem

  3. Traveling Salesmen Problem using ACO , GA, NN Algorithm

  4. Genetic Algorithm VS Travelling Salesman Problems

  5. Optimizing Routes: Solving the Traveling Salesman Problem with Approximation Algorithms

  6. Shortest Path Finder

COMMENTS

  1. Traveling Salesman Problem using Genetic Algorithm

    AuPrerequisites: Genetic Algorithm, Travelling Salesman Problem In this article, a genetic algorithm is proposed to solve the travelling salesman problem. Genetic algorithms are heuristic search algorithms inspired by the process that supports the evolution of life. The algorithm is designed to replicate the natural selection process to carry generation, i.e. survival of the fittest of beings.

  2. Traveling Salesman Problem with Genetic Algorithms

    The traveling salesman problem (TSP) is a famous problem in computer science. The problem might be summarized as follows: imagine you are a salesperson who needs to visit some number of cities. Because you want to minimize costs spent on traveling (or maybe you're just lazy like I am), you want to find out the most efficient route, one that will require the least amount of traveling. You are ...

  3. Traveling Salesman Problem (TSP) using Genetic Algorithm (Python)

    In conclusion, the application of genetic algorithms to solve the Traveling Salesman Problem (TSP) has proven to be a powerful and flexible approach. The algorithm operates by mimicking the ...

  4. Evolution of a salesman: A complete genetic algorithm tutorial for

    Drawing inspiration from natural selection, genetic algorithms (GA) are a fascinating approach to solving search and optimization problems. While much has been written about GA (see: here and here), little has been done to show a step-by-step implementation of a GA in Python for more sophisticated problems.That's where this tutorial comes in!

  5. Traveling salesman problem. Find the shortest route using a genetic

    The so called traveling salesman problem is a very well known challenge. The task is to find the shortest overall route between many destinations: saleswoman visits several stores in succession and returns to the starting point in the overall shortest distance at the end. ... We are going to implement a genetic algorithm to solve this problem ...

  6. Travelling Salesman Problem using Genetic Algorithm

    The Travelling Salesman Problem (TSP) finds the shortest path between a collection of cities and the starting point. Due of its combinatorial nature and exponentially increasing number of routes as cities rise, it is a difficult task.The Genetic Algorithm (GA) is a genetically inspired heuristic. Emulating natural selection solves the TSP.

  7. Genetic algorithms for the travelling salesman problem: a crossover

    This paper addresses an application of genetic algorithms (GA) for solving the travelling salesman problem (TSP), it compares the results of implementing two different types of two-point (1 order) genes crossover, the static and the dynamic approaches, which are used to produce new offspring. By changing three factors; the number of cities, the number of generations and the population size ...

  8. PDF An Efficient Genetic Algorithm for the Traveling Salesman Problem

    Keywords: traveling salesman problem; genetic algorithm; Inver-over operator based on distance neighbor tabulation; differing operator. 1 Introduction 1.1 Traveling Salesman Problem The Traveling Salesman Problem (TSP) is a typical representative of combinatorial optimization problem, in which the salesman wants to minimize the total distance

  9. Genetic algorithm for Traveling Salesman Problem

    A new crossover technique to improve genetic algorithm and its application to TSP. 2019 International Conference on Electrical, Computer and Communication Engineering (ECCE), IEEE. Google Scholar Cross Ref; Alhanjouri, M. A. and B. Alfarra (2013). "Ant colony versus genetic algorithm based on travelling salesman problem." Int. J. Comput. Tech.

  10. PDF A Powerful Genetic Algorithm for Traveling Salesman Problem

    An intermediate solution consists of one or more loops. Step 5. Generate an o spring solution by connecting all loops into one loop . Step 6. If a further o spring solution is generated, then go to Step 3. Otherwise, terminate the procedure. A Powerful Genetic Algorithm for Traveling Salesman Problem Figure 1.

  11. Optimization of Saleman Travelling Problem Using Genetic Algorithm with

    Traveling salesman problem (TSP) is a problem of determining the shortest path for a salesman to take to visit all cities. Although a small number of cities is easy to solve, as the number of cities increases, it's not possible to solve in polynomial time as it was a combinatorial nondeterministic polynomial (NP-hard) problem. Hence, this project is implementing a genetic algorithm (GA) to ...

  12. Genetic Algorithms for the Travelling Salesman Problem: A Review of

    This paper is the result of a literature study carried out by the authors. It is a review of the different attempts made to solve the Travelling Salesman Problem with Genetic Algorithms. We present crossover and mutation operators, developed to tackle the Travelling Salesman Problem with Genetic Algorithms with different representations such as: binary representation, path representation ...

  13. Solving the dynamic traveling salesman problem using a genetic

    1. Introduction. The Traveling Salesman Problem (TSP) probably represents the most intensive area of research within the wide range of combinatorial optimization problems [20], [24].Whereas the diverse perspectives and problem-solving methods have helped practitioners and scholars to address a multitude of different problems in different industries [21], [33], [14], [13], the literature on TSP ...

  14. Travelling Salesman Problem using Genetic Algorithm

    A strategy to find the nearly optimized solution to these type of problems, using new crossover technique for genetic algorithm that generates high quality solution to the TSP is presented. This paper includes a flexible method for solving the travelling salesman problem using genetic algorithm. In this problem TSP is used as a domain.TSP has long been known to be NP-complete and standard ...

  15. A parallel ensemble genetic algorithm for the traveling salesman problem

    A parallel ensemble of Genetic Algorithms for the Traveling Salesman Problem (TSP) is proposed. Different TSP solvers perform efficiently on different instance types. ... and Bryce D. Eldridge. 2005. A Study of Five Parallel Approaches to a Genetic Algorithm for the Traveling Salesman Problem. Intell. Autom. Soft Comput. 11 (2005), 217--234 ...

  16. PDF Solving Traveling Salesman Problem Using Genetic Algorithm Based on

    The Traveling Salesman Problem (TSP) is a Combinatorial Optimization Problem (COP), which belongs to NP-hard problems and is considered a typical problem for many real-world applications. Many researchers used the Genetic Algorithm (GA) for solving the TSP. However, using a suitable mutation was one of the main obstacles for GA.

  17. Solving the Travelling Salesman Problem (TSP) Using Genetic Algorithms

    The Travelling Salesman Problem (TSP) is finding the minimal path that traverses though all cities so that a salesman can travel with the minimal cost. The solution to this - classic in algorithms - problem can be achieved with many different approaches (Greedy and Brute Force to name a few) but all these have one common drawback: The Search Space of the Problem itself!

  18. PDF Genetic algorithms for the travelling salesman problem: a crossover

    Abstract This paper addresses an application of genetic algorithms (GA) for solving the travelling salesman prob-lem (TSP), it compares the results of implementing two different types of two-point (1 order) genes crossover, the static and the dynamic approaches, which are used to produce new offspring. By changing three factors; the number of ...

  19. A Study of Solving Traveling Salesman Problem with Genetic Algorithm

    Travelling salesman problem is one of the most important problems in the optimization area. To solve the problem of traveling salesman, the GA (genetic algorithm) can be seen as an appropriate method. In the genetic algorithm, there are many parameters needing to be set in advance. To figure out the effects of parameters in GA, we conducted experiments with different parameters and compared ...

  20. Genetic algorithm to the bi-objective multiple travelling salesman problem

    Chen and Chen [17] propose a genetic algorithm in which a two-part chromosome encoding strategy is employed in mutation and recombination operators, giving the solution of the MTSP. This two-part chromosome encoding takes care of the ordering of cities and the number of cities to be visited by each salesman.

  21. Python: Genetic Algorithms and the Traveling Salesman Problem

    There are very few tasks that can't be coerced into classification or regression problems. But let's shift gears today and discuss some of those problems. Two high impact problems in OR include the "traveling salesman problem" and the "vehicle routing problem.". The latter is much more tricky, involves a time component and often ...

  22. Travelling Salesman Problem using Genetic Algorithm

    Here we will be solving this problem using a genetic algorithm in python. It's kind of basic implementation of genetic algorithm. The first task to import libraries. x=int(random.random() * 200 ...

  23. Solving Traveling Salesman Problem by Using Genetic Algorithm

    The genetic algorithmic rule is employed for the aim of improving the answer house. The crossover is that the necessary stage within the genetic algorithm. Naveen (2012) have done the survey on the traveling salesman downside using varied genetic algorithmic rule operators. The projected work solves the motion salesman downside exploitation ...