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).

654 questions
10
votes
5 answers

Is this solvable in polynomial (or pseudo-polynomial) time?

I'm trying to come up with a reasonable algorithm for this problem: Let's say you have a bunch of balls. Each ball has at least one color, but can also be multicolored. Each ball has a weight and a value associated with it. There are also a bunch of…
9
votes
3 answers

Simplified Travelling Salesman in Prolog

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…
g.a.kilby
  • 93
  • 1
  • 3
9
votes
2 answers

Approximation algorithm for TSP variant, fixed start and end anywhere but starting point + multiple visits at each vertex ALLOWED

NOTE: Due to the fact that the trip does not end at the same place it started and also the fact that every point can be visited more than once as long as I still visit all of them, this is not really a TSP variant, but I put it due to lack of a…
8
votes
1 answer

Minimal Distance Hamiltonian Path Javascript

I know this is a fairly frequent question (tsp in general), but I've been stumped by it for awhile now. I'm looking to find the minimal distance hamiltonian path given a set of x,y coordinates. The start and end point are completely arbitrary but it…
stumpedcoder
  • 101
  • 1
  • 4
8
votes
4 answers

How can the A* algorithm be applied to the traveling salesman problem?

Possible Duplicate: Using A* to solve Travelling Salesman Problem I have recently learned that the A* algorithm can be applied to the travelling salesman problem. Bot how exactly do we define the start and the goal here, and how do we apply…
gruszczy
  • 37,239
  • 27
  • 119
  • 167
8
votes
6 answers

Solving the Travelling Salesman Problem in ruby (50+ locations)

I am working in a delivery company. We currently solve 50+ locations routes by "hand". I have been thinking about using Google Maps API to solve this problem, but I have read that there is a 24 points limit. Currently we are using rails in our…
jfanals
  • 947
  • 1
  • 12
  • 25
7
votes
3 answers

Use R to Efficiently Order Randomly Generated Transects

Problem I looking for a way to efficiently order randomly selected sampling transects occur around a fixed object. These transects, once generated, need to be ordered in a way that makes sense spatially such that the distance traveled is minimized.…
7
votes
3 answers

2-opt algorithm to solve the Travelling Salesman Problem in Python

I couldn't find any complete implementation of the 2-opt algorithm in Python so I am trying to add the missing parts to the code found here, which I present below. def two_opt(route): best = route improved = True while improved: …
rrz0
  • 1,762
  • 3
  • 17
  • 51
7
votes
1 answer

Finding the optimum cost of a traveling salesman solution

I'm working on this problem: TSP: Input: A matrix of distances; a budget b Output: A tour which passes through all the cities and has length <= b, if such a tour exists. TSP-OPT Input: A matrix of distances Output: The shortest tour which passes…
2-bits
  • 463
  • 5
  • 12
7
votes
4 answers

Travelling Salesman with multiple salesmen with a limit on number of cities per salesman?

Problem: I need to drop (n) employees from office to their homes(co-ordinates available). I have (x) 7-seater & (y) 4-seater cabs available. I have to design an algorithm to drop all the employees to their homes while travelling minimum…
7
votes
2 answers

Genetic Algorithm: Higher Mutation Rate leads to lower run time

I implemented a genetic algorithm to solve an enhanced Traveling Salesman Problem (the weight of the edges changes with the time of the day). Currently I'm evaluating the different parameters of my simulation and I stumbled upon a correlation I…
7
votes
1 answer

Traveling Salesman for java

Based on this pseudo code I am trying to implement a java fittness function for the Traveling Salesman problem but I am not sure if I am doing it right, can someone please help me out. N The number of cities to visit T A tour (list of integers…
Mikey
  • 637
  • 4
  • 17
7
votes
2 answers

Teleporting Traveler, Optimal Profit over time Problem

I'm new to the whole traveling-salesman problem as well as stackoverflow so let me know if I say something that isn't quite right. Intro: I'm trying to code a profit/time-optimized multiple-trade algorithm for a game which involves multiple cities…
7
votes
3 answers

TSP - Branch and bound

I'm trying to solve the TSP with Branch and bound algorithm. I must build a matrix with costs but I have this problem: I have city with coordinates x and y. The cost of traveling is ceil(ceil(sqrt((x1-x2)^2+(y1-y2)^2))/v) + days spent in the city. V…
gummmibear
  • 81
  • 1
  • 1
  • 4
7
votes
7 answers

Minimum cost strongly connected digraph

I have a digraph which is strongly connected (i.e. there is a path from i to j and j to i for each pair of nodes (i, j) in the graph G). I wish to find a strongly connected graph out of this graph such that the sum of all edges is the least. To put…
Kazoom
  • 5,179
  • 16
  • 54
  • 65
1
2
3
43 44