Closed koch-t closed 11 years ago
This is not surprising. The original algorithm assumes trips on a route are FIFO. This is not a sound assumption when real-time updates are in effect, so we have already improved on this by not assuming that trips are FIFO up to the boarding stop (all trips are considered at the boarding stop). However, downstreamof boarding we continue to assume they are FIFO.
This is equivalent to the assumption that the passenger will board the first bus that arrives on a line rather than waiting for the second bus on a given line based on travel advice telling them the second bus will overtake the first. Honestly 1) I doubt anyone would believe such advice, and 2) do you know of any real-world example of overtaking by vehicles on the same JourneyPattern on the same day?
-Andrew
You're right.
Then again this can really happen when we apply real-time data.
It can happen but it near-certainly means the realtime data is messed up, so we are effectively assuming the passenger will take the first vehicle of that line which passes, which is exactly what every normal passenger will do.
Well it doesn't happen that often but overtaking within a journeypattern surely can happen without messed up real-time data. Think of a bus that breaks down but continues after 10 minutes on a very high-frequency line.
Yes it does happen. But how should/would that affect planning? At all locations upstream of the breakdown, the breakdown situation is not known because it has not happened yet. At all locations downstream of the breakdown, the trips are still FIFO. This is the behavior I'm counting on: make sure a trip has not fallen behind (do not assume trip ordering is the same later in the trip as it is at the beginning of the trip), but also assume that once the delayed vehicle has resumed its course it will not pass vehicles ahead of it on the route, or more importantly assume that the passenger's mental model is such, and that there's no point defying it.
There is also another way of "fixing" this test, at least making sure there is the chance of this happening in real life is almost zero. Just add the route_id to pattern_signature in gtfsdb.py, we need distinct route_id's anyway per journey pattern if we want to continue assigning metadata to a route.
--- ../bliksem2/gtfsdb.py 2013-07-29 18:54:27.928960423 +0200
+++ gtfsdb.py 2013-07-31 10:28:03.997866574 +0200
@@ -397,13 +397,14 @@
if reporter and i%(n_trips//50+1)==0: reporter.write( "%d/%d trips grouped by %d patterns\n"%(i,n_trips,len(bundles)))
d = self.get_cursor()
- d.execute( "SELECT trip_id, arrival_time, departure_time, stop_id FROM stop_times WHERE trip_id=? AND arrival_time NOT NULL AND departure_time NOT NULL ORDER BY stop_sequence", (trip_id,) )
+ d.execute( "SELECT trip_id, arrival_time, departure_time, stop_id,route_id FROM stop_times LEFT JOIN trips using (trip_id) WHERE trip_id = ? AND arrival_time NOT NULL AND departure_time NOT NULL ORDER BY stop_sequence", (trip_id,) )
stop_times = list(d)
- stop_ids = [stop_id for trip_id, arrival_time, departure_time, stop_id in stop_times]
- dwells = [departure_time-arrival_time for trip_id, arrival_time, departure_time, stop_id in stop_times]
- pattern_signature = (tuple(stop_ids), tuple(dwells))
+ stop_ids = [stop_id for trip_id, arrival_time, departure_time, stop_id,route_id in stop_times]
+ dwells = [departure_time-arrival_time for trip_id, arrival_time, departure_time, stop_id,route_id in stop_times]
+ route_id = [route_id for trip_id, arrival_time, departure_time, stop_id,route_id in stop_times][0]
+ pattern_signature = (tuple(stop_ids), tuple(dwells),route_id)
if pattern_signature not in patterns:
pattern = Pattern( len(patterns), stop_ids, dwells )
...but "route" has no semantics at all in GTFS. This change would be counting on Routes to have a meaningful definition.
Well, it might not hurt to add GTFS route to the journeypattern key, as this would justify storing only one route name / headsign etc. per journeypattern (which we already do). It would be pretty insane for a feed producer to create lots of trips with the same sequence of stops and assign them to many different routes.
Well there is semantic regarding vehicle_type for example. The most real-life example i can think of is in Amsterdam where tram and busstops share the same stop_id's. Theoretically this could happen that a tram and a bus route go along the same stops but the tram is faster.
/reply to second reply.
Yes but that is the point, adding route_id,this will add a negligible amount of extra routes but will counter a lot of freak scenarios such as the one in this test. The RID exporter also make trip bundles on the condition, sequence-of-stops, sequence-of-pickupallowed,sequence-of-dropoffallowed,line_id,tripheadsign.
OK you convinced me :+1: I think it's highly unlikely to have two different routes hitting all the same stops in the same order, one faster than the other, but if it does exist they're likely to be marked as different modes/routes, and it's just a more watertight design.
So the test should also be altered to, for example, have the faster overtaking trip be a different mode (Rail) than the slower one (bus), in which case it will pass. And it needs a comment to that effect.
Test 2a1 has four trips along the same route/journeypattern. In both cases there is a longer and shorter variant, the shorter variant departs later but always arrives at the destination first. Ergo the router should always give an arrivaltime of 00:02:00 or 00:05:00. When departing at 00:00:00 we expect to get a intinrary via 2a1|short|1 to arrive at 00:02:00, if that is not possible we expect a trip via 2a1|long|2 to arrive at 00:06:00
NOTE: don't look at the route_id, which is set to the long because it 's the same route and we assign route_id per route.