2

The classic travelling salesman problem says you can visit every node exactly once.

I saw this interesting problem which says that you can revisit nodes if this can mean a shorter path.

Ie graph of

1-2-3 (in a triangle. undirected edge weights: 1-2 1

1-3 1

3-2 500

The best path would be going from 1 then to 2 then back to 1 then to three.

The algorithm to solve this I can't quite figure out. If the regular tsp was used, it will lead to infinite cycles.

  • 1
    Maybe a duplicate of [this question](https://stackoverflow.com/questions/39833023/tsp-where-vertices-can-be-visited-multiple-times) (first answer says it all) – m.raynal Apr 03 '19 at 18:29
  • have you tried any metaheuristic approaches or some exact algorithms? – guroosh Apr 05 '19 at 07:34

1 Answers1

1

You can just replace the distances with the shortest-path distances between each pair of nodes. So in your example, the distances would be: 1-2: 1 1-3: 1 2-3: 2 Then you solve a normal TSP on this instance. The model "thinks" it is visiting every city only once, even though one of the edges actually takes it "through" a city for a second time.

LarrySnyder610
  • 2,277
  • 12
  • 24
  • To precomputate all pairs shortest path would take n^2logn, then tsp with dp would be 2^n* n^2 –  Apr 18 '19 at 03:35
  • Maybe, although TSP is not normally solved using DP. But what is your question here? – LarrySnyder610 Apr 18 '19 at 21:20
  • No question! Thank you for your response :). It was an assignment so I couldn't use heuristics –  Apr 20 '19 at 22:19