NetLogo banner

Home
Download
Help
Resources
Extensions
FAQ
NetLogo Publications
Contact Us
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

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

  Donate

NetLogo Models Library:
IABM Textbook/chapter 5

(back to the library)

Traffic Basic Adaptive Individuals

[screen shot]

If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web

ACKNOWLEDGMENT

This model is from Chapter Five of the book "Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo", by Uri Wilensky & William Rand.

  • Wilensky, U. & Rand, W. (2015). Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo. Cambridge, MA. MIT Press.

This model is in the IABM Textbook folder of the NetLogo Models Library. The model, as well as any updates to the model, can also be found on the textbook website: http://www.intro-to-abm.com/.

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 extends the Traffic Basic model, from the social science section of the NetLogo models library, by having cars adapt their acceleration to try and maintain a smooth flow of traffic. It differs from the Traffic Basic Adaptive model in that this model has each car adapting individually, whereas that model has all cars adapting in unison.

An agent that can change its strategy based on prior experience is an adaptive agent. In the Traffic Basic Adaptive model, the agents collectively adapted their behavior, using their experience to find a common strategy (i.e., an acceleration) that maximized the average speed of all cars. In this version of the model, the agents individually adapt: each car can choose a different strategy (i.e., a different acceleration) in order to maximize its own speed. Instead of looking at the mean speed of all cars to evaluate the effectiveness of their current strategy, the cars look at their own mean speed since their last evaluation.

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 INIT-ACCELERATION slider controls the rate at which cars initially 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.

The SPEED-LIMIT slider sets the maximum speed that the cars can go.

Click on ADAPTIVE-GO to see how the results change when the cars are adapting to the environment around them, by changing their acceleration.

ADAPTIVE-GO employs the TICKS-BETWEEN-TESTS slider. This slider controls how frequently the model tests to see if it has found a better acceleration.

There are two monitors:

  • RED CAR SPEED displays the speed of one randomly selected car, which is colored red.

  • AVG SPEED displays the average speed of the cars.

The CAR SPEEDS plot plots the minimum, maximum and average speed of the cars. If the PLOT-RED-CAR? switch is on, it also plots the speed of the red car.

The ACCELERATION plot shows the distribution of the cars' accelerations over time. This is only used in ADAPTIVE-GO mode. (In regular GO mode, all cars have the same acceleration.)

THINGS TO NOTICE

First run the model using the GO button for a few hundred ticks. Then stop the model by pressing GO again and restart it by pressing ADAPTIVE-GO instead. Can you notice the change in behavior?

Notice how the ACCELERATION plot shows a single line when using GO, but multiple lines when using ADAPTIVE-GO. Do you understand why? If you switch from ADAPTIVE-GO to GO during the same run, you will still have multiple lines, but they won't change anymore. Can you explain what happens?

THINGS TO TRY

Run the model using ADAPTIVE-GO until all the cars reach a speed of 1.0. (You can temporarily uncheck "view updates" in the toolbar to make the model run faster.) All the cars now have the same speed but do they have the same acceleration? How do you explain the range of different accelerations once all the cars have had a chance to adapt?

When the plot-red-car? switch is turned on, we plot the speed of the red car in the CAR SPEEDS plot, but we don't plot its acceleration in the ACCELERATION plot. Add a (red!) pen to that plot to show the acceleration of the red car. How does the red car's compare to that if its peers? Run the model a few times. Are you getting the same result? What did you expect?

EXTENDING THE MODEL

The cars currently adapt by changing their acceleration. What if they could also change their deceleration? You would need to add deceleration and best-deceleration-so-far as turtle variables, rename the deceleration slider to init-deceleration and make a the related changes in the setup-cars and adapt procedures. Try it out! Does it help the cars to maximize their speed?

The amount by which acceleration varies is currently random-float 0.002 - 0.001. Make a slider called variation-range and have the acceleration vary instead by random-float variation-range - (variation-range / 2). Now see what happens when you use a higher variation range. Can the model still stabilize? Now try a very low one. Are the cars still able to adapt?

NETLOGO FEATURES

The CAR SPEEDS 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 UPPER-QUARTILE and LOWER-QUARTILE reporters show how to easily calculate quartiles.

RELATED MODELS

  • "Traffic Basic": a simple model of the movement of cars on a highway.

  • "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 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.

The traffic models from chapter 5 of the IABM textbook demonstrate different types of cognitive agents: "Traffic Basic Utility" demonstrates utility-based agents, "Traffic Grid Goal" demonstrates goal-based agents, and "Traffic Basic Adaptive" and "Traffic Basic Adaptive Individuals" demonstrate adaptive agents.

CREDITS AND REFERENCES

This model is an extension of the NetLogo Traffic Basic Adaptive model (Rand and Wilensky, 2008). This extension is based on exploration 20 from chapter 5 of the "Introduction to Agent-Based Modeling" textbook.

HOW TO CITE

This model is part of the textbook, “Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo.”

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

For the model itself:

Please cite the NetLogo software as:

Please cite the textbook as:

  • Wilensky, U. & Rand, W. (2015). Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo. Cambridge, MA. MIT Press.

COPYRIGHT AND LICENSE

Copyright 2015 Uri Wilensky.

CC BY-NC-SA 3.0

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.

(back to the NetLogo Models Library)