NetLogo User Community Models
Town - Traffic & Crowd simulation
by Jiri Lukas (Submitted: 11/11/2014)
## WHAT IS IT?
This model generates a small part of a town and simulates an interaction between 3 kinds od agents: traffic lights, vehicles and pedestrians. Cars can make their own decisions, they can accelerate, decelerate, change lanes, they can even turn at crossroads. Pedestrians can walk, avoid other pedestrians, cross the road by using crossings. They can communicate with vehicles when crossing the road.Although there are some bugs, this model can be usefull for researching some traffic situations, intervals of traffic lights, traffic flow etc.
## HOW IT WORKS
There are created 2-lane-roads in every direction. Each step, cars try to make a move forward at their current speed. They can accelerate until their maximum speed, based on town speed limit. If there is a slower car in front of them, they match the speed of the slower car and then decelerate, or they can try to change lane and overtake this car.If they want to change the lane, they have to check if there are no other vehicles they could endanger or hit. If there is crossing in front of them, they have to decide whether they will stop and let pedestrians cross the road or they will keep going - every vehicle is unique, in this case they use their variable POLITENESS to make decision. If there is a red traffic light in front of them, they will stop. If there is a green traffic light, they will make decision whether they will turn or keep going. If they are in righ lane, they can turn only right, in left lane they can turn only left. If they are going to turn left, they always check other vehicles in opposite direction to avoid crashes.
## HOW TO USE IT
The town is generated bz using function MODULO, so you can resize your world as you want. But be aware, But the world hast to make up, it means that the roads and lanes must run consecutively to avoid problems when turning.
Setup - it generates the town with pedestrians and cars based on NUM-OF-PEOPLE and NUM-OF-CARS (hotkey S)
Go - runs the model (hotkey G)
num-of-people - sets the number of pedestrians in town (you need to press SETUP button again to change it)
num-of-cars - sets the number of cars in town (you need to press SETUP button again to change it)
lights-interval - sets the interval of traffic lights
acceleration - says how fast cars will accelerate
decelerate - says how fast cars will slow down
speed-limit - sets the speed limit in the town
prob-of-turning - sets the probability of turning, i.e. says how likely cars will turn right/left at crossroad
time-to-crossing - says how long pedestrians have to walk before they start looking for crossing and decide to cross the road
basic-politeness - sets the input value for computing of politeness of cars
turtning-left? - says whether cars will be able to turn left or not (turning left is quite complicated computation that sometimes can slow down the model)
Waiting pedestrians - show the number of pedestrians waiting on waitpoints for crossing the road
Number of waiting pedestrians - displays the number of pedestrians waiting on waitpoints for crossing the road
## THINGS TO TRY
There is lots of opportunities to try. For example try changing BASIC-POLITENESS or LIGHTS-INTERVAL. Does it effect the number of waiting pedestrians? Or what about the number of cars or pedestrians, does it affect the efficiency of the traffic flow?
## EXTENDING THE MODEL
I know there is lots of bugs and the model is quite complicated. There is lots of rules for agents, lots of decisions they make etc. So you can try to optimize the model.
## NETLOGO FEATURES
See how the town is generated. There is used function MODULO. This is on of many ways how to generate the town. With the modulo, you can resize the world as you want, you can have 5000 x 5000 patches and it will still work.
## RELATED MODELS
Before I started I have looked for some related model to get some inspiration how to simulate the traffic or the crowd:
## CREDITS AND REFERENCES
Author: Jiri Lukas
This is my third major project in NetLogo, the first was Checkers Ai vs. Ai (http://ccl.northwestern.edu/netlogo/models/community/Checkers). The second one was Graph_search-DFS_and_BFS (http://ccl.northwestern.edu/netlogo/models/community/Graph_search-DFS_and_BFS).
(back to the NetLogo User Community Models)