ipeaGIT / r5r

https://ipeagit.github.io/r5r/
Other
176 stars 27 forks source link

Odd combinations of transport modes #63

Closed mvpsaraiva closed 3 years ago

mvpsaraiva commented 4 years ago

Our heuristic for turning one parameter mode into the 4 parameters R5 uses (direct_mode, transit_mode, access_mode and egress_mode) sometimes generates odd path options. For example, should we consider options such as driving to the bus stop, then taking the bus, and then driving again to the destination?

Example:

library("r5r")
library("ggplot2")

# Start R5R core
r5r_core <- setup_r5(system.file("extdata", package = "r5r"), verbose = FALSE)

# Load points of interest
points <- read.csv(system.file("extdata/poa_points_of_interest.csv", package = "r5r"))

# Configuring trip
origin <- points[10,] # Farrapos train station
destination <- points[12,] # Praia de Belas shopping mall

trip_date_time <- lubridate::as_datetime("2019-03-20 14:00:00")

max_walk_distance = 0.8
max_trip_duration = 120L

paths_df <- detailed_itineraries(r5r_core = r5r_core,
                                 origins = origin, destinations = destination,
                                 departure_datetime = trip_date_time,
                                 max_walk_dist = max_walk_distance,
                                 max_trip_duration = max_trip_duration,
                                 mode = c("WALK", "BICYCLE", "CAR", "BUS"),
                                 shortest_path = FALSE, verbose = FALSE)

paths_df %>%
  ggplot() +
  geom_sf(aes(colour=mode)) +
  facet_wrap(~option)
dhersz commented 4 years ago

What exactly means to have CAR as access and egress mode? How does a CAR direct trip with WALK as access and egress mode differs from the same trip, but with CAR as access and egress?

From what I can see in the paths_df it looks like that acess and egress are only relevant when the options refers to a transit route. Which leads me to think that we don't need to set CAR as a access and egress mode at all, since it won't affect CAR direct trips, and would solve the issue.

Do you agree?

PS: I created a test-utils file with some tests for the supporting functions. Once we agree on this I'll create some tests to check the output of select_mode.

dhersz commented 4 years ago

I have added a quick and (hopefully) temporary fix to this. Now in the case the algorithm selects CAR and BICYCLE as possible egress modes, those are removed in the end.

I'm leaving this issue open because we have to understand some nuances of the modes better to refine select_mode:

dhersz commented 4 years ago

A bit of research on the modes:

DIRECT MODES

ACCESS MODES

EGRESS MODES

BICYCLE_RENT

To use BICYCLE_RENT, we have to:

CAR_PARK

OSM ways and nodes must have tag "park_ride". Glimpsed through some garages and parking spots located within our sample pbf and I don't think any of them have it, so we'll need to find some data to test this.

Time to stop with CAR_PARK mode equals to:

BICYCLE_RENT and CAR_PARK costs

These can be found here.

rafapereirabr commented 3 years ago

I've done some tests (see primary input below). Belor are the trave time estimates for the following combination of modes.

The take away message is that both access and egress modes are important for pretty much all combinations. I suggest we use as the default simple combinations of modes (assuming egress is always walking), but we also giver users the flexibility to choose a more complex combinations. The question is how to keep this simple for the user.

Simple combinations (DEFAULT): (assumes the person will always walk after hopping off from the public transport)

More complex combinations (assumes the person will have access to another mode after hopping off from the public transport)

Travel time estimates

:walking: = 154 minutes 'direct_modes' = "WALK" 'transit_mode' = "" 'access_mode' = "WALK" 'egress_mode' = "WALK"

:walking: + :bus: + :walking: = 66 minutes 'direct_modes' = "WALK" 'transit_mode' = "TRANSIT..." 'access_mode' = "WALK" 'egress_mode' = "WALK"

:walking: + :bus: + :bicyclist: = 62 minutes 'direct_modes' = "WALK" 'transit_mode' = "TRANSIT..." 'access_mode' = "WALK" 'egress_mode' = "BICYCLE"

:bicyclist: + :bus: + :walking: = 51 minutes 'direct_modes' = "BICYCLE" 'transit_mode' = "TRANSIT..." 'access_mode' = "BICYCLE" 'egress_mode' = "WALK"

:bicyclist: + :bus: + :bicyclist: = 48 minutes 'direct_modes' = "BICYCLE" 'transit_mode' = "TRANSIT..." 'access_mode' = "BICYCLE" 'egress_mode' = "WALK"

:walking: + :bus: + :car: = 28 minutes 'direct_modes' = "WALK" 'transit_mode' = "TRANSIT..." 'access_mode' = "WALK" 'egress_mode' = "CAR"

:car: + :bus: + :walking: = 18 minutes 'direct_modes' = "CAR" 'transit_mode' = "TRANSIT..." 'access_mode' = "CAR" 'egress_mode' = "WALK"

:car: + :bus: + :car: = 18 minutes 'direct_modes' = "CAR" 'transit_mode' = "TRANSIT..." 'access_mode' = "CAR" 'egress_mode' = "CAR"

Primary input:

# load origin/destination points
data_path <- system.file("extdata/poa", package = "r5r")
points <- read.csv(file.path(data_path, "poa_hexgrid.csv"))
r5r_core <- setup_r5(data_path = data_path)
departure_datetime <- as.POSIXct("13-05-2019 14:00:00", format = "%d-%m-%Y %H:%M:%S")

# estimate travel time matrix
travel_time_matrix(r5r_core,
                          origins = points[120,],
                          destinations = points[10,],
                          departure_datetime = departure_datetime,
                          max_walk_dist = Inf,
                          max_trip_duration = 1200L)

# variations of mode combinations
mode_list <- list('direct_modes' = "WALK",
                  'transit_mode' = "TRANSIT;TRAM;SUBWAY;RAIL;BUS;FERRY;CABLE_CAR;GONDOLA;FUNICULAR",
                  'access_mode'  = "WALK",
                  'egress_mode'  = "WALK")