Home
Help
Resources
Extensions
FAQ
NetLogo Publications
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Web
Printable
Chinese
Czech
Farsi / Persian
Japanese
Spanish

## NetLogo User Community Models

## 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.
Note: Sometimes it may look that cars touch each other or people go through the cars. It is cause by the size of cars, which is 2. That means the agent is on 1 patch, but the shape i bigger then the patch. You can set up the default size of the car, but it doesn't look well.

## 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.
Pedestrians can walk and also avoid other pedestrians. If there are any other pedestrians in front of them, they turn around slightly and wait for next step. If the variable of an individual WALK-TIME reaches the desired value, they start looking for the nearest crossing. There is waitpoint where they wait and say to vehicles around they want to cross the road. If the crossing is empty or the car stopped, they start crossing the road.

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

### Buttons

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)

### Sliders

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

### Switcher

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)

### Monitor

Waiting pedestrians - show the number of pedestrians waiting on waitpoints for crossing the road

### Plot

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.
You can add lights on crossings. You can improve overtaking, turning on crossroad. You can add some new activities for pedestrians, new rules.
The last thing you can do is to add any fuzzy logic and make this model more interesting.

## 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.
You can also notice the usage of the function STAMP that prints the agent look and then you can kill the agent.

## RELATED MODELS

Before I started I have looked for some related model to get some inspiration how to simulate the traffic or the crowd:
* TrafficBasic by Uri Wilensky
* Traffic Grid by Uri Wilensky
* Traffic Intersection by Uri Wilensky
* Traffic 2 Lanes by Uri Wilensky
* Traffic_dynamics by Francesca De Min and Aurora Patetta
* Traffic with lane changing by Carl Edwards

## CREDITS AND REFERENCES

Author: Jiri Lukas
Email: jirilukas3@seznam.cz