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
0 answers

How Do I Identify The Edge Case That Is Failing My Code?

I'm working on a coding question and I'm given an array for example something like this: [1, 7, 3, 21, 13, 19] I'm suppose to pair up items in the array. Then after that I'm suppose to apply this simple rule. Say I choose a pair x and y: Rule: if x…
0
votes
3 answers

Algorithm or approach to path problem, shortest path with n points for n <= 12

i have n points on a 2d plane, with n <= 12, and i need the distance of the shortest path available including all points, starting on any of them, but not making a closed circuit i've been trying floyd-marshal, travel salesman problem and other…
Daniel
  • 521
  • 1
  • 5
  • 5
0
votes
1 answer

How to calculate minimum expected time for searching a graph?

I have a simple graphing problem where I traverse a graph looking for an item. Each node in the graph has a probability n/100 of the item being there, where the sum of all the probabilities equals 1. How can I find the minimum expected time to…
TheOne
  • 10,819
  • 20
  • 81
  • 119
0
votes
0 answers

Unused argument in GA package

I'm trying to use TSP package with GA. I want to do something similar to this My code: library(GA) library(globalOptTests) library(TSP) data("USCA50") fitFun <- function(x) -tour_length(solve_TSP(USCA50)) dist <- as.matrix(USCA50) GA <-…
KerJa
  • 1
  • 1
0
votes
3 answers

Solver for TSP-like Puzzle, perhaps in Javascript

I have created a puzzle which is a derivative of the travelling salesman problem, which I call Trace Perfect. It is essentially an undirected graph with weighted edges. The goal is to traverse every edge at least once in any direction using minimal…
Patrick
  • 1,302
  • 2
  • 13
  • 22
0
votes
2 answers

How to apply the distance formula to a list of [x,y] coordinates in python

In order to solve the Traveling Salesman Problem (TSP) using a genetic algorithm, I am randomly generating a list of Z points on an N by N grid: field = [random.sample(range(N), 2) for x in range(Z)] Afterwards, to create a random path that the…
0
votes
1 answer

How can I use google or-tools in ruby for my rails app?

I need to solve tsp problem in my rails application. I want to use google or-tools for solving this problem of tsp. The documentation1 tells about using or-tools in c++, c#, java and python. The code for solving tsp using or-tools in python is…
0
votes
1 answer

How can I run through every permutation in my Traveling Salesman program?

I'm trying to work on a variation of the Traveling Salesman Problem (TSP) and I've hit a speed bump that has left me scratching my head. I have to find the shortest journey to visit all top 1000 ranking universities in the world. The starting and…
0
votes
0 answers

TSP/Optimization/CSP Algorithm

I am dealing with a challenge that is similar to the Traveling Salesman Problem but with a degree of Optimization and Constraint Satisfaction. The algorithm has as input the following variables: A set of points, where each point object has the…
0
votes
0 answers

TSP formulation with Pyomo

I am fairly new to Pyomo and I am trying to solve this regular formulation of TSP problem: enter image description here I have written this code based on material I could find online, but I am having some problems debugging it. It would be great if…
Mike
  • 375
  • 1
  • 4
  • 14
0
votes
0 answers

Insert a node to graph in its best place, not at end of graph

Suppose I have a list=[2,5,7] (representing a visit order of cities). I want to insert node 6 to this list (or Graph); however, I'm looking for the best place of insertion (in terms of total cost of list). For instance Cost of list1=[2,6,5,7] is…
0
votes
1 answer

What is the best algorithm for determining duplicated paths between tracking trips?

I am developing an mobile application for recording user trips. A trip is made by sequences of user positions (with longitude and latitude values). Now my problem is how to determine a trip has been traveled so far? On the other words, how to…
0
votes
1 answer

Dynamic VRP with Pickup (from one or few places) and Delivery

The problem I'm facing is: pickups goods from many places, not from depots. there is no main/depot place. All drivers may start driving wherever they want. dynamically adding goods locations and their destinations (while drivers are on the…
0
votes
1 answer

TSP for a flights fares

I am trying to solve a Traveling-salesman problem with a flight fares, so main idea is to start from one Airport and visit all Airports only once and return to origin. So for example: Starting from LAX Visit LV, CA, NY End LAX. This is a classic…
hasskell
  • 441
  • 3
  • 7
0
votes
0 answers

How To Solve TSP With Multiple Routes, Visits And Constraints

I've got an TSP problem which I can't seem to solve somehow. It consists of about 1200 addresses for which all distances (measured in seconds) between them, a frequency (once a week, twice a week, 3 times a week etc...) and cargo-weight are…