# traffic 3

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## WHAT IS IT?

This model models the movement of cars on a highway. Each car follows a simple set of rules: it slows down (decelerates) if it sees a car close ahead, and speeds up (accelerates) if it doesn't see a car ahead. The model demonstrates how traffic jams can form even without any accidents, broken bridges, or overturned trucks. No "centralized cause" is needed for a traffic jam to form.

## HOW TO USE IT

Click on the SETUP button to set up the cars.

Set the NUMBER-OF-CARS slider to change the number of cars on the road.

Click on GO to start the cars moving. Note that they wrap around the world as they move, so the road is like a continuous loop.

The ACCELERATION slider controls the rate at which cars accelerate (speed up) when there are no cars ahead.

When a car sees another car right in front, it matches that car's speed and then slows down a bit more. How much slower it goes than the car in front of it is controlled by the DECELERATION slider.

## THINGS TO NOTICE

Traffic jams can start from small "seeds." These cars start with random positions and random speeds. If some cars are clustered together, they will move slowly, causing cars behind them to slow down, and a traffic jam forms.

Even though all of the cars are moving forward, the traffic jams tend to move backwards. This behavior is common in wave phenomena: the behavior of the group is often very different from the behavior of the individuals that make up the group.

The plot shows three values as the model runs:

the fastest speed of any car (this doesn't exceed the speed limit!)

the slowest speed of any car

the speed of a single car (turtle 0), painted red so it can be watched.

Notice not only the maximum and minimum, but also the variability -- the "jerkiness" of one vehicle.

Notice that the default settings have cars decelerating much faster than they accelerate. This is typical of traffic flow models.

Even though both ACCELERATION and DECELERATION are very small, the cars can achieve high speeds as these values are added or subtracted at each tick.

## THINGS TO TRY

In this model there are three sliders that can affect the tendency to create traffic jams: the initial NUMBER-OF-CARS, ACCELERATION, and DECELERATION.

Look for patterns in how these settings affect the traffic flow. Which variable has the greatest effect? Do the patterns make sense? Do they seem to be consistent with your driving experiences?

Set DECELERATION to zero. What happens to the flow? Gradually increase DECELERATION while the model runs. At what point does the flow "break down"?

## EXTENDING THE MODEL

Try other rules for speeding up and slowing down. Is the rule presented here realistic? Are there other rules that are more accurate or represent better driving strategies?

In reality, different vehicles may follow different rules. Try giving different rules or ACCELERATION/DECELERATION values to some of the cars. Can one bad driver mess things up?

The asymmetry between acceleration and deceleration is a simplified representation of different driving habits and response times. Can you explicitly encode these into the model?

What could you change to minimize the chances of traffic jams forming?

What could you change to make traffic jams move forward rather than backward?

Make a model of two-lane traffic.

## NETLOGO FEATURES

The plot shows both global values and the value for a single car, which helps one watch overall patterns and individual behavior at the same time.

The `watch`

command is used to make it easier to focus on the red car.

The `speed-limit`

and `speed-min`

variables are set to constant values. Since they are the same for every car, these variables could have been defined as globals rather than turtle variables. We have specified them as turtle variables since modifications or extensions to this model might well have every car with its own speed-limit values.

## RELATED MODELS

"Traffic Basic Utility": a version of "Traffic Basic" including a utility function for the cars.

"Traffic Basic Adaptive": a version of "Traffic Basic" where cars adapt their acceleration to try and maintain a smooth flow of traffic.

"Traffic Basic Adaptive Individuals": a version of "Traffic Basic Adaptive" where each car adapts individually, instead of all cars adapting in unison.

"Traffic 2 Lanes": a more sophisticated two-lane version of the "Traffic Basic" model.

"Traffic Intersection": a model of cars traveling through a single intersection.

"Traffic Grid": a model of traffic moving in a city grid, with stoplights at the intersections.

"Traffic Grid Goal": a version of "Traffic Grid" where the cars have goals, namely to drive to and from work.

"Gridlock HubNet": a version of "Traffic Grid" where students control traffic lights in real-time.

"Gridlock Alternate HubNet": a version of "Gridlock HubNet" where students can enter NetLogo code to plot custom metrics.

## HOW TO CITE

If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

- Wilensky, U. (1997). NetLogo Traffic Basic model. http://ccl.northwestern.edu/netlogo/models/TrafficBasic. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Please cite the NetLogo software as:

- Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

## COPYRIGHT AND LICENSE

Copyright 1997 Uri Wilensky.

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.

This model was developed at the MIT Media Lab using CM StarLogo. See Resnick, M. (1994) "Turtles, Termites and Traffic Jams: Explorations in Massively Parallel Microworlds." Cambridge, MA: MIT Press. Adapted to StarLogoT, 1997, as part of the Connected Mathematics Project.

This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2001.

## Comments and Questions

globals [ sample-car ] turtles-own [ speed speed-limit speed-min ] to setup clear-all ask patches [ set pcolor random 1.5 + yellow] ask patches [ setup-road ] draw-line 0 black 0.5 draw-line 6 black 0.5 setup-cars ;watch sample-car reset-ticks end to setup-road ;; patch procedure if pycor <= 2 and pycor >= -2 [ set pcolor white ] if pycor >= 4 and pycor <= 8 [ set pcolor white ] if pycor = 3 [ set pcolor green] if pycor = 4 or pycor = 8 [ set pcolor grey ] if pycor = 2 or pycor = -2 [ set pcolor grey ] end to draw-line [ y line-color gap ] create-turtles 1 [ setxy (min-pxcor - 0.5) y ; hide-turtle set color line-color set heading 90 repeat world-width [ pen-up forward gap pen-down forward (1 - gap) ] die ] end to setup-cars if number-of-cars > world-width [ user-message (word "There are too many cars for the amount of road. " "Please decrease the NUMBER-OF-CARS slider to below " (world-width + 1) " and press the SETUP button again. " "The setup has stopped.") stop ] set-default-shape turtles "car" create-turtles number-of-cars [ set color blue set xcor random-xcor set ycor random (1 - 3) set heading 90 ;; set initi9al speed to be in range 0.1 to 1.0 set speed 0.1 + random-float 0.9 set speed-limit 1 set speed-min 0 separate-cars ] set-default-shape turtles "car2" create-turtles number-of-cars [ set color brown set xcor random-xcor set ycor 6 set heading 270 ;; set initi9al speed to be in range 0.1 to 1.0 set speed 0.1 + random-float 0.9 set speed-limit 1 set speed-min 0 separate-cars ] set sample-car one-of turtles ask sample-car [ set color red ] end ; this procedure is needed so when we click "Setup" we ; don't end up with any two cars on the same patch to separate-cars ;; turtle procedure if any? other turtles-here [ fd 1 separate-cars ] end to go ;; if there is a car right ahead of you, match its speed then slow down ask turtles [ let car-ahead one-of turtles-on patch-ahead 1 ifelse car-ahead != nobody [ slow-down-car car-ahead ] [ speed-up-car ] ;; otherwise, speed up ;; don't slow down below speed minimum or speed up beyond speed limit if speed < speed-min [ set speed speed-min ] if speed > speed-limit [ set speed speed-limit ] fd speed ] tick end to slow-down-car [ car-ahead ] ;; turtle procedure ;; slow down so you are driving more slowly than the car ahead of you set speed [ speed ] of car-ahead - deceleration end to speed-up-car ;; turtle procedure set speed speed + acceleration end

There is only one version of this model, created 9 months ago by sura jasim.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

traffic 3.png | preview | Preview for 'traffic 3' | 9 months ago, by sura jasim | Download |

This model does not have any ancestors.

This model does not have any descendants.