[pgrouting-users] pgr_TSP(): how to avoid the route returning to the start point

tommaso tommasodb at googlemail.com
Wed Apr 11 05:35:40 PDT 2018


Hello, I'm testing the TSP feature using this example from the  
documentation:

SELECT * FROM pgr_TSP(
     $$
     SELECT * FROM pgr_dijkstraCostMatrix(
         'SELECT id, source, target, cost, reverse_cost FROM edge_table',
         (SELECT array_agg(id) FROM edge_table_vertices_pgr WHERE id < 14),
         directed := false
     )
     $$,
     start_id := 7,
     randomize := false
);

My problem is that the algorithm returns to the start point after visiting  
the last one, while in my use case this is not requested.
There is a option to avoid this? Until now I could not find such a option  
in the documentation.
Simply ignoring the last segment is not a solution, because in certain  
cases the order of the last and second the last points changes if the  
route goes back to the first point. So, I cannot predict which one is the  
desired last point.

Regards, Tom


More information about the Pgrouting-users mailing list