From 04228d19eaf4d2e6c55a47c624f3f9ddcc10d9ed Mon Sep 17 00:00:00 2001 From: Thomas Koch Date: Tue, 16 Dec 2014 21:08:00 +0100 Subject: [PATCH 1/2] Unflag banned journey_patterns after processing transfers Instead of unflagging the updated_journey_patterns bitmask each time we relax a stop, using a transfer. We do this once after processing all transfers --- router.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/router.c b/router.c index f76138e..2bfc0bc 100644 --- a/router.c +++ b/router.c @@ -424,9 +424,6 @@ void apply_transfers (router_t *router, router_request_t *req, state_from->walk_from = stop_index_from; /* assert (router->best_time[stop_index_from] == time_from); */ flag_journey_patterns_for_stop(router, req, stop_index_from); - #if RRRR_MAX_BANNED_JOURNEY_PATTERNS > 0 - unflag_banned_journey_patterns(router, req); - #endif } if (transfer) { @@ -484,13 +481,15 @@ void apply_transfers (router_t *router, router_request_t *req, state_to->walk_from = stop_index_from; router->best_time[stop_index_to] = time_to; flag_journey_patterns_for_stop(router, req, stop_index_to); - #if RRRR_MAX_BANNED_JOURNEY_PATTERNS > 0 - unflag_banned_journey_patterns(router, req); - #endif } } } } + + #if RRRR_MAX_BANNED_JOURNEY_PATTERNS > 0 + unflag_banned_journey_patterns(router, req); + #endif + /* Done with all transfers, reset stop-reached bits for the next round */ bitset_clear (router->updated_stops); /* Check invariant: Every stop reached in this round should have a From 705423120974ab22976ce1e4d15aad5e3d8f9364 Mon Sep 17 00:00:00 2001 From: Thomas Koch Date: Tue, 16 Dec 2014 21:01:15 +0100 Subject: [PATCH 2/2] Fix #148, ban unsuitable journey_patterns at once Instead of high number of non cache-local look-ups for journey_pattern attributes and calendar's, check this once and ban all unsuitable journey_patterns --- router.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/router.c b/router.c index 2bfc0bc..e2a34c5 100644 --- a/router.c +++ b/router.c @@ -192,6 +192,11 @@ static void flag_journey_patterns_for_stop(router_t *router, router_request_t *r if (i_jp == 0) return; do { + #if RRRR_BANNED_JOURNEY_PATTERNS_BITMASK == 1 + /* Don't check whether journeypattern is valid since we banned all unsuitable journey_patterns */ + i_jp--; + bitset_set (router->updated_journey_patterns, journey_patterns[i_jp]); + #else calendar_t jp_active_flags; i_jp--; @@ -212,6 +217,7 @@ static void flag_journey_patterns_for_stop(router_t *router, router_request_t *r /* & journey_pattern_active_flags seems to provide about 14% increase * in throughput */ + if ((router->day_mask & jp_active_flags) && (req->mode & router->tdata->journey_patterns[journey_patterns[i_jp]].attributes) > 0) { bitset_set (router->updated_journey_patterns, journey_patterns[i_jp]); @@ -219,6 +225,7 @@ static void flag_journey_patterns_for_stop(router_t *router, router_request_t *r fprintf (stderr, " journey_pattenr running\n"); #endif } + #endif } while (i_jp); #ifdef RRRR_FEATURE_REALTIME_EXPANDED @@ -255,15 +262,27 @@ static void unflag_banned_journey_patterns (router_t *router, router_request_t * } static void initialize_banned_journey_patterns (router_t *router, router_request_t *req) { + uint32_t i_jp = router->tdata->n_journey_patterns; uint8_t i_banned_jp = req->n_banned_journey_patterns; bitset_black(router->banned_journey_patterns); + do { + calendar_t jp_active_flags; + i_jp--; + jp_active_flags = router->tdata->journey_pattern_active[i_jp]; + + if (! ( router->day_mask & jp_active_flags && + req->mode & router->tdata->journey_patterns[i_jp].attributes)) { + /* Journey is invalid on selected days and/or attributes */ + bitset_unset (router->banned_journey_patterns,i_jp); + } + } while (i_jp); + if (i_banned_jp == 0) return; do { i_banned_jp--; - bitset_unset (router->banned_journey_patterns, - req->banned_journey_patterns[i_banned_jp]); + bitset_unset (router->banned_journey_patterns,req->banned_journey_patterns[i_banned_jp]); } while (i_banned_jp); } #else