-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Analyzer: Add time_bin argument to area_to_pandas #130
Conversation
Okay, it finally starts to look like something. 1. Added
|
@toruseo This is now ready for an initial review, before I optimize further. |
Thanks for your hard work. This
For this issue, I want to ensure the backward compatibility. Maybe the index name for non time_bin mode can be just an integer (i.e., drop line 1519). Another related issue is that the index for
Similar indexing mode could be added to As a minor improvement, it is better to accept any numbers (including float) as time_bin argument as it is in seconds. Just doing |
Awesome, I will implement your suggestions later today. |
Implemented and tested! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I forgot to submit the review
I don't really get the test error. It seems a value diff this time? |
This seems to be a real issue. This means that your method says the traffic volume was 9310, whereas the actual number of all vehicles was 6880. Maybe double-counting or something. Pls verify your method very carefully. Traffic volume and other stats in time_bin mode need to be verified as well. And can you include your test code (based on a small, tractable scenario like one in |
Note that we now get vehicle counts from links, which is faster if we iterate over them anyway.
2d857fb
to
ca6d94c
Compare
A huge advantage of calculating I will try to get the count deviation bug fixed this week. |
This commit addresses an issue with traffic volume calculation in the area_to_pandas method of the Analyzer class. Previously, the method was overcounting vehicles, resulting in inflated traffic volume numbers for areas in the network. The main changes include: 1. Modified the process_area function to more accurately count vehicles: - Now counts vehicles entering the area from outside - Also counts vehicles starting their trip within the area - Avoids double-counting vehicles passing through multiple links within the area 2. Updated the traffic volume calculation logic: - Uses two separate queries to identify entering vehicles and vehicles starting their trips within the area - Sums these two values to get the total traffic volume
can you add test for time_bin mode as I instructed? Validity of Analyzer must be very carefully checked, because if its output is corrupted, entire results of the research will be seriously damaged. |
This commit modifies the link_to_pandas function in the analyzer to ensure that the last time bin is always included in the output, even if it's not complete. The change addresses an issue where the final time bin was being omitted when the simulation end time was exactly divisible by the time bin size. - Use math.ceil instead of integer division to calculate the number of bins - This ensures that there's always a bin that includes the final time step - Improves consistency in time-based analysis, especially for simulations where the last time bin is significant
sorry, I missed your last message. Let me check |
Thanks for getting back. Unfortunately, I don’t have time to work on this in the near future. If you are able, feel free to continue work on this PR. My gut tells me it might be either A) some time indexing bug, like not including the first or last time step, B) something to do with when the vehicles get counted on a link, or C) something to do with how the areas are split and links the edges behaving weird, |
okay, I leave this in pending status |
This is related to #143 (comment) |
I don't see me working further on it, but I have successfully used this code in my thesis. So feel free to continue it. |
The current error may be small, but I value perfection for this kind of stats computation. I also dont see me working on this, so let me close this one. |
This PR introduces time-binned analysis capabilities to the
link_to_pandas
andarea_to_pandas
methods in the Analyzer class, while also addressing an issue with traffic volume calculation. These changes allow for more flexible, granular, and accurate analysis of traffic data over time.Changes
Added
time_bin
argument tolink_to_pandas
:time_bin
is None, the method behaves as before.time_bin
is specified, data is aggregated into time bins.Updated
area_to_pandas
to work with time-binned data:link_to_pandas
whentime_bin
is specified.Fixed traffic volume calculation in
area_to_pandas
:Data validation:
traffic_volume
now represents the volume per bin instead of cumulative.total_travel_time
is calculated per bin, which is more logical for a binned approach.Notes
Part of #120.
TODO
link_to_pandas