Open jucardwell opened 2 months ago
Planning to also update dodgr and re-run the script. I am still on 0.2.21
Looks like I am having the same issue with the updated version as well
Thanks @jucardwell for the very interesting use case. I must admit, I don't quite understand what you're trying to do, even though it seems like a pretty obviously valuable analysis. I've re-run the code myself on a test network to try to get some insight. The values of sum_time_weighted
converge, but to different values for each iteration. I think I'm going to need a bit more help understanding what the expectations are here, and why ...?
One thing that does jump out from your code there is your modification of weightings. I can't really foresee the effect this might have? I guess as the iteration proceeds, the applied increases in weighting will penalize increasingly large portions of the entire network, and re-direct routing onto alternative paths. But then at some stage, this penalty scheme will likely saturate, and thus revert towards the original, un-penalized scheme? I added a line to dump proportions of penalized_roads
, which increase with increase in weight_increase_factor
from under 30% to 34%. But as said, I'm going to need a bit more info to understand what all this means.
One thing I did just notice: if you examine diff(summarized_iterations$sum_time_weighted)
, some values do increase fairly quickly to near your expected values, but then decrease again.
Hi Mark, thanks for the response. Essentially, I am trying to test the availability of reasonable alternative routes. I penalize utilized roads during each iteration so that I can try to "force" alternative paths. Once a road has been used in one iteration, it is penalized by a weight factor. My expectation is that, once reasonable alternative routes have been exhausted, the flows will revert back to the initial shortest paths. Tracking the iteration in which this happens gives some insight into the redundancy of the network. Most of the origins revert back to their initial paths within 5-20 iterations and once they have converged, there is no change in later iterations. At that point of reversion, I would expect that the sum_time_weighted would be the sum_time_weighted of the first iteration * weight factor. This would mean that the paths were the same as the original paths, but since they have been penalized, their weighted time is increased. However, in the example I provided, there are instances where the sum_time_weighted converges, but not at the expected value. For instance, in the example provided, the first iteration sum_time_weighted was 483517.619. If the weighting factor was 1.25 we would expect it to converge at some iteration at 604397.024. However, it is converging at a smaller value than that, which is unexpected. Because it is converging, that means that all those paths have already been re-weighted, which would imply that the base sum_time_weighted should have been lower than the selected shortest path.
When simply looking at the iteration in which the values converge, the pattern is exactly what I would think it would look like (more iterations to convergence in more urban areas), but I am worried that the convergence is not occurring at the expected value.
Thanks again
Don't forget that you've got (generally highly) non-linear relationships with the rest of the network. I mentioned above that my trial covered only about 30% of the network as penalized ways. Even when these are fully penalized, the actual routes taken depend on relative weighted distances/times with respect to all other (non-penalized) ways. So I wouldn't really know what to actually expect as penalties increase for only a small portion of the network.
Hi Mark, thanks for the response. I'm not sure I totally understand what you mean about non-linear relationships with the rest of the network. I am running a separate trial for about 2000 discrete origins. Each origin has between 1-20 destinations that are all within a relatively short geographical distance from the origin. My hypothesis is that "reasonable" routes would be exhausted in the beginning iterations after the re-weighting scheme and it would land back on the paths in the first set (meaning that even with the penalty, that path is still the relative shortest). Sorry for taking up so much time, but I think I'm not quite there.
I will say that the differences are quite small (for instance, the example is .2%. I've encountered small issues with floating point rounding in dodgr
I'm still not entirely clear what that code would really do, but maybe this tangential thought might help: Your penalty adjustments are very coarse, and penalize all ways traversed in any prior scenario. More usual approaches to finding alternative paths involve simply switching off single edges. You could also do that by finding the edge with the largest flow in your filtered_data
, and then on the next iteration set d_weighted
for that to some arbitrarily high value like 1e6
or so? Or select some smaller set of n
highest-flow edges to switch off?
Hi Mark, basically, I am attempting to apply the methodology in this analysis https://dl.acm.org/doi/abs/10.1145/3357000.3366137 I am specifically looking for diverse paths, which is why I penalize all roads. Basically-- how much path diversity exists before returning to the shortest path. I'm open to trying a different approach, but am specifically trying to model a path penalization approach to create routing diversity
Cross-linking to related issue #224. @jucardwell The idea of "diverse paths" has always been a primary motivation here (https://github.com/UrbanAnalyst/dodgr/issues/224#issuecomment-2068832839), and something I definitely want to implement and improve. I'll get back to you asap
Hi Mark,
I am trying to figure out an issue I am having in dodgr_flows. I am using dodgr_flows to calculate a "redundancy index" for each block group in North Carolina. I have a flow matrix set up for each block group, which tracks travel from each origin block group to its habitual destinations and it includes a flow approximation to each destination based on population data.
To track redundancy, I have set up a process that iteratively increases the graph$weighted_distance (which I have set to weighted_time) once that path has been utilized in a shortest path.
In most situations, as I would have expected, the sum of weighted time "levels out" at a maximum of (beginning weighted flow * weight factor), meaning that the flow has been re-directed onto the original shortest path set at some iteration. I am tracking the number of that iteration to compare across block groups.
However, a non-trivial number of block groups (maybe 20%) are exhibiting a "leveling out" below the expected maximum. This seems to indicate to me that there is a shortest path set that is not selected as the original shortest path, or that something else is going on.
For instance, in the output below the sum_time_weighted of the first iteration is 483517.619, so you would expect that at some iteration, it would return to that value * weight value, which would be 604397.024. As you can see below, it is leveling out, but at a value lower than that max. I have occasionally encountered rounding issues with dodgr outputs. I wonder if that could be the issue here (given that any rounding issue is multiplied by the flow on that route), but the magnitude seems a bit large for that.
Looking for any thoughts/opinions. I realize this use case is a bit convoluted, so if it would be helpful for me to come up with reproducible code, please let me know. Thanks.