knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(sf) library(mapview) mapviewOptions( vector.palette = colorRampPalette( c("#000004FF", "#420A68FF", "#932667FF", "#DD513AFF", "#FCA50AFF", "#FCFFA4FF") ) )
Tool for placing virtual stations in demand-responsive transport systems in villages by defining and minimizing a global energy (drtplanr
, name is inspired by stplanr). The station locations are randomly initialized in the street network and iteratively optimized based on the reachable population in combination with walking and driving times.
The model in the package example optimizes the positions of virtual stations in an assumed on-demand shuttle service for the community of Jegenstorf in Bern, Switzerland.
library(drtplanr) set.seed(123)
Load the package example data sets:
aoi <- sf::st_read(system.file("example.gpkg", package="drtplanr"), layer = "aoi") pop <- sf::st_read(system.file("example.gpkg", package="drtplanr"), layer = "pop") m <- mapview(aoi, alpha.region = 0, layer.name = "AOI", homebutton = FALSE) + mapview(pop, zcol = "n", alpha = 0, layer.name = "Population", homebutton = FALSE) m
Create a new demand reponsive transport model for the aoi 'Jegenstorf', with 10 randomly initialized virtual on-demand stations.
m <- drt_drtm( model_name = "Jegenstorf", aoi = aoi, pop = pop, n_vir = 15, m_seg = 100 ) m
Iterate the model 100 times, where every iteration consists of:
m1 <- drt_iterate(m, 100)
m1 <- drt_iterate(m, 100)
Print model summary:
m1
drt_plot(m1)
drt_map(m1)
The model state is saved in the model. This allows making copies and store different stages of the optimization.
m2 <- drt_import( system.file("Jegenstorf_i1000.RData", package="drtplanr") )
m2 <- drt_iterate(m1, 900)
Print model summary:
m2
drt_plot(m2)
drt_map(m2)
The drtplanr has functions to import and export the drtm objects. Furthermore graphics of the energy plot and the station map can be exported as images (.png).
# Export model drt_export(m2, path = getwd()) # Import model m2 <- drt_import("Jegenstorf_i1000.RData") # Save graphics drt_save_graphics(m2, path = getwd())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.