Home Download Help Resources Extensions FAQ NetLogo Publications Contact Us Donate Models: Library Community Modeling Commons Beginners Interactive NetLogo Dictionary User Manuals: Web Printable Chinese Czech Farsi / Persian Japanese Spanish

NetLogo Models Library: 
If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web 
This model is from Chapter Five of the book "Introduction to AgentBased Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo", by Uri Wilensky & William Rand.
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.introtoabm.com/.
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.
Click on the SETUP button to set up the cars.
Set the NUMBEROFCARS 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 INITACCELERATION 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 SPEEDLIMIT slider sets the maximum speed that the cars can go.
Click on ADAPTIVEGO to see how the results change when the cars are adapting to the environment around them, by changing their acceleration.
ADAPTIVEGO employs the TICKSBETWEENTESTS 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 PLOTREDCAR? 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 ADAPTIVEGO mode. (In regular GO mode, all cars have the same acceleration.)
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 ADAPTIVEGO 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 ADAPTIVEGO. Do you understand why? If you switch from ADAPTIVEGO to GO during the same run, you will still have multiple lines, but they won't change anymore. Can you explain what happens?
Run the model using ADAPTIVEGO 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 plotredcar?
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?
The cars currently adapt by changing their acceleration. What if they could also change their deceleration? You would need to add deceleration
and bestdecelerationsofar
as turtle variables, rename the deceleration
slider to initdeceleration
and make a the related changes in the setupcars
and adapt
procedures. Try it out! Does it help the cars to maximize their speed?
The amount by which acceleration varies is currently randomfloat 0.002  0.001
. Make a slider called variationrange
and have the acceleration vary instead by randomfloat variationrange  (variationrange / 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?
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 UPPERQUARTILE and LOWERQUARTILE reporters show how to easily calculate quartiles.
"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 twolane 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 realtime.
"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 utilitybased agents, "Traffic Grid Goal" demonstrates goalbased agents, and "Traffic Basic Adaptive" and "Traffic Basic Adaptive Individuals" demonstrate adaptive agents.
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 AgentBased Modeling" textbook.
This model is part of the textbook, “Introduction to AgentBased 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:
Copyright 2015 Uri Wilensky.
This work is licensed under the Creative Commons AttributionNonCommercialShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/byncsa/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)