[pgrouting-users] pgr_tsp performance

Hello everyone,

I need to determine a good route for an asymmetric travelling salesman type problem that can have up to hundreds of nodes.

For now I was able to use the pgr_tsp function (with driving distance matrix input) from pgrouting to determine a route for an instance with 100 nodes in less than 10 seconds.

I know that this function uses a simulated annealing heuristic so I can’t expect the optimal route, but the problem is that the output route is not very good, having several points where it backtracks.

What I want to know is:

1 - Does this function usually gives good results for instances with 30+ nodes?

2 - I would not have a problem with waiting up to an hour for the results if it meant a better route… is there a way to change any of the simulated annealing parameters? The algorithm seems to be converging prematurely.

3 - Are there any good free libraries that you can suggest for this purpose apart from pgrouting?

Thank you,

Diogo Silva

AVISO DE CONFIDENCIALIDADE: Este e-mail e quaisquer ficheiros informáticos com ele transmitidos são confidenciais e destinados ao conhecimento e uso exclusivo do respectivo destinatário, não podendo o conteúdo dos mesmos ser alterado. Caso tenha recebido este e-mail indevidamente, queira informar de imediato o remetente e proceder à destruição da mensagem.

CONFIDENTIALITY WARNING: This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. Their contents may not be altered. If you have received this e-mail in error please notify the sender and destroy it immediately.

P Antes de imprimir este mail, pense bem se tem mesmo que o fazer. Proteja o meio ambiente.

Hello Diogo,

On 10/1/2014 5:27 AM, Diogo Silva wrote:

Hello everyone,

I need to determine a good route for an asymmetric travelling salesman
type problem that can have up to hundreds of nodes.

First off as of pgRouting 2.0 we only solve the symmetric TSP. Although some is working on an asymmetric solver.

For now I was able to use the pgr_tsp function (with driving distance
matrix input) from pgrouting to determine a route for an instance with
100 nodes in less than 10 seconds.

You probably need to break down what costs what here. I believe the time here is being spent on computing the distance matrix and NOT on solving the TSP which is very fast and has no problem handling 100 nodes.

I know that this function uses a simulated annealing heuristic so I
can't expect the optimal route, but the problem is that the output route
is not very good, having several points where it backtracks.

TSP is ONLY solving the order of the nodes based on the distance matrix. When you map the order of the nodes to a road network is will backtrack.

       o o o
       | | |
       A B C
       | | |
------+-------+-------+------

Say you have a TSP solution that has a sequence of ....,A,B,C,.... but the road network above where A, B, C are on dead-end streets you can only sevice them by back track on the route.

What I want to know is:

                 1 - Does this function usually gives good results for
instances with 30+ nodes?

The function give good results regardless of the number of nodes.

                 2 - I would not have a problem with waiting up to an
hour for the results if it meant a better route... is there a way to
change any of the simulated annealing parameters? The algorithm seems to
be converging prematurely.

Some pictures and an explaination of what you think is wrong would help a lot here. You can also play with the source code and change the parameters if you want. I think it is working fine for the problems it was intended to solve and that the problem is that it might not be the correct tool for your problem (based on symmetric vs asymmetric), but I happy to be convinced otherwise.

                 3 - Are there any good free libraries that you can
suggest for this purpose apart from pgrouting?

Yes, lots are available on the net google is your friend.
https://www.google.com/?gws_rd=ssl#q=asymmetric+tsp+source+code

Hope this helps,
   -Steve

Thank you,

Diogo Silva

*AVISO DE CONFIDENCIALIDADE*: Este e-mail e quaisquer ficheiros
informáticos com ele transmitidos são confidenciais e destinados ao
conhecimento e uso exclusivo do respectivo destinatário, não podendo o
conteúdo dos mesmos ser alterado. Caso tenha recebido este e-mail
indevidamente, queira informar de imediato o remetente e proceder à
destruição da mensagem.

*CONFIDENTIALITY WARNING*: This e-mail and any files transmitted with it
are confidential and intended solely for the use of the individual or
entity to whom they are addressed. Their contents may not be altered. If
you have received this e-mail in error please notify the sender and
destroy it immediately.

*P****Antes de imprimir este mail, pense bem se tem mesmo que o fazer.
Proteja o meio ambiente.***

