Composite traffic model: Difference between revisions

From Opasnet
Jump to navigation Jump to search
mNo edit summary
(→‎R model: delay from distance added)
Line 38: Line 38:
library(OpasnetBaseUtils)
library(OpasnetBaseUtils)


roads <- op_baseGetData("opasnet_base", "Op_en2634", apply.utf8 = FALSE)
roads <- op_baseGetData("opasnet_base", "Op_en2634", series_id = 2575, apply.utf8 = FALSE)
colnames(roads)[6] <- "Through"
colnames(roads)[6] <- "Through"


#trips.locs <- op_baseGetLocs("opasnet_base", "Op_en2625", apply.utf8 = FALSE)
distance <- op_baseGetData("opasnet_base", "Op_en5322", include = 14299, exclude = c(53097, 53098))
 
speed <- 40 # kmh^-1
 
tdelay <- distance[distance$Mode == "Car" & distance$Time == "1", c("From", "To", "Result")]
tdelay$Result <- ceiling((tdelay$Result / speed) * n.intervals.per.h) / n.intervals.per.h
colnames(tdelay)[colnames(tdelay) %in% "Result"] <- "Delay"


trips <- op_baseGetData("opasnet_base", "Op_en2625")
trips <- op_baseGetData("opasnet_base", "Op_en2625")


system.time(
for (i in 1:(length(times) - 1)) {
for (i in 1:(length(times) - 1)) {
if(i == 1) {
if(i == 1) {
trips.sample.1 <- trips[trips$Time == times[1],]
trips.sample.1 <- trips[trips$Time == times[1],]
#trips.sample.1 <- op_baseGetData("opasnet_base", "Op_en2625", include = trips.locs$loc_id[trips.locs$ind == "Time" &
# trips.locs$loc == as.character(times[1])])
trips.sample.1$Secondary <- 0
trips.sample.1$Secondary <- 0
} else {
} else {
Line 58: Line 64:
trips.sample.2 <- trips[trips$Time == times[i + 1],]
trips.sample.2 <- trips[trips$Time == times[i + 1],]
#trips.sample.2 <- op_baseGetData("opasnet_base", "Op_en2625", include = trips.locs$loc_id[trips.locs$ind == "Time" &
# trips.locs$loc == as.character(times[i + 1])])
# Optimizer main code
# Optimizer main code
Line 133: Line 137:
# Add transferred passengers to the next time slot as secondary passengers
# Add transferred passengers to the next time slot as secondary passengers
# delay <- distance / speed
trips.left.trans <- merge(trips.left.trans, tdelay)
delay <- 0.2
colnames(trips.left.trans)[5] <- "Secondary"
colnames(trips.left.trans)[5] <- "Secondary"
Line 140: Line 143:
colnames(trips.left.trans)[2] <- "From"
colnames(trips.left.trans)[2] <- "From"
colnames(trips.left.trans)[3] <- "To"
colnames(trips.left.trans)[3] <- "To"
trips.left.trans$Time <- as.character(as.numeric(as.character(trips.left.trans$Time)) + delay)
trips.left.trans$Time <- as.character(as.numeric(as.character(trips.left.trans$Time)) + trips.left.trans$Delay)
trips.left.trans <- as.data.frame(as.table(tapply(trips.left.trans$Secondary, trips.left.trans[,
trips.left.trans <- as.data.frame(as.table(tapply(trips.left.trans$Secondary, trips.left.trans[,
Line 151: Line 154:
trips.out <- rbind(trips.out, data.frame(trips.sample.1[, c("From", "To", "Time")], d8, d4, d3, d2, d1, c8, c4, c3, c2, c1))
trips.out <- rbind(trips.out, data.frame(trips.sample.1[, c("From", "To", "Time")], d8, d4, d3, d2, d1, c8, c4, c3, c2, c1))
}
}
)


# Summary
# Summary
Line 176: Line 180:


{{todo|Ruvetaan keräämään tälle sivulle matskua mallin uudesta versiosta.|Smxb}}
{{todo|Ruvetaan keräämään tälle sivulle matskua mallin uudesta versiosta.|Smxb}}
{{comment|# |Takes below 10 minutes to run. Neat!|--[[User:Teemu R|Teemu R]] 14:08, 2 August 2011 (EEST)}}

Revision as of 11:08, 2 August 2011



This page is about a composite traffic model that is an updated version of File:Composite traffic.ANA. The new version is coded with R.

Definition

Variables

R model

  • Trip aggregator
    • Optimization rules:
  1. No second transfer -> prioritize "secondary" passengers
  2. Fill as many 8-person-vehicles as possible
  3. Fill as many 4-person-vehicles as possible
  4. Special rule: for trips with no possible transfer-point -> direct trip
  5. Transfer the rest (will always be 4-person-vehicles)
  6. Re-check vehicle configurations, when exact numbers of primary and secondary passengers as well as transferees are known

+ Show code

TODO: {{#todo:Ruvetaan keräämään tälle sivulle matskua mallin uudesta versiosta.|Smxb|}}


----#: . Takes below 10 minutes to run. Neat! --Teemu R 14:08, 2 August 2011 (EEST) (type: truth; paradigms: science: comment)