pgRouting / pgrouting

Repository contains pgRouting library. Development branch is "develop", stable branch is "master"
https://pgrouting.org
GNU General Public License v2.0
1.15k stars 366 forks source link

pgr_astar returns one null route #296

Closed noenest closed 9 years ago

noenest commented 9 years ago

Dear developers,

We have installed pgRouting to perform searches on the European cartography.

After successfully installing the software and the cartography (version details below), we perform a simple query using the A* algorithm to find the shortest path between two nodes in different cities within the same country. Unfortunately, it not working. The query follows:

SELECT seq, id1 AS node, id2 AS edge, cost FROM pgr_astar(
    'SELECT id, source, target, cost, x1, y1, x2, y2, reverse_cost FROM eu_2po_4pgr 
        WHERE ST_dwithin(geom_way::geography, (SELECT geography(ST_makeLine(geom_way)) FROM vista_vertice_table WHERE source IN (8324560, 14246280)), 500)',
    8324560, 14246280, false, false);

The result is always:

psql:pruebas/prueba31-astar.sql:1: ERROR:  Error computing path: (null)

The same problem appears with bidirectional A*, but not with Dijkstra or bidirectional Dijkstra.

We are using Ubuntu 14, with PostgreSQL 9.3.6, postgis 2.1.2, and pgrouting 2.0.0. Our system has 32Gb of RAM, and the configuration file for PostgreSQL has been created using pgtune.

It is very important for our research to solve this issue. Any help will be greatly appreciated.

Thank you very much!

woodbri commented 9 years ago

The node numbers are very large, this can be a problem in some cases if the they are sparsely assigned. For example is there a large difference between (max(nodeid) - min(nodeid)) and count(nodeid). You might try renumbering you nodes.

ERROR: Error computing path: (null)

Is not a real helpful message. The null means that something bad happened and we did not have a chance to assign an error message to it. Typically this is an out of memory request.

Also can you try pgr_trsp() and let us know if that works.

It would be helpful if you can make a smaller test case that reproduces this problem then we can debug that. How many edges in:

select count(*) from eu_2po_4pgr where st_dwithin(geom_way::geography, (select geography(st_makeLine(geom_way)) from vista_vertice_table where source in (8324560, 14246280)), 500);

You could dump those to shapefile then someone could use that to make a similar test case.

noenest commented 9 years ago

I have some questions.

As to the node numbers, I got the following results for multiple queries:

(25478853 - 168719) - 4526 = 25305608

(23459170 - 2775613) - 607 = 20682950

(24464701 - 2775613) - 1114 = 21687974

In the first two cases mentioned error occurs. In the latter case the query returns the path .

I dont know how interpret this result or how try renumbering nodes and that achievement with this.

On the other hand, I tried pgr_trsp() and works, but the result for the cost is always zero. Why this happens? It has also happened to me with pgr_bdDijkstra.

And finally, why the A * algorithm has these problems and Dijsktra algorithm runs without modifying the base query?

Thanks!!