NetLogo banner

 Contact Us

 Modeling Commons

 User Manuals:


NetLogo User Community Models

(back to the NetLogo User Community Models)


by Pedro S. Rodríguez-Hernández & Juan C Burguillo-Rial (Submitted: 10/15/2015 )

[screen shot]

Download HB-SOTL_8_10
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".

(You can also run this model in your browser, but we don't recommend it; details here.)


HB-SOTL is a model of traffic moving in a city grid. It allows you to control traffic lights and global variables, such as the speed limit and the number of cars, and explore traffic dynamics. In our model, cars have a source and a destination, roads can have one or two directions, each of which can can have one or two lanes. We add new control methods, namely hb-sotl, hb-comm-sotl, QL-sotl, and LA-sotl.

From version 8.0 on, HB-SOTL is an extension of HB-COMM-SOTL (History-Based Self-Organizing Traffic Lights with Communication) by Pedro S. Rodriguez-Hernandez & Juan C. Burguillo-Rial.

HB-COMM-SOTL was an extension of Learning-SOTL (Self-Organizing Traffic Lights with Learning Algorithms) by Pedro S. Rodriguez-Hernandez & Juan C. Burguillo-Rial.

Learning-SOTL was an extension of HB-SOTL (History-Based Self-Organizing Traffic Lights) by Pedro S. Rodriguez-Hernandez & Juan C. Burguillo-Rial.

HB-SOTL versions 1.0 to 7.0 was an extension of SOTL (Self-Organizing Traffic Lights) by Carlos Gershenson. The HB-SOTL is documented at the publication: Juan C. Burguillo-Rial, Pedro S. Rodríguez-Hernández, Enrique Costa-Montenegro, Felipe Gil-Castiñeira. History-based Self-Organizing Traffic Lights. Journal of Computing and Informatics (CAI) 22, pp. 1001-1012. 2009. Available at:

SOTL was extended from the model "Gridlock" by Uri Wilensky & Walter Stroup, which comes with NetLogo 2.0.0 (see more info at the bottom)


+ HB-SOTL is based upon version 1.0 of HB-COMM-SOTL

+ HB-COMM-SOTL was based upon version 7.2 of Learning-SOTL

+ Learning-SOTL was based upon version 7.0 of HB-SOTL

+ We are trying to test the effect of having devices to measure the cars which traverse the intersection in only a fraction of the traffic lights controllers

+ HB-SOTL's name stands for "history-based SOTL"

+ At every lights cycle, the intersection controller makes a decision based on the amount of cars which have traversed this intersection in the *previous* cycle, if it has this information. If not, it acts as the "marching" controllers.



0.00 2007-03-08 just removed torus? and four-dirs?
all our models will be non-torus and four-directions

1.00 2007-04-30 added source/destination to cars. Modified the procedures
put-on-empty-road and cars-remove-create. Added procedures
select-destination and guide-car.
2.00 2007-05-15 added a "Step" button, to run the scenario step by step. Added
a count of "stray cars" (cars whose path deviates in excess
from the shortest)
3.00 2007-06-06 added bidirectional roads. This includes modifying guide-car and
all the procedures for traffic control. Added deadlock resolution
4.00 2007-06-07 added dual-lane roads. Modified the yellow lights cycle to adapt
it to the width of the intersection
5.00 2007-11-13 added "hb-sotl" control method. Added automatic call to
reset-traffic-lights when control changes. Adapted to NetLogo4.0
6.00 2008-03-23 added the ability to park cars when they reach their destinations
and to unpark them later (instead of removing/creating)
7.00 2008-05-14 added depth to the history in "hb-sotl" method


1.00 2009-05-22 cleaning of HB-SOTL 7.0
2.00 2009-06-01 added QL-SOTL. Whenever a green cycle ends, i.e. whenever a controller
changes a lane's lights to red, it selects the next action (i.e. the
length of the next green cycle) at random. Whenever a red cycle ends,
the controller valorates its last decision comparing the current
length of the waiting cars queue with that of the previous red cycle.
3.00 2009-08-01 added LA-SOTL. Idem.
4.00 2009-10-13 corrected 2 problems with car guidance: now cars run in the middle
of the lane, and, in the case of dual-lanes, cars use both lanes.
The deadlock resolution algorithm is more aggressive now.
The average speed metric now avoids counting parked cars.
In HB-SOTL, now we have separate histories for horizontal and vertical
5.00 2009-10-28 the commuters commute between downtown (the central patches) and the
residential areas (the outmost patches and the outside world)
6.00 2009-11-01 the valoration of the last decision is made on the basis of the ratio:
number of cars crossing the intersection in the current green cycle /
length of the (waiting + approaching) cars queue in the previous red cycle,
instead of the ratio: length of the waiting cars queue in the current
red cycle / length of the waiting cars queue in the previous red cycle
7.00 2009-11-02 both the decision and the valoration are made on the last "n" cycles
average value, instead of on the last cycle value (where "n" is
selectable by means of a slider)
7.10 2009-11-20 both the decision and the valoration are based on the number of cars
rather than on the queue length

