traveling-salesman

TSP Where Vertices Can be Visited Multiple Times

烂漫一生 提交于 2019-12-14 02:14:49
问题 I am looking to solve a problem where I have a weighted directed graph and I must start at the origin, visit all vertices at least once and return to the origin in the shortest path possible. Essentially this would be a classic example of TSP, except I DO NOT have the constraint that each vertex can only be visited once. In my case any vertex excluding the origin can be visited any number of times along the path, if this makes the path shorter. So for example in a graph containing the

Generate all neighbors for 2OPT in python

不羁的心 提交于 2019-12-13 19:30:28
问题 I am trying to implement to the 2opt optimization algorithm for the undirected Traveling Salesman Problem. For given cities: cities = [[ 72.06557466, 5.73765812], [ 94.50272578, 68.95162393], [ 58.53952609, 15.12518299], [ 94.64599891, 34.65906808], [ 62.42311036, 45.8430048 ], [ 24.73697454, 4.4159545 ], [ 15.71071819, 81.27575127], [ 65.65743227, 54.90239983], [ 5.07828178, 47.34845887], [ 88.98592652, 48.14959719]] My understanding for the general algorithm is that starting from a random

Tile Trial NP-hard complexity

核能气质少年 提交于 2019-12-12 02:48:54
问题 In the game Final Fantasy XIII-3, the player is presented with a couple puzzles. The first puzzle introduced is called Tile Trial , which presents the player with a grid of tiles, some of which have crystals on them. The goal is to retrieve all of the crystals and reach the exit, while stepping on each tile no more than once. The author of http://arxiv.org/pdf/1203.1633v1.pdf stated that this problem is NP-Hard because a specific case can be reduced to Hamiltonian-cycle. I find that this is a

Find the shortest path between a given source and a set of destinations

a 夏天 提交于 2019-12-11 02:20:39
问题 You are given a weighted connected graph (20 nodes) with all edges having positive weight. We have a robot that starts at point A and it must pass at points B, D and E for example. The idea is to find the shortest path that connects all these 4 points. The robot also has a limited battery, but it can be recharged in some points. After researching on the internet I have two algorithms in mind: Dijkstra's and TSP . Dijkstra's will find the shortest path between a node and every other node and

TSP, algorithm gets stuck in local minimum

旧街凉风 提交于 2019-12-10 10:09:53
问题 I am struggling to implement a program based on simulated annealing to solve the traveling salesman problem. All solutions I got are not satisfying and i have no clue how to improve my implementation. Obviously I'm not focusing on benchmarks, but only on finding the visually acceptable shortest path. If anyone might enlighten me I would be thankful. # weight function, simple euclidean norm def road(X,Y): sum = 0 size = len(X) -1 for i in range(0,size): sum +=math.sqrt((X[i]-X[i+1])**2 + (Y[i]

How to fix the start and end points in Travelling Salesmen Problem?

天大地大妈咪最大 提交于 2019-12-10 02:41:53
问题 I have a solver that solves normal symmetric TSP problems. The solution means the shortest path via all the nodes with no restriction on which nodes are the first and the last ones in the path. Is there a way to transform the problem so that a specific node can be ensured as the start node, and another node as the end node? One way would be to add an I - a very large distance - to all distances between these start/end nodes and all the others (adding I twice to the distance between start and

Simplified Travelling Salesman in Prolog

大憨熊 提交于 2019-12-10 02:33:59
问题 I've looked through the similar questions but can't find anything that's relevant to my problem. I'm struggling to find an algorithm or set of 'loops' that will find a path from CityA to CityB , using a database of distance(City1,City2,Distance) facts. What I've managed to do so far is below, but it always backtracks at write(X), and then completes with the final iteration, which is what I want it to do but only to a certain extent. For example, I don't want it to print out any city names

Find shortest path from X,Y coordinates (with start ≠ end)

蹲街弑〆低调 提交于 2019-12-08 18:24:35
I have a dataframe with X and Y coordinates of points like this: structure(list(X = c(666L, 779L, 176L, 272L, 232L, 74L, 928L, 667L, 1126L, 919L), Y = c(807, 518, 724, 221, 182, 807, 604, 384, 142, 728)), .Names = c("X", "Y"), row.names = c(NA, 10L), class = "data.frame") I just want to find out the shortest path connecting all these points, and also return its total distance. There are no other conditions: every point can be connected to any other, no specific point to start or end, no weights, etc... I found lots of topics about igraph package but i can't figure out how to feed my data into

Implementation of a particular Travelling-Salesman variation

房东的猫 提交于 2019-12-08 04:42:51
问题 I'm looking for an algorithm(C/C++/Java - doesn't matter) which will resolve a problem which consists of finding the shortest path between 2 nodes (A and B) of a graph. The catch is that the path must visit certain other given nodes(cities). A city can be visited more than once. Example of path( A -H-D-C-E- F - G - F - B ) (where A is source, B is destination, F and G are cities which must be visited). I see this as a variation of the Traveling Salesman Problem but I couldn't find or write a

Travelling Salesman Problem

两盒软妹~` 提交于 2019-12-07 21:39:46
问题 I am trying to develop a program in C++ from Travelling Salesman Problem Algorithm. I need a distance matrix and a cost matrix. After using all the formulas, i get a new resultant matrix. But I dont understand what that matrix shows. Suppose the resultant matrix is: 1 2 3 4 5 6 7 8 9 Now I want to know what this matrix shows? Assume I have 3 cities to traverse. Please tell me the flow. A sample program of this algorithm will be more favorable.. Thank you. My Program is: #include<iostream.h>