pgRouting / pgrouting

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

many to many kdijkstra #205

Closed woodbri closed 8 years ago

woodbri commented 10 years ago

WE have had a request for a many to many kdijkstra like routine. This could be done by loading the graph once which is expensive, then solving it multiple times and returning the results, or potentially a distance matrix.

yobiSource commented 8 years ago

Is this solved with 92e3848533d5979c0e40520b02c6dd8559f4cc7d and available with 2.1? So that's the SQL version of pgr_vidstodmatrix is obsolete.

cvvergara commented 8 years ago

@yobiSource _About pgrvidstodmatrix I was looking at the documentation of V2.0 http://docs.pgrouting.org/2.0/en/doc/index.html and there is no pgr_vidstodmatrix so it can not be obsolete.

Also, the functionality is different, pgr_dijkstra (the many to many version) does not return a matrix, and pgr_vidstodmatrix returns a matrix. and as you can see there are things left TODO also pgr_vidstodmatrix is being thought to be symetrical.

About kdijkstra you may say that with all the different signatures of pgr_dijkstra it returns a kdijkstra with that idea. but using overloading pgr_dijkstra covers all the cases with out the k (less names to remember),

Also we have a kdijkstra set of functions pgr_kdijkstraCost pgr_kdijkstraPath that need to evolve also towards V3.0, So I didn't close this issue. You may say that its 1/2 closed

yobiSource commented 8 years ago

pgr_vidstodmatrix did not exist in the V2.0 release, it was added later.

I have slightly customized pgr_vidstodmatrix and made it smaller for my purposes. But the return value is still a Dmatrix, just as an array instead of a record with arrays. (I have to call the function a thousand times with up to 500x500 route variants. This takes hours and eats my RAM.)

I've compiled pgrouting-2.1.0-alpha1 and both versions exist. old pgr_vidstodmatrix(integer[], postgis.geometry[], text, double precision) RETURNS record AS dmatrix double precision[], ids integer[]

new pgr_vidstodmatrix(text, integer[], boolean, boolean, boolean) RETURNS double precision[] (As my modified version of the old)

I have run both functions with the sample data and both return the same Dmatrix. Exactly what I need, the SQL function in C for faster execution. The rest is pgr_tsp job.

Perhaps @woodbri can explain the new function or add missing doc. (I do not know what "dir boolean" does)

I have to prepare my server, for testing the large amounts of OSM data.

evolve pgr_kdijkstraCost and pgr_kdijkstraPath is surely the best option but I can not wait. ^^

cvvergara commented 8 years ago

@yobiSource @woodbri I am oppening #368 to talk about pgr_vidstodmatrix

cvvergara commented 8 years ago

As the title is not precise into which many to many: pgr_kdijkstraPath pgr_kdijkstraCost

See #333 As pgr_kdijkstraPath is going to be deprecated in favor of pgr_dijkstra and there is already a pgr_dijkstra that works many to many for the paths,

So the feature request problem is reduced to: pgr_dijkstraCost to work on:

That would also eliminate the k from the name of the existing one that works 1 to many.

Wrappers to the pgr_dijkstra can work (agg_cost where edge = -1); but actually some cycles in the C/C++ can be avoided because the path is not needed.

cvvergara commented 8 years ago

Deprecating pgr_kdijstraCost please use pgr_dijkstraCost (one to many) pgr_kdijstraCost Its being fixed by wrapping it with the results of pgr_dijkstraCost (one to many)

Deprecating pgr_kdijstraPath please use pgr_dijkstra (one to many) pgr_kdijstraPath Its being fixed by wrapping it with the results of pgr_dijkstra (one to many)

many to many kdijstraCost & kdijstraPath is not going to be done, use the many to many versions of pgr_dijkstraCost & pgr_dijkstra