Withinday feedback tables - smart-fm/simmobility-prod GitHub Wiki

The feedbacks can be explained using the flowchart shown below:

Feedback for Pre-day Usage

After running the withinday and supply, its travel time outputs are aggregated into zonal level and are used to update travel times and costs in the skim matrices. These updated skim matrices are then used by preday to generate the activity schedules for another day. This feedback can be enabled using the subtrip_metrics in simrun_Midterm.xml

We have a python program named - TravelTimeAggregator.py which is responsible for this feedback. This script takes the subtrip_metrics.csv file (output from supply) as input and updates the specified skim matrices and zone-to-zone travel times tables. The database connection information and table names can be configured easily in the first few lines of the python program.

The program resides under the scripts directory of the simmobility code base and can be executed from a terminal as follows.

python TravelTimeAggregator.py subtrip_metrics.csv

Running the TravelTimeAggregator table updates the two sets of network skim tables.

  • The first set comprises three tables- demand.learned_amcosts, demand.learned_pmcosts and demand.learned_opcosts. These tables contain estimates of zone-to-zone mean travel times, based on the start time. The temporal granularity is AM/PM/Off-peak portions of a typical day.
  • The second set comprises two tables- demand.tcost_bus and demand.tcost_car. These tables contain estimates of zone-to-zone mean travel times, based on the start time. The temporal granularity is 30 minutes.

Feedback for Within-day Usage

There are many parameters that SimMobility agents use to evaluate the utility of paths in their pathset when performing route choice. The most important parameter for private route choice is the travel time, whereas public transit route choice additionally considers factors like waiting time at PT stops and accessibility of the stops from the origin and destination etc.

One key feature of SimMobility supply is that the performance of the network is tracked and preserved across simulations. This information is used by the agents in withinday to choose routes for their trips. There are two important tables which help SimMobility agents to perform route choices. Both tables are kept in the supply schema of the simmobility database.

  • link_travel_time table stores time dependent link travel times
  • pt_stop_stats table stores time dependent waiting times, dwell times, number of arrivals and number of boardings for each public transit stop

Both these tables are internal feedback tables from supply to withinday. The outputs generated by supply from one simulation is averaged with the current values in these tables to form the input to the subsequent withinday simulation.

link_travel_time

The simmobility [road network] (https://github.com/smart-fm/simmobility-prod/wiki/SimMobility-road-network) consists of links which represent unidirectional roads connecting a pair of nodes in the network.

For every pair of links (x,y) where the to-node of link x is the from-node of link y and there exists a turning group connecting link x to link y, and for every five minute interval i of the day , the link_travel_time table stores the (expected) travel time for link x if an agent enters link x in interval i and eventually wants to enter to link y as per his path.

The structure of the table are explained below.

column description
link_id link id
downstream_link_id id of an immediate downstream link
start_time start time of 5 minute interval
end_time end time of 5 minute interval
travel_time link travel time. Unit: seconds

Initially, when a new [activity schedule] (https://github.com/smart-fm/simmobility-prod/wiki/Day-activity-schedule) (demand) is given, default link travel times are assumed for the entire day based on the free flow speed and length of the link . To be precise, we add up the travel times computed based on the maximum speed and length for each segment of a link to obtain the default travel time for the link. After every run of withinday simulations, the link travel times experienced by each vehicle is written into an [output] (https://github.com/smart-fm/simmobility-prod/wiki/Mid-Term-Output#link_travel_timetxt) file. This output is then fed back into the link travel time table. The time dependent travel times for each link written into this output is averaged with the current values in this table using a postgresql function (stored procedure) in the simmobility database as shown in the sample sql statement below.

select * from upsert_realtime('/full/path/to/output/file','supply.link_travel_time',0.5);

upsert_realtime() is the postgresql function developed for averaging the travel times from the latest simulation with the values in the table. This function takes three arguments.

  1. The complete directory path to the output file (with file name) from the system root.
  2. The name of the link travel times table to update (with schema name).
  3. The averaging weight given to the new travel times from the output file. Permissible values are in the range [0,1]. Values more than 0.5 will give proportionately more weightage to the new travel times from the output file and values less than 0.5 will give more weightage to existing values in the table.

The feedback can also be carried out using a python script called scripts/python/upsert_link_travel_time.py. The usage is shown below: This python script takes three arguments:

  1. The complete directory path to the output file (with file name) from the system root.
  2. The name of the link travel times table to update (with schema name).
  3. The averaging weight given to the new travel times from the output file(called the alpha value). Permissible values are in the range [0,1]. Alpha values more than 0.5 will give proportionately more weightage to the new travel times from the output file and alpha values less than 0.5 will give more weightage to existing values in the table. An example of the usage: python2.7 upsert_link_travel_time.py link_travel_time.csv supply.link_travel_time 0.4

This python script is called by the C++ code base when the link travel time feedback tag is set to be true

For subsequent simulations, this updated link_travel_time table provides guidance for private and public transit route choice by allowing agents to estimate travel times of the paths in their pathset.

pt_stop_stats

For every five minute interval of the day, for every bus/train line and for every bus stop/train station, the pt_stop_stats table tracks average dwell time and number of arrivals of the bus/train line. It also tracks the average waiting time and number of persons boarding at each stop for each bus/train line for every interval.

The structure of the table is described below.

column description
interval_id index of a 5 minute interval in a day
stop_code PT stop/station code
pt_line PT line id
avg_wait_time average waiting time at the stop for this PT line if traveller arrival time at stop is in this interval
avg_dwell_time average dwell time of buses/trains at the stop for this PT line if it arrives at the stop in this interval
num_pt_arrivals number of buses/trains which arrived at this stop in this interval
num_persons_boarding number of individuals who boarded this pt line at this interval

pt_stop_stats is also a supply to withinday feedback, like the link travel times table. After every simulation run, the supply produces a [pt stop stats] (https://github.com/smart-fm/simmobility-prod/wiki/Mid-Term-Output#ptstopstatscsv) output file. Similar to link_travel_time table, pt_stop_stats table also has a postgres function to average the statistics output from supply to the current values in the table. Below is a example of how to perform this feedback.

select * from update_stop_stats('/full/path/to/output/file','supply.pt_stop_stats',0.5);

update_stop_stats() is the postgresql function developed for averaging public transit stop stats output into this table. It takes three arguments.

  1. The complete directory path to the pt stop stats output file (with file name) from the system root.
  2. The name of the pt stop stats database table to update (with schema name).
  3. The averaging weight given to the new statistics from the output file. Permissible values are in the range [0,1]. Values more than 0.5 will give proportionately more weightage to the new stats from the output file and values less than 0.5 will give more weightage to existing values in the table.

The updated pt_stop_stats table is then used as input for subsequent simulations to guide the public transit route choices of SimMobility agents.

The feedback can also be carried out using a python script called scripts/python/upsert_PT_stop_stats.py. xThis script updates 4 variables in total (avg_wait_time, avg_dwell_time, num_bus_arrivals and num_persons_boarding). The usage is shown below: This python script takes three arguments:

  1. The complete directory path to the output file (with file name) from the system root.
  2. The name of the pt_stop_stats table to update (with schema name).
  3. The averaging weight given to the new values from the output file. Permissible values are in the range [0,1]. Alpha values more than 0.5 will give proportionately more weightage to the new values from the output file and alpha values less than 0.5 will give more weightage to existing values in the table. An example of the usage: python2.7 upsert_PT_stop_stats.py ptstopstats.csv supply.pt_bus_stop_stats 0.4

This python script is called by the C++ code base when the pt_stop_stats feedback tag is set to be true