_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

Thanks you for the quick reply. :slight_smile:

-----Original Message-----
From: pgrouting-users-bounces@lists.osgeo.org [mailto:pgrouting-users-bounces@lists.osgeo.org] On Behalf Of Stephen Woodbridge
Sent: 1 de outubro de 2014 15:21
To: pgrouting-users@lists.osgeo.org
Subject: Re: [pgrouting-users] pgr_tsp performance

Hello Diogo,

---

First off as of pgRouting 2.0 we only solve the symmetric TSP. Although some is working on an asymmetric solver.

Yes, I have been looking over the pgr_tsp source code and saw some comments on it about what changes need to be done for it to work on an asymmetric TSP. But I did not wanted to change the code unless I was sure it was the cause of the problem.
Do you think using a non-symmetrical distance matrix as input for pgr_tsp can be the cause of problem? In my case, the distance from A to B can be very different than that from B to A because of one-way streets. (see attachment).

---

You probably need to break down what costs what here. I believe the time here is being spent on computing the distance matrix and NOT on solving the TSP which is very fast and has no problem handling 100 nodes.

Sorry I did not go into more detail on this part. I pre-calculated the distance matrix (driving distances by road) on another one of my functions using the pgr_kdijkstraCost function. You are right, the pgr_tsp function is more than fast enough for what I need. The 10 seconds I mentioned include the execution of other parts of code. Time is not the problem for me.

---

TSP is ONLY solving the order of the nodes based on the distance matrix.
When you map the order of the nodes to a road network is will backtrack.

       o o o
       | | |
       A B C
       | | |
------+-------+-------+------

Say you have a TSP solution that has a sequence of ....,A,B,C,.... but the road network above where A, B, C are on dead-end streets you can only sevice them by back track on the route.

Yes, of course, I agree. But the cases I am referring to are like this:

  --A-----B-----C-----D-----E--

Say you have a normal two-way street with five service points. The type of backtracking solution I am talking about contain segments like: ...,A,D,B,C,E,...

The attachment has some pictures of two parts of the same route (step 1 to 14 and step 29 to 38) and a picture showing one-way streets. Black lines are the roads, green lines are roads used in the route, yellow node and line represent the current step start node and path.

I have tested this visualization method with a route that I manually created as if it were the output of the pgr_tsp funtion and it worked fine, so doubt the problem is in converting the output of the pgr_tsp funtion to QuantumGIS.

---

The function give good results regardless of the number of nodes.

Good to know.

---

Some pictures and an explanation of what you think is wrong would help a lot here. You can also play with the source code and change the parameters if you want. I think it is working fine for the problems it was intended to solve and that the problem is that it might not be the correct tool for your problem (based on symmetric vs asymmetric), but I happy to be convinced otherwise.

(See attachment)

---

Yes, lots are available on the net google is your friend.
https://www.google.com/?gws_rd=ssl#q=asymmetric+tsp+source+code

Thanks, yes he is. :slight_smile:

AVISO DE CONFIDENCIALIDADE: Este e-mail e quaisquer ficheiros informáticos com ele transmitidos são confidenciais e destinados ao conhecimento e uso exclusivo do respectivo destinatário, não podendo o conteúdo dos mesmos ser alterado. Caso tenha recebido este e-mail indevidamente, queira informar de imediato o remetente e proceder à destruição da mensagem.

CONFIDENTIALITY WARNING: This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. Their contents may not be altered. If you have received this e-mail in error please notify the sender and destroy it immediately.

Route.zip (1.43 MB)

Hi Digo,

I am attempting to work on an impementation off the AS TSP problem, what I
have at the moment is some what raw if I get any where I will attempt to
let you known.
D.
hanks you for the quick reply. :slight_smile:

-----Original Message-----
From: pgrouting-users-bounces@lists.osgeo.org
[mailto:pgrouting-users-bounces@lists.osgeo.org] On Behalf Of Stephen
Woodbridge
Sent: 1 de outubro de 2014 15:21
To: pgrouting-users@lists.osgeo.org
Subject: Re: [pgrouting-users] pgr_tsp performance

Hello Diogo,

---

First off as of pgRouting 2.0 we only solve the symmetric TSP. Although
some is
working on an asymmetric solver.