-
Notifications
You must be signed in to change notification settings - Fork 28
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
[feature] keep forbidden pickup/dropoff on stay in #730
Conversation
(tdd power !)
refactor enhance_pickup_dropoff to keep restrictions set
and add some calendars helpers
I should definitly have split this PR in 2, one for the builder and one for the bug. I can still do it if you prefer. I'd be happy to have a review on the builder's API |
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.
Did not review the model-builder part (vote for a separate PR, as we are not in a hurry to merge any of this work).
👍 Despite remarks on twisted cases, it's better than what we had on staying as it respects data more.
src/model.rs
Outdated
// The stay in is not really possible when timing overlaps | ||
// between arrival of first vehicle journey and departure of | ||
// next vehicle journey (see Example 2 above). | ||
last_stop.departure_time <= first_stop.arrival_time |
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.
If one is past-midnight and the next is at the beginning of the day after, I guess it won't work but it "only" matters for night-bus lines
🙈 becomes a bit too complex for the gain I think.
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.
after giving it some thoughts, past midnight are usually implemented as time > 24h (like "25:00:00"
for 1am) no? and this case is handled no 🤔 ?
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.
It would not be handled I think, as the first VJ would end at 25:00
and the second would start at 02:00
.
They would be possible stay-in, but we wouldn't "see" that.
But that's OK for now (and possibly for ever 😝 )
I do not resolve the comment just to have it quick if we ever come back later to that work to improve those tricky cases.
src/model.rs
Outdated
if can_chain_without_overlap(vj, other_vj) { | ||
allowed_first_drop_off_vj.insert(*other_vj_idx); | ||
allowed_last_pick_up_vj.insert(vj_idx); | ||
} else if can_chain_without_overlap(other_vj, vj) { | ||
allowed_first_drop_off_vj.insert(vj_idx); | ||
allowed_last_pick_up_vj.insert(*other_vj_idx); |
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.
Not sure how twisted this example is (all vjs are on the same block_id, same calendar):
vj1 ends at spA (10:00-11:00)
vj2 starts at spA (10:00-11:00) ends at spB (12:00-13:00)
vj3 starts at spC (14:00-15:00)
Because of vj1-vj3 test, the outcome from your code is that all vj1's last dropoff is allowed at spA which is not what we want, no?
(we would have the same for vj2's first pickup if we had a vj0).
This probably implies building a chain first (tree if you consider calendars), then check what's possible... then decide what matters more in case of conflict (probably being safe and forbid).
And it's actually what's done in Navitia as the next vj is unique and check is done once it's affected.
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.
hum interesting edge case, I don't know if it's a valid GTFS 🤔
I'm not sure it's worth implementing something this tricky as this is meant only for strengthening the data if we do in transit_model
I don't think we should be "safe and forbid" (like we should in navitia) since we are only adding additional constraints on the data. So we should just forbid impossible cases, and if a particular case can happen sometimes but not always, we should let it be possible and be handled by the journey planner
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.
I think this should be split into 2 parts :
- Is it a realistic case to have chained blocks (so every extremity would endup being qualified as a valid stay-in in this algo) ? I think we get block_id corresponding to vehicles, so yes (so an algo without determining "real-life" chains would not change data much from original).
- Is it realistic to have calendars that would make "real-life" chaining of trips being stay-in some days and not stay-in some other days? I think we should not care about that until we have the problem as it's too edgy 🙈 . And OK to stay closer to data in that conflicting case, you make a good point contradicting my "safe" argument.
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.
As discussed:
- Not addressing that for now, so authorize a bit too much pickup/dropoff which is OK (still better to respect data). To be documented but that's all.
- If calendars introduce a contradictory case (stay-in should be authorized on sunday, not on saturday) : authorise to respect data. To be 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.
test added block_id_on_non_overlaping_calendar_with_overlaping_stops
(and I think the current implementation handles it quite nicely after testing it 😜 )
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.
Indeed, it's nice : what's consistent is handle, and what's not stays close to initial data 👍
Letting the discussion unresolved for the "chaining" part if we later come back to that work, but you did all that could reasonably be done ✔️
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.
Overall, it's an improvement since we keep existing values and there is more test. But I feel like there is still a bunch of work to do to make it maintainable.
Co-authored-by: Jean SIMARD <[email protected]>
Co-authored-by: Jean SIMARD <[email protected]>
Co-authored-by: Jean SIMARD <[email protected]>
Co-authored-by: Jean SIMARD <[email protected]>
Co-authored-by: Jean SIMARD <[email protected]>
Co-authored-by: Jean SIMARD <[email protected]>
Co-authored-by: Jean SIMARD <[email protected]>
Co-authored-by: Jean SIMARD <[email protected]>
To bump in |
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.
ModelBuilder interface with default attributes + muter looks fine, and to me we settled on something good for functionnal stay-in part 👍
Not sure about the fallible IntoDate, and didn't look at all @woshilapin's unresolved comments, but that's the only review left before approval.
a86382c
to
156a9a2
Compare
I think I resolved all issues, feel free to poke me again if I missed something (apart from the |
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.
Looks like all is addressed indeed (let @woshilapin check his last opened comments, though)
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.
Still need to bump Cargo.toml
to 0.33.1
at least (or 0.34.0
as @ArnaudOggy suggested, but I would say this is bug fix so 0.33.1
is probably enough). The rest of the PR is good-to-go for me.
No need |
To keep to data as clean as possible, the model was sanitized to add restrictions on drop off at first stop time / pick up at last stop time.
Since for stay in this could remove valid journeys, the pick up at last stop time / drop off at first stop time was possible for stay in.
The previous implementation was removing explicitly set constraints on those stay in stop times.
As a side effect we now also correctly handle restrictions on stay in of different calendars (see example 4)
Note 1: the new implementation is quadratic in term of trip on the same
block_id
. However the number of vj on the same block_id seems quite limited thus the runtime penalty is quite small.I tested it on the bretagne dataset, so biggest dataset I know with block_id (106k trips, 2M+ stoptimes, max number of vehicle journeys with same block_id: 76) there is a small impact on the run time import (not on the memory footprint).
On my computer the best of 3 runs (there are ~1s of difference on the same runs) before: 17s to read the GTFS, after: 18s to read the GTFS.
Note 2:
this reactivate the use of the model_builder and add some utilities to it
internally linked to ND-1088