0

I'm using postgresql / PostGIS with pgrouting and I need to compute the shortest path. In a previous version of pgrouting, I was using shortest_path_astar. In my routing graph I had impossible segments, such as locked doors. I used:

SELECT id FROM shortest_path_astar('SELECT edge_id AS id, vertex_id1 AS source, vertex_id2 AS target, ' || '(CASE WHEN door = ''S'' THEN -1.0  ELSE  (length)  )  END)::float8 AS cost, ' || '(CASE WHEN door_rev = ''S'' THEN -1.0  ELSE  (length)  )  END )::float8 AS reverse_cost, ' || 'x1, y1, x2, y2 FROM edges', origin_node, destination_node, TRUE, TRUE)

Basically: when door is closed (door = ''S''), I fixed the cost to -1. It worked fine till the new version of this function, pgr_astar. With pgr_astar instead of shortest_path_astar, this query crashes the server.

How can I change my function to avoid the crash?

Antonin
  • 1,748
  • 7
  • 19
  • 24
  • I read "A negative cost will prevent the edge from being inserted in the graph" in the [documentation for pgr_astar](http://docs.pgrouting.org/2.0/en/src/astar/doc/index.html#pgr-astar), so it should be the same. But if I remove it, it does not crash anymore. – Antonin Nov 28 '13 at 16:53

2 Answers2

1

Can you post a simple test case that reproduces this crash in the issue tracker: https://github.com/pgRouting/pgrouting/issues

cost: -1 should work should work.

Stephen Woodbridge
  • 1,100
  • 1
  • 8
  • 16
  • The problem is that I don't know where the problem is exactly, so I can not create a simple test case. I can only send you the full network (50'000 edges and almost the same number of nodes). And I'm not so sure I can share these data yet. I'm negotiating. – Antonin Nov 30 '13 at 11:07
  • I just check the code and any edge with cost < 0.0 will not be added to the graph. So I would guess that the problem may be related to the fact that you might not have any valid route between the start and end node. Can you run your query in psql and copy the failured results to this thread. – Stephen Woodbridge Dec 01 '13 at 18:23
0

I finally used pgr_bdAstar, bi-directional A* Shortest Path.

Antonin
  • 1,748
  • 7
  • 19
  • 24