<br><br><div class="gmail_quote">On Fri, Jul 29, 2011 at 9:54 PM, Stephen Woodbridge <span dir="ltr"><<a href="mailto:woodbri@swoodbridge.com">woodbri@swoodbridge.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On 7/29/2011 11:49 AM, Jay Mahadeokar wrote:<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
Hi Steve,<br>
<br>
On Fri, Jul 29, 2011 at 6:26 PM, Stephen Woodbridge<br></div><div class="im">
<<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.com</a> <mailto:<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.<u></u>com</a>>> wrote:<br>
<br></div><div><div></div><div class="h5">
Jay,<br>
<br>
This make sense. What I'm trying to understand and get to is how do<br>
we make this easy to setup and use. It seems like we are missing<br>
something somewhere. For example, the cyclical range of a single<br>
entry can be different from other entries, think week days versus<br>
weekends. It should be possible to have some cyclic entries and some<br>
not cyclic. Based on this it seems that the cyclic flag needs to be<br>
set on each record along with the period of the cycle. Would you agree?<br>
<br>
<br>
The main motivation behind all this brain storming is to keep the core<br>
algorithm and the postgres c function implementation, independent of the<br>
nature of data, right? So, we need to somehow abstract the data<br>
dependent properties from the core functionality.<br>
<br>
That was the reason why we came up with the plsql wrapper functions<br>
idea. For optimising again, we need to communicate the cyclic properties<br>
to core algorithm, but the interface should be independent of nature of<br>
data.<br>
<br>
If this is the case, then a quick scan of the data would tell us if<br>
there are cyclic entries, in which case a simple function to scan<br>
the data needed and see if any entry is cyclic could return that<br>
flag. But if every entry is marked as cyclic or not then you might<br>
not need that flag at all.<br>
<br>
<br>
What I feel is: if we scan the data and keep the logic of determining<br>
the cyclic nature within the postgres C function, then the above aim<br>
will somehow get lost and it will again become a data format specific<br>
function.<br>
<br>
So, I think it will be better if the application developers deal with<br>
the data themselves so that they can achieve the optimisation. Example -<br>
for weekday, weekend, the plsql function will provide specific values<br>
for each day and mark data as non cyclic if there is transition from<br>
weekday to weekend and vice versa. (A journey more than few days is<br>
highly unlikely, so anyways it wont repeat the data too much, though it<br>
will not be optimal)<br>
<br>
If the journey is within weekday or within weekend, then we can mark<br>
data as cyclic, and just retrieve 24 hour data.<br>
<br>
This is specific to example data you specified. I believe such<br>
improvisations will be applicable for most data formats. Thoughts?<br>
<br>
Again, this is not the most optimal implementation, but still it keeps<br>
the core implementation independent of data format. Any other ideas?<br>
</div></div></blockquote>
<br>
Jay,<br>
<br>
I think you are correct in this. This will require some real world examples of data and how to work with it. The abstraction makes sense but it is hard to map it to reality hence our discussions.<br>
<br>
So if we propose a hypothetical example like:<br>
<br>
1. roadway which it one way between 7-10am north bound on mon-fri<br>
2. same roadway is one way between 4-7pm south bound on mon-fri<br>
3. same roadway is two otherwise<br>
<br>
A separate type of rule might be:<br>
<br>
4. there was an accident at 11am causing reduced speeds for the next 30 mins<br>
<br>
we could define a table like:<br>
<br>
time_dependency<br>
rule_id:seq:day_of_week:start_<u></u>time:end_time:from_cost:to_<u></u>cost:expiry_date<br>
1:1:2,3,4,5,6:0700:1000:30:-1:<br>
1:2:2,3,4,5,6:1600:1900:-1:30:<br>
1:3:1,7:0000:2400:45:45:<br>
2:1:0:1100:1130:20:20:20110729<br>
<br>
I hope that is clear.<br>
sun-sat === 1-7 for day_of_week<br>
cost -1 means you can travel that direction<br>
<br>
then in the edges table, you can link the edge to time_dependency table via the rule_id<br>
<br>
This is not perfect because, from_cost and to_cost imply a direction of digitization of the segment which might be reversed on some segments. You might have multiple rules associated with a single segment. I'm thinking of a "rule" as a single description of some conditions that might get reused by multiple edges in the graph. So we might want a linking table like:<br>
<br>
edge_id:rule_id<br>
<br>
that will support multiple rules to be associated.<br>
<br>
Then the stored procedure could be written to query these tables based on start time, elapsed time from start, and edge_id that could return the cost of a single edge. Or you would need to write a stored procedure to transform these tables into whatever structure you need for the routing.<br>
<br></blockquote><div><br>Hi Steve,<br><br>Thanks for coming up with the example. It fits well in order to describe our current plan. So, as proposed we will assume our data is in format (instead of creating ids and seq separately im keeping gid as the id like in ways table):<br>
<br>gid: day_of_week: start_time: end_time: from_cost: to_cost: expiry_date<br><br>Now, the application developer dealing with the data will write plsql function which will query the above table and return set of rows:<br>
<br>gid, start_time, end_time, travel_time as expected by the tdsp query.<br><br>Now, if the data format is such that there are rules associated to specific edges, and there are linking tables etc as you mentioned, then it would be the responsibility of the application developer to come up with join queries etc that will be needed in the plsql wrapper function. We will just expect data in the above format. And we can also keep track of cyclic nature as discussed earlier. There can be many other formats and many other linking table possibilities, but we should not be responsible for those. That was the reason of deciding the input data format during the pre-coding period.<br>
<br>I hope I am understanding your point and answering relevantly. Thanks again for coming up with the users perspective. This is really helping me to understand the real-world scenario which I had not thought about particularly. Any other comments?<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I just trying to put this into a concrete example so we can work through how this works and to help understand how we need to document it so people can use it in a real world example.<br>
<br>
Thoughts?<br>
<br>
-Steve<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
May be I'm missing something because I have not had a full cup of<br>
tea yet :)<br>
<br>
Thoughts,<br>
-Steve<br>
<br>
<br>
On 7/29/2011 8:39 AM, Jay Mahadeokar wrote:<br>
<br>
<br>
<br>
On Fri, Jul 29, 2011 at 5:50 PM, Stephen Woodbridge<br>
<<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.com</a> <mailto:<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.<u></u>com</a>><br></div>
<mailto:<a href="mailto:woodbri@swoodbridge" target="_blank">woodbri@swoodbridge</a>. com<div><div></div><div class="h5"><br>
<mailto:<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.<u></u>com</a>>>> wrote:<br>
<br>
On 7/29/2011 5:49 AM, Jay Mahadeokar wrote:<br>
<br>
Hi all,<br>
<br>
I was looking at ways to optimise the tdsp implementation.<br>
<br>
Currently, if the time-interval is suppose 24, (24<br>
hours) and<br>
the travel<br>
time expected is around 60 hours, then the tdsp-wrapper<br>
query<br>
retrieves<br>
total 60 intervals and the data is repeated for the 24 hour<br>
intervals.<br>
(I hope what i am trying to say is clear).<br>
<br>
This is unnecessary space wastage. So, I edited the<br>
weight_map<br>
class to<br>
accommodate a variables is_cyclic and the<br>
cycle_interval, which will<br>
keep track of the cyclic nature of the data. So,<br>
actually only<br>
the 24<br>
hour data will be fed to weight map and then it will be<br>
reused<br>
in cycles.<br>
<br>
Because of the good design, I guess this has scaled up<br>
really<br>
nice and<br>
there is no need to modify actual core tdsp. Just the<br>
weight_map's<br>
get_travel_time() function and the wrapper plsql<br>
function needed<br>
to be<br>
altered.<br>
<br>
<br>
This makes perfect sense and sounds like a great optimization.<br>
<br>
<br>
Now, in the main query, I am thinking of adding one more<br>
boolean<br>
variable - is_cyclic which will be enabled if the data<br>
is cyclic in<br>
nature. Should we keep this? Or we should assume that<br>
the data<br>
will be<br>
always cyclic.<br>
Any other views on the same are welcome.<br>
<br>
<br>
I guess my questions are:<br>
How does this get set?<br>
What are the advantages of setting it?<br>
Is there a way to dynamically check if it is cyclic at the<br>
start and<br>
avoid having the app builder set it up?<br>
<br>
<br>
Advantages of setting it:<br>
If the data is not cyclic, then the whole data will be expected to<br>
reside in database itself. So, if the upper bound of the time is<br>
reached<br>
then by default, we can assume that the travel_time<br>
corresponding to the<br>
last existing time window should be used for such cases.<br>
<br>
If data is cyclic, then we need to start all over again. These<br>
are the<br>
cases, what I could think of.<br>
<br>
How does this get set:<br>
The tdsp query must have an additional parameter - is_cyclic which<br>
should be used to set the is_cyclic flag of the weight_map.<br>
<br>
Now, if data is cyclic, then the plsql function that retrieves<br>
the data<br>
should be written in such a way that if interval is suppose 0 -<br>
24, and<br>
start time is 21, then 21->0 and 20->23. After that the cyclic flag<br>
will indicate us to loop again. The plsql function will be<br>
generally<br>
written by app developer and he should take care of this. (I have<br>
already implemented this in my code.)<br>
<br>
If data is cyclic, he should pass the flag appropriately. If<br>
is_cyclic<br>
is false, we can assume that if intervals are exhausted, we will<br>
keep<br>
using time corresponding to last interval.<br>
<br>
Is this reasonable?<br>
<br>
I suppose it is not a big deal for the app builder to set<br>
this flag<br>
since he will know if the data loaded is cyclic in nature. I<br>
assume<br>
you are only looking for some indication if there are cyclic<br>
entries<br>
in the data and not if this specific query has a cyclic<br>
nature which<br>
would be impossible to know without analyzing the start time<br>
and max<br>
time window, in which case we should figure that out<br>
automatically<br>
because the user making the request is not likely to know<br>
anything<br>
more than start, end and start time or end time.<br>
<br>
-Steve<br>
<br>
--<br>
Regards,<br>
-Jay Mahadeokar<br>
<br>
<br>
<br>
______________________________ _________________<br>
pgrouting-dev mailing list<br></div></div>
<a href="mailto:pgrouting-dev@lists.osgeo.org" target="_blank">pgrouting-dev@lists.osgeo.org</a> <mailto:<a href="mailto:pgrouting-dev@lists.osgeo.org" target="_blank">pgrouting-dev@lists.<u></u>osgeo.org</a>><div class="im">
<br>
<a href="http://lists.osgeo.org/" target="_blank">http://lists.osgeo.org/</a> mailman/listinfo/pgrouting-dev<br>
<<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-dev" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-dev</a><u></u>><br>
<br>
<br>
______________________________ _________________<br>
pgrouting-dev mailing list<br></div>
<a href="mailto:pgrouting-dev@lists.osgeo.org" target="_blank">pgrouting-dev@lists.osgeo.org</a> <mailto:<a href="mailto:pgrouting-dev@lists.osgeo.org" target="_blank">pgrouting-dev@lists.<u></u>osgeo.org</a>><div class="im">
<br>
<a href="http://lists.osgeo.org/" target="_blank">http://lists.osgeo.org/</a> mailman/listinfo/pgrouting-dev<br></div><div class="im">
<<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-dev" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-dev</a><u></u>><br>
<br>
<br>
<br>
<br>
--<br>
Regards,<br>
-Jay Mahadeokar<br>
<br>
<br>
<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>
</div></blockquote><div><div></div><div class="h5">
<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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>-Jay Mahadeokar<br><br>