Routing models usually find either the fastest or the cheapest route.
Accounting for both time and monetary cost at once is hard, because
minimizing trip duration and minimizing cost are competing objectives
(Conway and Stewart 2019). To address this
problem, r5r’s pareto_frontier() returns the
most efficient combinations of travel time and monetary cost between
origin/destination pairs. This vignette shows, with a reproducible
example, how to use it and interpret its results.
pareto_frontier means.Imagine a trip from A to B with several route alternatives (figure below):
These options form the Pareto frontier of routes from A to B: no route is both faster and cheaper than any route on the frontier. On the frontier, a trip cannot be made faster without costing more, nor cheaper without taking longer.
The frontier shows the time-cost trade-offs that public transport
passengers face. It also supports cumulative-opportunity accessibility
metrics with both time and cost cutoffs (e.g. the number of jobs
reachable within 40 minutes and R$ 5) (Conway and
Stewart 2019). Let’s see a couple concrete examples showing how
r5r can calculate the Pareto frontier for multiple
origins.
pareto_frontier().build_network()We use the Porto Alegre (Brazil) sample data included in
r5r.
# increase Java memory
options(java.parameters = "-Xmx2G")
# load libraries
library(r5r)
library(data.table)
library(ggplot2)
library(dplyr)
# build a routable transport network with r5r
data_path <- system.file("extdata/poa", package = "r5r")
r5r_network <- build_network(data_path)
# routing inputs
mode <- c('walk', 'transit')
max_trip_duration <- 90 # minutes
# load origin/destination points of interest
points <- fread(file.path(data_path, "poa_points_of_interest.csv"))R5 computes the monetary cost of each route from the
fare rules of the public transport system. In Porto Alegre:
A fare structure with these rules ships with r5r, so we
simply read it. The fare
structure vignette shows how to build one step by step.
pareto_frontier().We compute the Pareto frontier from all origins to all destinations with these monetary cost cutoffs:
departure_datetime <- as.POSIXct("13-05-2019 14:00:00",
format = "%d-%m-%Y %H:%M:%S")
prtf <- pareto_frontier(
r5r_network,
origins = points,
destinations = points,
mode = c("WALK", "TRANSIT"),
departure_datetime = departure_datetime,
fare_structure = fare_structure,
fare_cutoffs = c(1, 4.5, 4.8, 7.20, 8.37),
progress = TRUE
)
head(prtf)For illustration, the Pareto frontiers between the Farrapos train station and (a) the Praia de Belas shopping mall and (b) the Moinhos hospital:
Stop the network and run Java’s garbage collector to free the memory it used:
If you have any suggestions or want to report an error, please visit the package GitHub page.