traveling-salesman

Traveling salesman example with known global optimum

六月ゝ 毕业季﹏ 提交于 2019-12-05 06:03:05
I made a memetic algorithm in Python for traveling salesman problem . However, all the test data (list of distances between cities) I've encountered lack the information of the best solution, so I can't know how close to global optimum my algorithm gets. Does anyone know where I can find some tsp test data (preferably in matrix form, but anything's good) with known best solution? Did you google? http://www.tsp.gatech.edu/data/index.html That page provides several test-cases of which 16 has an optimal solution. Perhaps you can generate your own test data? This definitely won't be comprehensive

Travelling Salesman with Google Maps API or any other

你。 提交于 2019-12-05 00:45:25
问题 I have a list of addresses and need to find the best route that reaches every address and goes back to the start With Google Maps API it is possible to calculate this with 8 waypoints I think but 8 isn't enough for my purposes. Is there someone out there who offers route optimization with more than 8 waypoints? I mean there must be, right? This is a problem that many organisations need a solution to. It is no problem at all if it costs a lot of money, the calculations are very heavy so I

Java: Traveling Salesman - Found polynomial algorithm

非 Y 不嫁゛ 提交于 2019-12-04 22:11:28
Edit : An improvement to this algorithm been found. Your are welcome to see it. This question is the an improvement of my old question. Now I want to show you Java code sample , and explain my algorithm in more details. I think that I found a polynomial algorithm to get an exact solution to the Traveling Salesman Problem. My implementation is build from 5 steps: 1) Quick setup 2) Search for solution 3) Stop condition 1 4) Stop condition 2 5) Stop condition 3 I want to start from step 2 and 3, and if I do not get wrong there I will show you the rest of it. So what I am going to show you now, is

Neo4J - Traveling Salesman

為{幸葍}努か 提交于 2019-12-04 18:55:20
I'm trying to solve an augmented TSP problem using a graph database, but I'm struggling. I'm great with SQL, but am a total noob on cypher. I've created a simple graph with cities (nodes) and flights (relationships). THE SETUP: Travel to 8 different cities (1 city per week, no duplicates) with the lowest total flight cost. I'm trying to solve an optimal path to minimize the cost of the flights, which changes each week. Here is a file on pastebin containing my nodes & relationships. Just run it against Neo4JShell to insert the data. I started off using this article as a basis but it doesn't

How to turn TSP into minimum hamiltonian path?

有些话、适合烂在心里 提交于 2019-12-04 16:50:32
I'm trying to solve this problem http://coj.uci.cu/24h/problem.xhtml?abb=1368 . After a lot of research, and spending a lot of time i was able to implement a Branch and Bound algorithm for TSP, which gets a path passing all points and returning to start. I was thinking that removing the longest edge from that path i would get the answer, but just when i finished my algorithm, i discovered that this isn't true in all cases, reading this question: Minimal Distance Hamiltonian Path Javascript I've found some answers saying that adding a dummy point with zero distance to every other point, and

Palmer's Algorithm for Hamiltonian cycles

时光总嘲笑我的痴心妄想 提交于 2019-12-04 13:31:10
In a "dense" graph, I am trying to construct a Hamiltonian cycle using Palmer's Algorithm . However, I need more explanation for this algorithm because it does not work with me when I implement it. It seems that there is an unclear part in Wikipedia's explanation. I would be thankful if someone explains it more clearly or give me some links to read. Here's the algorithm statement: Palmer (1997) describes the following simple algorithm for constructing a Hamiltonian cycle in a graph meeting Ore's condition. Arrange the vertices arbitrarily into a cycle, ignoring adjacencies in the graph. While

How to implement a dynamic programming algorithms to TSP in Python?

吃可爱长大的小学妹 提交于 2019-12-04 10:10:17
I want to solve the TSP problem using a dynamic programming algorithm in Python.The problem is: Input: cities represented as a list of points. For example, [(1,2), (0.3, 4.5), (9, 3)...]. The distance between cities is defined as the Euclidean distance. Output: the minimum cost of a traveling salesman tour for this instance, rounded down to the nearest integer. And the pseudo-code is: Let A = 2-D array, indexed by subsets of {1, 2, ,3, ..., n} that contains 1 and destinations j belongs to {1, 2, 3,...n} 1. Base case: 2. if S = {0}, then A[S, 1] = 0; 3. else, A[S, 1] = Infinity. 4.for m = 2, 3,

Why does adding Crossover to my Genetic Algorithm gives me worse results?

泪湿孤枕 提交于 2019-12-04 02:12:46
I have implemented a Genetic Algorithm to solve the Traveling Salesman Problem (TSP). When I use only mutation, I find better solutions than when I add in crossover. I know that normal crossover methods do not work for TSP, so I implemented both the Ordered Crossover and the PMX Crossover methods, and both suffer from bad results. Here are the other parameters I'm using: Mutation : Single Swap Mutation or Inverted Subsequence Mutation ( as described by Tiendil here ) with mutation rates tested between 1% and 25%. Selection : Roulette Wheel Selection Fitness function : 1 / distance of tour

What is a practical solution to the Travelling Salesman prblem, using Google Maps?

强颜欢笑 提交于 2019-12-03 20:07:16
问题 What is a practical solution to the Travelling Salesman problem, using Google Maps / geolocation / route finding? I don't need the best solution, within 5% would be fine. For example, I have 20 locations in the UK to visit, in any order. This may need to scale to hundreds of locations. What sort of algorithm can I use, given that I can lookup distances (but don't want to lookup hundreds of distances)? 回答1: I you are looking for a polynomial approximation for the Euclidean TSP, several

Travelling Salesman in scipy

感情迁移 提交于 2019-12-03 17:48:01
问题 How do I solve a Travelling Salesman problem in python? I did not find any library, there should be a way using scipy functions for optimization or other libraries. My hacky-extremelly-lazy-pythonic bruteforcing solution is: tsp_solution = min( (sum( Dist[i] for i in izip(per, per[1:])), n, per) for n, per in enumerate(i for i in permutations(xrange(Dist.shape[0]), Dist.shape[0])) )[2] where Dist (numpy.array) is the distance matrix. If Dist is too big this will take forever. Suggestions? 回答1