library(tidyverse) library(tidyr) library(stringr) library(xml2) # compile a big file of baseline, and doubling capacity, with and without one lane less, short termm and long term # baseline ----------------------------- baseline <- read_csv("output/experiments-pieter/set4/baseline/analysis/linkCounts.csv") %>% tibble() %>% rename(lt = volume) %>% mutate(st=lt) baseline_cap <- read_xml( "output/experiments-pieter/set4/baseline/duesseldorf-25pct-dc_114-no-lanes.output_network.xml.gz" ) baseline_cap <- tibble( id = baseline_cap %>% xml_find_all("//link") %>% xml_attr("id"), cap_st = baseline_cap %>% xml_find_all("//link") %>% xml_attr("capacity"), cap_lt = baseline_cap %>% xml_find_all("//link") %>% xml_attr("capacity") ) # donothing ----------------------------- donothing <- read_csv("output/experiments-pieter/set4/lt-donothing/analysis/linkCounts.csv") %>% tibble() %>% rename(lt = volume) %>% left_join( read_csv("output/experiments-pieter/set4/st-donothing/analysis/linkCounts.csv") %>% tibble() %>% rename(st = volume) ) donothing_cap_lt <- read_xml( "output/experiments-pieter/set4/lt-donothing/duesseldorf-25pct-dc_114-no-lanes.output_network.xml.gz" ) donothing_cap_st <- read_xml( "output/experiments-pieter/set4/st-donothing/network.xml.gz" ) donothing_cap <- tibble( id = donothing_cap_lt %>% xml_find_all("//link") %>% xml_attr("id"), cap_lt = donothing_cap_lt %>% xml_find_all("//link") %>% xml_attr("capacity") ) %>% left_join( tibble( id = donothing_cap_st %>% xml_find_all("//link") %>% xml_attr("id"), cap_st = donothing_cap_st %>% xml_find_all("//link") %>% xml_attr("capacity") ) ) # reduce ----------------------------- reduce <- read_csv("output/experiments-pieter/set4/st-reduce/analysis/linkCounts.csv") %>% tibble() %>% rename(st = volume) reduce_cap_lt <- read_xml( "output/experiments-pieter/set4/lt-reduce/network.xml.gz" ) reduce_cap_st <- read_xml( "output/experiments-pieter/set4/st-reduce/network.xml.gz" ) reduce_cap <- tibble( id = reduce_cap_lt %>% xml_find_all("//link") %>% xml_attr("id"), cap_lt = reduce_cap_lt %>% xml_find_all("//link") %>% xml_attr("capacity") ) %>% left_join( tibble( id = reduce_cap_st %>% xml_find_all("//link") %>% xml_attr("id"), cap_st = reduce_cap_st %>% xml_find_all("//link") %>% xml_attr("capacity") ) ) # bikelane ----------------------------- bikelane <- read_csv("output/experiments-pieter/set4/lt-bikelane/analysis/linkCounts.csv") %>% tibble() %>% rename(lt = volume) %>% left_join( read_csv("output/experiments-pieter/set4/st-bikelane/analysis/linkCounts.csv") %>% tibble() %>% rename(st = volume) ) bikelane_cap_lt <- read_xml( "output/experiments-pieter/set4/lt-bikelane/network.xml.gz" ) bikelane_cap_st <- read_xml( "output/experiments-pieter/set4/st-bikelane/network.xml.gz" ) bikelane_cap <- tibble( id = bikelane_cap_lt %>% xml_find_all("//link") %>% xml_attr("id"), cap_lt = bikelane_cap_lt %>% xml_find_all("//link") %>% xml_attr("capacity") ) %>% left_join( tibble( id = bikelane_cap_st %>% xml_find_all("//link") %>% xml_attr("id"), cap_st = bikelane_cap_st %>% xml_find_all("//link") %>% xml_attr("capacity") ) ) # output ----------------------------- write.csv( baseline %>% left_join(baseline_cap), "projects/komodnext/website/two_corridors/baseline_volume.csv", row.names = F, quote = F ) write.csv( bikelane %>% left_join(bikelane_cap), "projects/komodnext/website/two_corridors/bikelane_volume.csv", row.names = F, quote = F ) write.csv( donothing %>% left_join(donothing_cap), "projects/komodnext/website/two_corridors/donothing_volume.csv", row.names = F, quote = F ) write.csv( reduce %>% left_join(reduce_cap), "projects/komodnext/website/two_corridors/reduce_volume.csv", row.names = F, quote = F ) # travel times ----------------------------- corridor <- read_csv("scenarios/input/northeast_corridor_grafenberger_allee.csv") %>% select(id = ID) traveltimes <- read_csv("output/experiments-pieter/set4/baseline/analysis/linkTimesVolumes.csv") %>% tibble() %>% select(id = linkId, time, tt = avgTravelTime) %>% right_join(corridor) %>% mutate(hour = round(time / 3600)) %>% group_by(id, hour) %>% summarise(baseline = mean(tt)) %>% ungroup() %>% left_join( read_csv( "output/experiments-pieter/set4/lt-bikelane/analysis/linkTimesVolumes.csv" ) %>% tibble() %>% select(id = linkId, time, tt = avgTravelTime) %>% right_join(corridor) %>% mutate(hour = round(time / 3600)) %>% group_by(id, hour) %>% summarise(bikelane = mean(tt)) %>% ungroup() ) %>% left_join( read_csv( "output/experiments-pieter/set4/lt-donothing/analysis/linkTimesVolumes.csv" ) %>% tibble() %>% select(id = linkId, time, tt = avgTravelTime) %>% right_join(corridor) %>% mutate(hour = round(time / 3600)) %>% group_by(id, hour) %>% summarise(donothing = mean(tt)) %>% ungroup() ) tt_out <- traveltimes %>% group_by(hour) %>% summarise(across(baseline:donothing, ~sum(.x, na.rm = T) / 60)) %>% filter(complete.cases(.)) write.csv( tt_out, file = "projects/komodnext/website/two_corridors/longterm_tt.csv", row.names = F, quote = F )