4

I'm using Google Or-Tools to solve a Traveling Salesman Problem by using this example (basically I just replaced the distances matrix with mine). As in the example, I set data['depot'] = 0.

For my application it is not important to return to the first node at the end of the path. I can remove the last edge from the solution but I wonder that if I could remove this constraint altogether it might find a better path overall.

gilad
  • 426
  • 1
  • 5
  • 15

1 Answers1

6

Make sure the distance from all nodes to 0 (the depot) is null. This is equivalent to what you are asking for.

Laurent Perron
  • 8,594
  • 1
  • 8
  • 22
  • 1
    Wouldn't this skew the results? I do need to use this node as a starting point. What you're saying is that the first step will cost 0 no matter which is the next node. Also, wouldn't the optimizer would then try to get to the node just before the depot? – gilad Apr 27 '20 at 13:31
  • 2
    no. The step from any node to 0 will cost 0, not the step outgoing from 0. And you can only visit a node once, 0 included. – Laurent Perron Apr 27 '20 at 15:27
  • I understand but this would make the problem asymmetric and force me to use optimizers that support asymmetric costs. I will try anyway and come back with results. – gilad May 03 '20 at 05:34
  • 1
    Sorry for the late reply, this worked perfectly. Thanks! – gilad Aug 10 '20 at 11:47