<p dir="ltr">Hi Steve, </p>
<p dir="ltr">Please consider this opportunity to consolidate current Dijkstra functions.</p>
<p dir="ltr">As you know, there are side situations where Dijkstra and KDijkstra are producing different results when that shouldn't happen. </p>
<p dir="ltr">Maybe it's time to merge everything into the same code base to be make it easier to tackle bugs and future improvements. :-) </p>
<p dir="ltr">I can help with testing, if you want! </p>
<p dir="ltr">Thanks to all community! </p>
<p dir="ltr">--<br>
Helder Alves</p>
<div class="gmail_quote">On Apr 13, 2014 2:41 PM, "Stephen Woodbridge" <<a href="mailto:woodbri@swoodbridge.com">woodbri@swoodbridge.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So a couple of more thoughts on refactoring TRSP. I think we can get away with having just two C wrapper functions:<br>
<br>
1) to handle node input<br>
2) to handle edge input<br>
<br>
I think everything else can be handled as options in the plpgsql wrappers like:<br>
<br>
a) input is always an array of nodes or edges<br>
we can take two node arguments and create an array in psql wrapper<br>
likewise for the start and end edge function<br>
<br>
b) we can add an argument mode=n, where<br>
0 - point to point<br>
1 - one to many<br>
2 - many to many<br>
<br>
c) it might be useful to have an option costonly if you only want the cost and not all the edge info<br>
<br>
d) restrictions are optional and can be passed as null if none<br>
<br>
The only issue with this is that we currently return different result types if we are returning a single route versus returning multiple routes in the result. I think we can deal with this by always returning the multiple results structure from the C code and filtering the column out in the plpgsql wrapper function to support the existing functions<br>
<br>
My goal is to minimize code duplication and to simplify the lower level code for consistency, supportability, and testing. Long term we might deprecate some of the plpgsql wrapper functions to simplify the documentation and to make it easier to work with.<br>
<br>
Thoughts and input are welcome. I'm still in the planning stage for this but will short start coding something ;)<br>
<br>
Thanks,<br>
-Steve<br>
<br>
On 4/12/2014 8:28 PM, Stephen Woodbridge wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Roni,<br>
<br>
I hope you and your family are doing well.<br>
I am well but have been very busy. I'm between some contracts at the<br>
moment and I am looking at the TRSP improvements you did quite a ways<br>
back to add the reverse cost and routing from nodes A-B-C-...<br>
<br>
Looking at multi_dijkstra it seems that I should be able to mimic that<br>
code based on how you clean up after each route A-B to restart for B-C<br>
and create a similar function that computes one to many destinations,<br>
A-B, A-C, A-D, etc.<br>
<br>
What do you think?<br>
<br>
So for integrating this code, I probably need to implement a family of<br>
additional functions like:<br>
<br>
<br>
Existing functions:<br>
<br>
pgr_trsp(text, integer, integer, boolean, boolean)<br>
-- node to node<br>
<br>
pgr_trsp(text, integer, integer, boolean, boolean, text)<br>
-- node to node with restrictions<br>
<br>
pgr_trsp(text, integer, double precision, integer, double precision,<br>
boolean, boolean)<br>
-- edge to edge<br>
<br>
pgr_trsp(text, integer, double precision, integer, double precision,<br>
boolean, boolean, text)<br>
-- edge to edge with restrictions<br>
<br>
pgr_trsp(text, integer[], boolean, boolean, text)<br>
-- array of nodes **this gets changed to use new code (1)**<br>
<br>
pgr_trsp(text, integer[], float8[], boolean, boolean, text)<br>
-- array of edges **this gets changed to use new code (2)**<br>
<br>
(1) should plug directly into your code. I currently do this in C by<br>
calling your old code multiple times, but it will be more efficient to<br>
change this to call multi_dijkstra because we only build the graph once.<br>
<br>
(2) I currently do this in C by making multiple calls to your old code.<br>
The multi_dijkstra only accepts nodes, not edges, so I'll look at making<br>
a version that can be called by edges. Unless you want to do that :)<br>
<br>
Then I think I would like to add a new argument to (1) and (2) above<br>
"boolean onetomany" and if it is true then we compute A-B, A-C, A-D, ...<br>
and if it is false it will compute A-B-C-...<br>
<br>
I'll have to think about how to return the results, but that should not<br>
be too hard.<br>
<br>
TODO:<br>
<br>
1. create function to support multi_dijkstra with edges<br>
2. create new function onetomany_dijkstra for nodes<br>
3. create new function onetomany_dijkstra for edges<br>
4. update C code wrappers to support the above<br>
5. develop test cases<br>
6. write the documentation<br>
7. check it in<br>
<br>
Ok that is a bunch of work! Maybe I'll start with just getting (1) done<br>
so it calls your new code, and write a test case for that. Then tackle<br>
the rest.<br>
<br>
Thoughts?<br>
<br>
-Steve<br>
______________________________<u></u>_________________<br>
pgrouting-dev mailing list<br>
<a href="mailto:pgrouting-dev@lists.osgeo.org" target="_blank">pgrouting-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-dev" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-dev</a><br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
pgrouting-dev mailing list<br>
<a href="mailto:pgrouting-dev@lists.osgeo.org" target="_blank">pgrouting-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-dev" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-dev</a><br>
</blockquote></div>