7.20 2009-11-20 added a slider for defining the number of states, and changed the sliders
for defining the "width" of the states
refined the valoration heuristics: now we have into account not only the
ratio cars crossing / cars waiting, but also the controller's "throughput"
i.e. the cars crossing per timestep


1.00 2009-12-11 cleaning of Learning-SOTL 7.2
changed the definition of "aggressiveness": scaled up to a factor of 10
(just to avoid multiplying it by 10 once and again)


8.00 2010-09-15 cleaning of HB-COMM-SOTL 1.0
added %car-meters slider: the fraction of controllers provided with a device to measure the amount of cars which traverse the intersection
the car-meters information now is only used by hb-sotl.

8.10 2010-11-11 now the car-meters information is used by hb-comm-sotl too.



Run "Setup" before starting simulation. Then start and stop with "Go". Some parameters, such as grid-sizes and four-dirs? will be applied only after pressing "Setup".

Tip: you can "freeze" the display (on top of the "city" display) and/or switch off the plots to accelerate simulations.

For SOTL details, consult the paper "Self-Organizing Traffic Lights"


"Setup"- Initializes simulation

"Re-run"- "soft" and quick "Setup" (just clears variables, doesn't change street topology)

"Reset-TL"- Turns phases of adaptive control methods ("sotl"'s and "cut-off") to zero, so that they need to adapt again (to check robustness)

"Go"- Start and stop simulation

"Step"- Run simulation just one time step

"Refresh Plots"- Clear all plots


-control- select control method for traffic lights (now, when changing methods during the same run, resetTL is automatically called. (If one was yellow, can cause problems...)


"grid-size-x"- number of vertical streets

"grid-size-y"- number of horizontal streets

"number"- initial number of cars for "Setup" and "Re-run", intended average number of circulating cars

%vertical- percentage of cars initially flowing in vertical roads, if starting at an intersection (%horizontal= 100-%vertical)

%origin-out- percentage of cars with origin outside the world

%destination-out- percentage of cars with destination outside the world

%bidirectional- percentage of bidirectional streets

%2-lane- percentage of streets with two lanes in the same direction

simulation-speed- regulates processing speed

speed-limit- maximum speed of cars

p- phase period for cyclic control methods ("marching", "optim", and "no-corr")

mingreen- minimum green phase for "sotl-phase" and "sotl-platoon" controls

keep-platoon- "omega" distance at which cars are checked from green light in "sotl-platoon" control

cut-platoon- "miu" cars approaching a green light at which platoons can be cut in "sotl-platoon" control

queue-cut- lambda queue length for "cut-off" control

tolerance- "theta" threshold for all "sotl" control methods

metatolerance- attempt of metaadaptive regime. Doesn't work, keep set to zero...

deadlock-limit- maximum time to decide that a car is suffering a deadlock

aggressiveness- scale factor for the time slots of the green cycles in "self-org-history"

hb-depth- number of previous cycles to be taken into account in "self-org-history"

parking-probability- probability of parking a car that reaches its destination and is not a commuter (commuters always park)

parking-time-min- minimum time a car is going to be parked

parking-time-max- maximum time a car is going to be parked (the actual parking time is a random variable uniformly distributed among this value and the previous)

%commuters- percentage of cars with a fixed home-place and work-place, which are going to switch origin and destination between those 2 places

excursion-probability- probability for a commuter to make an "excursion" to a place other than its work-place or its home-place


power?- makes traffic lights work

yellow?- include yellow phase (1 timestep) between green and red phases

crash?- monitor crashes at intersections

plots?- switches plotting (off increases simulation speed)

movie?- activates the recording of the simulation as a movie

over-length?- activates the control of cars running for a extra-long time (this should only happen if there is an error in the guidance procedure)


This activity and associated models and materials was created as part of the projects:
PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and INTEGRATED SIMULATION AND MODELING ENVIRONMENT. These projects gratefully acknowledge the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227.

Copyright 2002 by Uri Wilensky & Walter Stroup. All rights reserved.

Permission to use, modify or redistribute this model is hereby granted, provided that both of the following requirements are followed:
a) this copyright notice is included.
b) this model will not be redistributed for profit without permission from the copyright holders.
Contact the copyright holders for appropriate licenses for redistribution for profit.

To refer to this model in academic publications, please use: Wilensky, U. & Stroup, W. (2002). NetLogo HubNet Gridlock model. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

In other publications, please use: Copyright 2002 by Uri Wilensky and Walter Stroup. All rights reserved. See for terms of use.

(back to the NetLogo User Community Models)