## How to define speed limits by vehicle class in static models

#### In certain situations, the speed limit can differ according to vehicle type; for instance, on a single-carriageway road in the UK, vehicles over 7.5 tonnes can only travel at 50 miles per hour but other vehicles can travel at 60 miles per hour. You can code this within the delay functions for macroscopic models or through the use of traffic management for microscopic and mesoscopic models as explained in part 1.

For macroscopic models, a vehicle’s travel time (and thus speed) is specified by the volume delay function, turn penalty function and junction delay function. These functions can read parameters such as speed limit to estimate a travel time along a section or turn. To alter the speed by vehicle type, you must therefore make edits within these functions.

For this pro tip, we will code the UK rules on single carriageway roads for a volume delay function. A similar approach would be taken on the turn penalty functions. We will need to check the road type, vehicle type and number of lanes.

To find out the vehicle type being considered, use:

```				```
vehicle = context.userClass.getVehicle()
```
```

To find out the speed limit being considered, use:

```				```
SectionSpeed=section.getSpeed()
```
```

To find out the number of lanes being considered, use:

```				```
NbLanes=section.getNbFullLanes()
```
```

The speed along a section can then be specified using the following function:

```				```
def freeFlowTravelTime(context, section, funcVolume):
model = context.experiment.getModel()
vehicleName = context.userClass.getVehicle().getName()
SectionSpeed=section.getSpeed()
NbLanes=section.getNbFullLanes()
if vehicleName==”HGV” and SectionSpeed==96 and NbLanes==1: #If its a HGV on a single carriageway road with a 96kph/60mph limit
speed=80
else:
speed=SectionSpeed
distance=section.length3D() / 1000.0          # Km
t0 = distance/speed                                 # hour
return t0
```
```

This could be expanded with other vehicle types such as trailered vehicles if necessary.

This freeflowspeed function should then be integrated into the VDF. For example using the BPR function. It is important however to still take into account the delay within the total travel time. We will therefore calculate travel time as the maximum of the volume specific travel time and the vehicle speed limit)

```				```
def freeFlowVehicleTravelTime(context, section, funcVolume):
model = context.experiment.getModel()
vehicleName = context.userClass.getVehicle().getName()
SectionSpeed=section.getSpeed()
NbLanes=section.getNbFullLanes()
if vehicleName==”HGV” and SectionSpeed==96 and NbLanes==1: #If its a HGV on a single carriageway road with a 96kph/60mph limit
speed=80
else:
speed=SectionSpeed
distance=section.length3D() / 1000.0          # Km
t0 = distance/speed                                 # hour
return t0
def freeFlowTravelTime(context, section, funcVolume):
model = context.experiment.getModel()
speed=SectionSpeed
distance=section.length3D() / 1000.0          # Km
t0 = distance/speed                                 # hour
return t0
def vdf( context, section, funcVolume ):
#coefficients alpha and beta must be modified accordingly
alpha = 0.15
beta = 4.0
freeFlowVehicleTravelTime = freeFlowVehicleTravelTime(context, section, funcVolume)
freeFlowTravelTime=freeFlowTravelTime(context, section, funcVolume)
volume = funcVolume.getVolume()
capacity = section.getCapacity()
cost = max(freeFlowTravelTime * (1 + alpha * ((volume + addVolume) / capacity ) ** beta), freeFlowVehicleTravelTime)
return cost
```
```

Don’t forget you can then use table view to apply the function to all sections in the network. This can be found in Window > Windows > Table View. By going to the volume delay function column and changing the bottom row, all sections can be updated.

Set the bottom row to your desired VDF

For more information on scripting and functions, please see  qthelp://aimsun.com.aimsun.20.0/doc/UsersManual/ScriptIntro.html

or attend one of our Scripting courses.

### Importing SCATS traffic signal control data into Aimsun Next

February 2022: The SCATS traffic control system is designed to optimise traffic ﬂow. Dimitris Triantafyllos explains how the SCATS ITS Interface can import data from SCATS ITS into the Aimsun Next network.

### Hybrid Simulation

February 2018: Geline Canayon and Laura Torres give you a brief guided tour through the how, when, where and why of hybrid simulation.

SHARE

### 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].

Available: https://docs.aimsun.com/next/24.0.0/

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 = {https://docs.aimsun.com/next/24.0.0},
}​​​​​​​​​​​​​​​

Aimsun Next 24

TY – COMP
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:
https://docs.aimsun.com/next/24.0.0/