Questions tagged [traveling-salesman]

The "traveling salesman problem" is a classical computer science problem which involves finding the shortest path which could be taken by a hypothetical salesman to make a single visit to each location on a map (in a graph).

The traveling salesman problem (often referred to by its initials: TSP) is one of the most well known "hard" (NP-complete) problems in classical computer science. Simply stated, it involves finding the shortest path which could be taken by a hypothetical salesman to make a single visit to each location on a map (in a graph).

732 questions
0
votes
1 answer

Christofides TSP; let start and end node be those that are the farthest apart

I'm using Christofides algorithm to calculate a solution for a Traveling Salesman Problem. The implementation is the one integrated in networkx library for Python. The algorithm accepts an undirected networkx graph and returns a list of nodes in the…
Hendrik Wiese
  • 2,010
  • 3
  • 22
  • 49
0
votes
0 answers

Python IndexError in my Nearest Neighbour Algorithm for TSP

I am trying to solve TSP using the nearest algorithm, but I got stuck at the IndexError: boolean index did not match indexed array along dimension 0; dimension is 1 but corresponding boolean dimension is 38. For my algorithm I'm using a distance…
iri
  • 21
  • 1
  • 5
0
votes
0 answers

Implementation cuckoo search algorithm (TSPLIB, python

I am implementing an improved cuckoo search algorithm for research (link below). This algorithm should work very very well, however my implementation is approximately 1.5 times of the optimal on the test TSPLIB 'eil51.txt' while it should be close…
0
votes
1 answer

Python and Pandas - Distances with latitude and longitude

I am trying compare distances between points (in this case fake people) in longitudes and latitudes. I can import the data, then convert the lat and long data to radians and get the following output with pandas: lat long name…
Milo
  • 33
  • 5
0
votes
0 answers

How can I write a heuristics function for a tsp problem?

I am running a graph search(with different types of search like ucs, bfs, dfs, greedy, and a*) on a tsp problem, I am however running into an issue with greedy and a* search because I am stuck with identifying the heuristics function. I have my…
0
votes
0 answers

Is it possible to show edges in the front layer of a multigraph based on colour since edges are overlapping?

I have a complete graph G of 214 nodes and therefore a looot of edges. In this graph I have a subset of edges that are coloured red, however almost all edges are overlapped by other edges and therefore the route is not visible. Is it possible to get…
kGame
  • 21
  • 3
0
votes
0 answers

Define start point for TSP using mlrose

I followed a tutorial on how to use mlrose for TSP. The tutorial didn't cover on how can I define the start point (and also end point of the optimized route). How can I do it (if I can do it). I'll link what I got so far. This is the code I…
JM Aido
  • 13
  • 2
0
votes
0 answers

Solving Dynamic Programming for Travelling Salesman Problem - Java

I want to implement a dynamic programming solution for travelling salesman problem. I have managed to solve it with the code below: `package tsp; import java.util.Arrays; import java.util.Collections; public class TSP { static int l ; public static…
Jeremy
  • 21
  • 4
0
votes
0 answers

Travelling Salesman Problem, It takes so long to implement

I got Travelling Salesman Problem code from geeksforgeeks website ( https://www.geeksforgeeks.org/traveling-salesman-problem-tsp-implementation/ ) and try to implemented on 26 different city, but when I run the code it takes forever to show the…
0
votes
0 answers

How to draw a line that crosses all points by using a list of point indices?

I have the following lists that correspond to 6 (clients) points (each one having an id, and x and y coordinates) allIds = [0, 1, 2, 3, 4, 5], allxs = [50, 25, 43, 80, 25, 18] allys = [50, 54, 96, 50, 90, 47] For example, the 1st point has an id…
Yannis_Tr
  • 15
  • 5
0
votes
0 answers

TSP variant: Traveling salesman problem with city-to-city restriction

I've been working for a few days on solving a travelling salesman type problem, with the following goal. On a plot like the one displayed below (algorithmic identification of the cells, hence the fact that the numbers are not necessarily in a…
J O
  • 1
  • 1
0
votes
0 answers

Nearest neighbor/Travelling salesman problem in Neo4j

I want to solve nearest neighbors/travelling salesman problem using Neo4j database. I have 200 cities that are connect with one another. I have tried using this code below to solve the problem but it takes forever to calculate. MATCH (from:Node…
0
votes
2 answers

Find the final path of Traveling Salesman Problem

I am trying to implement the Traveling Salesman Problem and I need to return the path that lead to the minimum cost. I have a distance matrix, and this is the code: static int TSP(int[][] distance, boolean[] visitCity, int currPos, int cities, int…
0
votes
0 answers

What is the problem name for Traveling salesman problem(TSP) without considering going back to starting point in asymetric graph

need to visit all the nodes exactly once and without considering going back to starting point in an asymetric graph.The distance should be minimum. Like a traveller needs to visit all the cities with minimum distance/cost and don't need to go back…
Jack
  • 181
  • 10
0
votes
1 answer

PuLP Optimization Traveling Salesman Problem - Calculating arrival time for each node

I'm solving the traveling salesman problem using PuLP optimizer on python. The code takes the time matrix as an ndarray and uses it to calculate the optimal route. My first version is running perfectly but i am facing some issue when i add a…