Automatic model file management
Dimitris Triantafyllos explains how to use the Aimsun Next project folder structure to automatically manage model files.
In certain situations, the speed limit for each vehicle type is different. 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 in Aimsun Next through the use of traffic management for microscopic and mesoscopic models, or within the delay functions for macroscopic models.
For microscopic and mesoscopic models, the speed for a road is set by the “Speed Limit” parameter. This can be reduced for a vehicle class through using a traffic management action called “Speed Reduction”, which you can also use to reduce turn speeds for larger vehicles.
Step 1: Add a traffic condition by going to the Project menu > Traffic Management > New > Traffic Condition
Step 2: Double-click on the Traffic Condition to open it. Select Activation Condition: Always and Apply to Warm up.
Step 3: Add a speed reduction action by right-clicking the Traffic Condition > New > Speed Reduction
Step 4: Select the speed reduction parameters.
In the speed reduction menu, you can specify which section/turn the action is applied to, what the new speed will be and choose to apply the action only to a certain vehicle class. In the example above, the Heavy class has been chosen which includes all vehicle types with vehicles over 7.5t.
The above method is valid for one section or one turn at a time; this would be an arduous task for a model with a large number of roads where HGVs have different speed limits. However, you can also choose to apply a speed change to a grouping of sections, a grouping of turns or a road type.
However, it may be the case that you want to apply a speed reduction to a subset of sections for a road type such as single-carriageway roads with a 60-mile-per-hour speed limit without having these be a separate road type.
The following script can be used to apply a speed reduction action for a given road type while also checking the number of lanes in the section. You need to specify the Traffic Condition name, new speed, vehicle class and road type and number of lanes for which the new speed would apply. The script will then iterate over all sections in the model of the specified road type and add a speed reduction action for each one.
The pseudocode for this is:
Get/Create Traffic Condition
Get vehicle class
For all sections:
If section.roadtype==roadtype and section.numberoflanes:
Create speed reduction action
Add speed reduction to Traffic Condition
'''This script applies a speed reduction for all sections in a road type. The User must specify the road type and the new speed'''
TrafficConditionName="Speed Reduction"
RoadTypeName="SingleCarriageway60" #96kph
VehicleClassName="Heavy Class"
NewSpeed=80 #50mph
NumberofLanes=1
def createSpeedReduction(section,Speed, VehicleClassname): #Add a speed reduction action
change = GKSystem.getSystem().newObject("GKSpeedChange", model)
change.setSection(section)
change.setSpeed(str(Speed)) #set the new speed
VehicleClassType=model.getType("GKVehicleClass")
VehicleClass=model.getCatalog().findByName(VehicleClassname,VehicleClassType)
change.setVehicleClass(VehicleClass) #add a filter for the vehicle class
return change
def NewTrafficCondition():#add a new TrafficConditionName
cmd = model.createNewCmd( model.getType( "GKTrafficCondition" ))
model.getCommander().addCommand( cmd )
res = cmd.createdObject()
res.setActivationType(GKSimulationEvent.eAlways) #set it to be active throughout the modelled period
applyToWarmUpAtt = model.getColumn("GKPolicy::applyOnWarmupAtt") #set it to be active in the warm up
res.setDataValue(applyToWarmUpAtt, QVariant(True))
return res
def GetVehicleClass( model, name): # get the vehicle class object
vehicleClassType=model.getType("GKVehicleClass")
vehicleClass = model.getCatalog().findByName(name, vehicleClassType)
if vehicleClass == None:
print ("No Vehicle Class Found")
return None
return vehicleClass
condition=model.getCatalog().findByName(TrafficConditionName, model.getType("GKTrafficCondition"))
if condition==None: #find condition or add new one
condition=NewTrafficCondition()
condition.setName(TrafficConditionName)
sections=model.getCatalog().getObjectsByType(model.getType("GKSection"))
for section in sections: #for all sections in road type, if the section has x lanes, make a new speed change in the given Traffic Condition
section=sections[section]
nooflanes=section.getNbFullLanes() #get the number of full lanes for this section
if section.getRoadType().getName()==RoadTypeName and nooflanes==NumberofLanes:
speedreductionaction=createSpeedReduction(section,NewSpeed,VehicleClassName)
speedreductionaction.setName("Speed reduction for section %s" %(section.getId()))
condition.addChange(speedreductionaction)
print ("new change")
print ("done")
Lastly, you need to apply the Traffic Condition to the Scenario, whether it has been added via a script or manually; open the scenario object and go to the Strategies and Conditions tab. Tick the new Traffic Condition.
Dimitris Triantafyllos explains how to use the Aimsun Next project folder structure to automatically manage model files.
June 2020: Our new embedded pedestrian simulator is super fast, comes free of charge in the main installer, simulates an unlimited number of pedestrians.
SHARE
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/