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

How to use Matrix Contents

March 2017: Marga Delgado shows you how to use Contents to group matrices into subfolders, which is particularly convenient when working with multiple matrices.

  • Got a question? Get in touch.

    We are here to help!


Cite Aimsun Next

Aimsun Next 24

Aimsun (2024). Aimsun Next 24 User’s Manual, Aimsun Next Version 24.0.0, Barcelona, Spain. Accessed on: April. 16, 2024. [Online].


Aimsun Next 24

@manual {AimsunManual,
title = {Aimsun Next 24 User’s Manual},
author = {Aimsun},
edition = {Aimsun Next 24.0.0},
address = {Barcelona, Spain},
year = {2024. [Online]},
month = {Accessed on: Month, Day, Year},
url = {},

Aimsun Next 24

T1 – Aimsun Next 24 User’s Manual
A1 – Aimsun
ET – Aimsun Next Version 24.0.0
Y1 – 2024
Y2 – Accessed on: Month, Day, Year
CY – Barcelona, Spain
PB – Aimsun
UR – [In software]. Available: