Using bus travel times from a dynamic simulation in a public transport delay function for transit assignment

Technical Note #8

January 2015

Imagine that you have run a dynamic simulation (meso, micro or hybrid) that gives you accurate travel times for transit vehicles that take into account congestion, reserved lanes, signals and transit priority algorithms. Wouldn’t it be nice to use this information to get a more accurate estimation of the stop-to-stop travel time in a macroscopic transit assignment?


Thanks to the integrated modelling environment provided by Aimsun, this is possible. You just have to write a Public Transport Delay function that reads bus travel time from the time series produced by the dynamic simulation.

Public transport assignment


For example:

costCol = None
def pdf( context, line, ptsection ):
	global costCol
	if costCol == None:
		model = ptsection.getModel()
		vehicleType = model.getType("GKVehicle")
		vehicleId = model.getCatalog().findByName("Bus", vehicleType).getId()
		costCol = model.getColumn("DYNAMIC::SRC_GKSection_travelTime_%i" % vehicleId)
	res = 0.0
	fromStop = ptsection.getMaster().getOrigin()
	if fromStop != None:
		sectionLength = fromSection.length2D()
		fromSection = fromStop.getSection()
		fromFraction = (sectionLength - fromStop.getPosition()) / sectionLength
		fromSection = None
	toStop = ptsection.getMaster().getDestination()
	if toStop != None:
		toSection = toStop.getSection()
		toFraction = toStop.getPosition() / toSection.length2D()
		toSection = None
	for section in ptsection.getMaster().getRoute():
		fraction = 1.0
		if fromSection != None and section.getId() == fromSection.getId():
			fraction = fromFraction
		elif toSection != None and section.getId() == toSection.getId():
			fraction = toFraction
		ts = section.getDataValueTS(costCol)
		if ts != None:
			res += ts.getAggregatedValue()/60 * fraction
	if res == 0.0:
		print "No dynamic cost for PT Section %i" % ptsection.getId()
		res = 60.0 * ptsection.getDistance()/1000.0 / 20.0 #km/h
	return res

The function reads the travel time of the last simulation for the bus vehicle type from the section, and since the cost for PT assignment is expressed for PT Sections, i.e. for stop-to-stop segments, it adds it for all sections between stops, calculating a fraction for the first and last section, depending on the position of the bust stops.


An important application of this approach is estimating the effect on distribution and mode split of operational changes made to the transit system, such as the introduction of signal priority and reserved lanes along a corridor.

More technical notes

  • Got a question? Get in touch.

    We are here to help!


Cite Aimsun Next


Aimsun Next 23

Aimsun (2023). Aimsun Next 23 User's Manual, Aimsun Next Version 23.0.0, Barcelona, Spain. Accessed on: July. 19, 2023. [Online].



Aimsun Next 20.0.5

Aimsun (2021). Aimsun Next 20.0.5 User's Manual, Aimsun Next Version 20.0.3, Barcelona, Spain. Accessed on: May. 1, 2021. [In software].
Available: qthelp://

Aimsun Next 23

@manual {​​​​​​​​AimsunManual,

title = {​​​​​​​​Aimsun Next 23 User's Manual}​​​​​,
author = {​​​​​​​​Aimsun}​​​​​​​​,
edition =  {​​​​​​​​​​​​​​​Aimsun Next 23.0.0}​​​​​​​​​​​​​​​,
address = {​​​​​​​​​​​​​​​Barcelona, Spain}​​​​​​​​​​​​​​​,
year  = {​​​​​​​​​​​​​​​2023. [Online]}​​​​​​​​​​​​​​​,
month = {​​​​​​​​​​​​​​​Accessed on: Month, Day, Year}​​​​​​​​​​​​​​​,
url = {​​​​​​​​​​​​​​​}​​​​​​​​​​​​​​​,

Aimsun Next 20.0.5

@manual {​​​​​​​​AimsunManual,

title = {​​​​​​​​Aimsun Next 20.0.5 User's Manual}​​​​​​​​,
author = {​​​​​​​​Aimsun}​​​​​​​​,
edition =  {​​​​​​​​​​​​​​​Aimsun Next 20.0.5}​​​​​​​​​​​​​​​,
address = {​​​​​​​​​​​​​​​Barcelona, Spain}​​​​​​​​​​​​​​​,
year  = {​​​​​​​​​​​​​​​2021. [In software]}​​​​​​​​​​​​​​​,
month = {​​​​​​​​​​​​​​​Accessed on: Month, Day, Year}​​​​​​​​​​​​​​​,
url = {​​​​​​​​​​​​​​​qthelp://}​​​​​​​​​​​​​​​,

Aimsun Next 23

T1  - Aimsun Next 23 User's Manual
A1  - Aimsun
ET - Aimsun Next Version 23.0.0
Y1  - 2023
Y2 - Accessed on: Month, Day, Year
CY  - Barcelona, Spain
PB  - Aimsun
UR  - [In software]. Available:

Aimsun Next 20.0.5

T1  - Aimsun Next 20.0.5 User's Manual
A1  - Aimsun
ET - Aimsun Next Version 20.0.5
Y1  - 2021
Y2 - Accessed on: Month, Day, Year
CY  - Barcelona, Spain
PB  - Aimsun
UR  - [In software]. Available: qthelp://