Search code examples
nodestraveling-salesmanoperations-research

How to solve a TSP using Concorde?


I have 12 nodes and distance between every pair of nodes (in meters). The nodes refer to different streets in a city. I need to obtain an exact solution of the TSP (not heuristic) so I'd like to solve the TSP problem with the program Concorde, but I am not able to introduce the data. The Concorde interface just lets me introduce random nodes and solve that problem, but I'd like to give it my data.

I've tried to create a .txt with the following structure:

\#nodes \#edges
node1 node2 dist12
node1 node3 dist13
(etc)

and changed the extension to .qs (as I've seen Concorde accepts that) but I don't obtain any results. I've also set the extension .tsp and nothing.

Also, I've searched the coordinates of my nodes in google maps, and created the text file:

12
45.609400, 8.874233
45.612743, 8.893011
45.610751, 8.898242
45.610617, 8.902134
45.609246, 8.905195
45.612339, 8.907780
45.617118, 8.903145
45.606889, 8.900597
45.601403, 8.878341
45.602539, 8.883501
45.604054, 8.879854
45.613369, 8.894035

But again, Concorde does not accept my file. What am I doing wrong? How should I introduce my data in Concorde?

Also, I've tried to introduce the last coordinate's file in the NEOS server for Concorde and the result is not the expected, as you can see in the image: TSP


Solution

  • I am currently investigating the qs format. Cannot find any information on the web, but by inspection, it appears to as below. No commas, and keep the counts straight, of course. save as *.qs and open it.

    node_count edge_information_count
    n1x n1y
    n2x n2y
    ...
    n(count)x n(count)y
    n1 n2 edge_info
    ....
    n1 n2 edge_info
    ...
    n(count)1 n(count)2 edge_info
    

    So, I got this to work (windows concorde ui version, Win 8.1, HP laptop) with your data, removing commas, fixing header line. It is not what you want, but by supplying distances in the edge info area (and updating the header) it may work.

    My question is, does it use the edge info in arriving at a solution? I can't say it does. I'll have to check the solution to see (and I'd like you working on it at the same time). But I do know that if you load a qs with edge information, solve it, save it, it replaces the edge information with the solution.

    Here's your euclidian solution, again, not what you want:

    12 0
    45.609400 8.874233
    45.612743 8.893011
    45.610751 8.898242
    45.610617 8.902134
    45.609246 8.905195
    45.612339 8.907780
    45.617118 8.903145
    45.606889 8.900597
    45.601403 8.878341
    45.602539 8.883501
    45.604054 8.879854
    45.613369 8.894035