A Linear Time and Space Algorithm For Optimal Traffic-Signal Duration at An Intersection
A Linear Time and Space Algorithm For Optimal Traffic-Signal Duration at An Intersection
Abstract—Finding an optimal solution for traffic-signal control exploits a phase, rather than a time interval, to eliminate many
duration is a computationally intensive task. It is typically O(T 3 ) unnecessary computations, reducing both computation time
in time and O(T 2 ) in space, where T is the length of the control and memory space requirements. As a result, the proposed
interval in discrete-time steps. In this paper, we propose a linear
time and space algorithm for the traffic-signal control problem. algorithm achieves more than 2700 times speedup (determined
The algorithm provides an efficient dynamic programming formu- experimentally) against the original COP algorithm for T =
lation of the state space that prunes nonoptimal states early on. 1024. We choose T to be the nearest powers of two to the
This paper proves the correctness of the algorithm and provides maximum typical traffic time-horizon prediction of 15 min
an initial experimental validation. This paper also conducts a (900 s), with 1-s units [2], [3].
simulation study comparing with other typical control methods.
The results show significant improvement in the average waiting Large cities contain thousands of traffic intersections. Each
time metric with respect to all other methods. constantly needs to compute the optimal control duration for
the real-time traffic load, for every small amount of time
Index Terms—Dynamic programming, optimization, traffic-
signal control. (a maximum of 15 min). Therefore, the computation cost is
substantially high.
I. I NTRODUCTION Another important aspect is the control performance of the
algorithm. Generally, most modern traffic control algorithms
TABLE I TABLE II
E XEMPLAR S IGNAL T IME P LAN A RRIVAL DATA P LAN
The time plan can be expressed as sequence p1 , p2 , . . . , where Ap (t) is the number of arrivals in phase p at time t, and
pt , . . . , pT , where pt is a traffic phase for a unit duration frp is the flow rate of phase p per unit of time.
occurring at discrete time t. In other words, the plan defines for At time t = 1, we have no previous state (w = ‘ − ’). There-
each time unit the active phase, including the clearance phase. fore, the queue lengths at this moment will be zeros (or given as
Define V (p, t) to be the cost of the optimal time plan ending initial conditions). From (5), we can deduce that computing cost
at time t and phase p; define C(S(w, t − 1), p, t) to be the cost function C() requires scanning all phases, which is O(|P |).
for operating phase p at time t when the previous phase is w, Dynamic programming thus proceeds in serial stages cor-
and S(w, t − 1) defines the traffic status that is necessary to responding to successive values of time t (serial monadic
compute a corresponding cost metric, such as the queue length dynamic programming [17] with forward recursion). Thus, at
at phase w and time t − 1. The queue length for the phase stage t, we compute V (p, t) for all possible phases p. The
is the sum of all the queue lengths of lanes belonging to the optimal solution requires a final backtracking step to find an
directions of the current phase. S(w, t − 1) can be the queue optimal sequence. We need to keep the S() values for the direct
length of vehicles currently existing in each phase for state w at previous stage only and neglect the other stages due to the in-
time t − 1. Thus herent serial nature of the dynamic programming formulation;
thus, the computations of current stage states only depend on
S(w, t) = qA (w, t), qB (w, t), . . . , q|P | (w, t) (1) the previous stage states. Therefore, we only need the O(|P |2 )
space to keep the values of S().
where qi (w, t) is the queue length of phase i at currently active To illustrate the core algorithm, we consider three active
phase w at time t. phases (without loss of generality), as depicted in Fig. 2. The
The optimal solution at a specific phase p and time t + 1 can phases are labeled A, B, and C. Each node represents a current
be computed as active phase at a time instance of the traffic intersection, except
for clearance interval state “0,” where it represents a no-active
C(−, p, 1), t=0 phase. The directed edges between nodes show the possible
V (p, t + 1) =
minρ V (ρ, t) ◦ C (S(ρ, t), t + 1) , t>0 next phases for a current phase. At t = 1, we cannot start with
(2) clearance phase “0,” but any active phase would suffice. At
390 IEEE TRANSACTIONS ON INTELLIGENT TRANSPORTATION SYSTEMS, VOL. 16, NO. 1, FEBRUARY 2015
TABLE III
E XTENDED P HASE NAMING N OTATION
Fig. 2. Graph representation for a three-phase problem, where |P | = 3, V (A, 3)|ρ=A = 6. We select the minimum cost and set the
r = 1, and γ = 1. predecessor state to be “0.”
Finally, at the last stage when t = T , we have two states
with the same minimum cost, where V () = 4. By applying the
backtracking starting from p = ‘0’, we get (5, “0”). From the
same state, the source phase is B, which gives (4, B), and so
on, to get the whole time plan, which is C, C, ‘0’, B, ‘0’. If
we start from the other optimal state B, we get the time plan of
C, C, ‘0’, B, B, which is also optimal.
The dynamic programming thus requires visiting every phase
at each time unit, computing the associated cost for each
predecessor, and storing the minimum cost. We thus require
3|P | cost computations for every row; the cost computation is
generally O(|P |), and since we have T rows, thus, the total time
complexity is O(|P |2 T ). For each phase, we need to store the
best predecessor phase. Thus, for each row, we store |p| + 1
values and one row of S(), which is O(|P |2 ); hence, the total
space complexity is O(|P |2 T ).
B. General Algorithm
To generalize our algorithm for any value of r and γ, we
expand the number of phases to include the timing constraints.
In particular, we classify the phases into “unconstrained” and
“constrained” phases. Unconstrained phases represent phases
that satisfy the minimum green and clearance constraints and
Fig. 3. Dynamic programming algorithm details for a three-phase problem,
where |P | = 3, r = 1, and γ = 1. are therefore free to change at the next time steps. Constrained
phases are constrained by the minimum duration and thus have
to repeat a corresponding fixed number of times. Phases are
t = 2, we can either keep the same phase or transition to the further classified into active and clearance phases, as in the
clearance phase. At t = 3, a clearance phase can be followed previous case. Table III lists the four possible groups of phases
by any active phase, and each predecessor active phase can and the labeling notation we adopt. Unconstrained clearance
transition into the clearance phase or keep its current phase, and active phases are labeled as “0” and ‘A’, ‘B’, . . ., as before.
and so on. The solution would be finding a path from the first Constrained phases are prefixed by a counter, indicating the
row (t = 1) and ending at the last row (t = T ) such that the number of successive times the phase has repeated so far.
associate cost is minimum. It is worth noting that the total number of phases we use is
To clarify the cost of the optimal time plan computation, we γ|P |r, where r ≤ γ.
explain the following example, where |P | = 3, r = 1, γ = 1, The minimum green time imposes the constraint that at least
and T = 5, as shown in Fig. 3. Moreover, the arrivals are given a phase has to be active for γ units of time. The phase is
in Table II. Each status keeps the values of S(), C(), V (), thus prefixed by a count of the number of time units since the
and predecessor phase ρ. V () expresses the total waiting time clearance phase, and the maximum count value is γ − 1 in time
for all vehicles until that moment. For example, at time = 3 units. A prefix with a value less than γ − 1 indicates that at
and phase = A, there are two predecessors, i.e., phase “0” the next time unit, the phase cannot change; therefore, a next
and the same phase A (circled in Fig. 3). Phase “0” has phase would have the same phase name but with a prefix count
V (‘0’, 2) = 1 and C(S(‘0’, 2), A, 3) = 2, where S(‘0’, 2) = increased by one (or removed if it reaches γ). A phase with no
(0, 0, 1); therefore, V (A, 3)|ρ= 0 = 3. On the other hand, prefix can stay the same or change to the clearance phase at the
phase A has V (A, 2) = 3 and C(S(A, 2), A, 3) = 3; therefore, next time unit.
SAMRA et al.: LINEAR TIME AND SPACE ALGORITHM FOR TRAFFIC-SIGNAL DURATION AT INTERSECTION 391
TABLE IV
P REDECESSOR C ONSTRAINTS
Our dynamic programming formulation essentially stays the V. VALIDATION OF THE P ROPOSED A LGORITHM
same, with only requiring redefining ρ according to Table IV.
We have conducted a set of experiments comparing the
The table essentially gives the possible predecessor phases for
solutions obtained by the new algorithm and COP; the results
a given phase p.
indicate that our generated sequences have exactly the same
Fig. 4 shows the corresponding graph when |P | = 3, r = 2,
cost as those obtained by COP. However, for generality, we
and γ = 3. The gray nodes in the first level are the initial
develop a correctness proof for our method. We iteratively con-
phases. The transitions between phases follow Table II. The
struct optimal sequences with increasing lengths; we therefore
target algorithm searches for the optimal solution through a
need to prove that, if we have an optimal time plan of length
matrix of dimensions T by γ|P | + r. This is O(|P |T ), as γ
j, then it includes the optimal sequence of length j − 1. It
and r are constants.
then follows by induction that the method generates optimal
Backtracking searches for the phase with the minimum cost
sequences.
in the last stage, with the condition that the phase must be
Let Ψ(j) denote phase sequence p1 , p2 , . . . , pj . Let op-
an unconstrained phase. Then, using the predecessor phases,
erator “ ” be the sequence concatenation operator, which is
recursively, we get the optimal path upon reaching the initial
defined as
stage.
Ψ(i) Ψ
(j) = p1 , p2 , . . . , pi , p
1 , p
2 , . . . , p
j . (6)
C. More Supported Features
Theorem: Given Ψ(j) = Ψ(j − 1) pj , if Ψ(j) is an optimal
In the previous two sections, we set r = 1 and γ = 1, and sequence of length j, Ψ(j − 1) is an optimal sequence of
r = 2 and γ = 3, respectively. Although these values of r and length j − 1.
γ are constant for all phases in the current intersection, our new Proof: We prove, by contradiction, that it is not possible to
algorithm also supports variable values for each phase. There- construct an optimal sequence of length j that does not contain
fore, we can have many values of r and γ, i.e., r1 , r2 , . . . , r|P | an optimal sequence of length j − 1.
and γ1 , γ2 , . . . , γ|P | , each associated with a phase. Assume that it is possible to find a sequence Ψ(j) such that
For supporting this feature, we require the following changes subsequence Ψ(j − 1), ending with phase pj−1 , is not an opti-
to our base algorithm: 1) the number of clearance states will mal sequence. Designate Ψ∗ (j − 1) to be an optimal sequence
392 IEEE TRANSACTIONS ON INTELLIGENT TRANSPORTATION SYSTEMS, VOL. 16, NO. 1, FEBRUARY 2015
Fig. 6. COP’s execution time with curve fitting. Fig. 7. New algorithm’s execution time with curve fitting.
ending with p∗j−1 = pj−1 . Therefore, we can construct a new about 2700 times speedup when T = 1024. The growth rate is
sequence Ψ∗ (j) = Ψ∗ (j − 1) pj , ending with the same phase largely linear for the proposed algorithm and is cubic for COP.
as Ψ(j). Since Ψ∗ (j − 1) has a lower cost than Ψ(j − 1) and Table V summarizes the time and space complexities for both
since they share the last phase (with the same cost), then Ψ∗ (j) algorithms, which were obtained analytically (see Appendix A
has a lower cost than Ψ(j), which is a contradiction as Ψ(j) is for derivation details).
an optimal sequence. Therefore, sequence Ψ(j − 1) has to be The rationale behind the difference in performance among
an optimal sequence. the two algorithms is worth discussing. Although COP uses dy-
namic programming to obtain the optimal sequence of phases,
it uses phases, rather than time, as stages in dynamic program-
VI. E XPERIMENTS AND R ESULTS ming. The COP algorithm explores the search space in a phase-
In this section, we evaluate two “performance” aspects of our oriented manner, exploring for each phase all possible time
proposed algorithm. Since dynamic programming approaches durations. This imposes a particular (cyclic) phase order and
are generally computation intensive, we study the computation results in a possible (linear) increase in the number of stages,
performance in our system in comparison to COP [1]. As e.g., as the worst case, a reverse phase sequence for phases C,
more recent methods that rely on artificial intelligence and B, and A could result in tripling the number of explored phase
machine learning have emerged to significantly decrease the cycles (e.g., A, B,C, A, B, C, and A, where the underlined
computation complexity, we study the difference on the con- stages are the sought stages, and the other stages would have
trol performance of our method in comparison to such recent time deltas of zero).
methods.
B. Control Performance
A. Computation Performance This set of experiments aims to compare the new algorithm
To evaluate the actual performance (in terms of execution with modern algorithms that implement other methodologies
time) of our algorithm, we have implemented it and the COP such as reinforcement learning, genetic programming, and neu-
algorithm. The implementation is done in C and experimented ral networks.
on an Intel Core2 Duo © 2.10-GHz personal computer with For having a unified methodology to study the control perfor-
2 GB of random access memory. mance, we decided to implement our algorithm into the Green
The traffic control problem, as formulated, has the following Light District (GLD) system [18]. The GLD is a well-known
parameters: the number of phases |P |, the size of the control open-source simulator for traffic-signal control. The system
interval in discrete-time steps T , and the traffic load. For a provides implementation of various traffic control algorithms
single intersection, the discrete-time steps parameter is the and has been used in many earlier studies [19]–[21].
limiting factor in the performance as the number of phases is We used the average junction waiting time to compare be-
constant, and the traffic load has no effect on the algorithm’s tween different control traffic algorithms. The metric expresses
time complexity. the total waiting time over the total passed vehicles over one
We have two sets of experiments. In the former set, we used intersection. We considered two configurations, i.e., one with
the same traffic parameters as the original COP algorithm [1]; three phases and the other with four phases.
we set the number of phases to three, and we used the same We compare the proposed algorithm with the following
traffic load. For scaling T , we change its value in powers of algorithms.
two to be 8, 16, 32, . . ., 4096. • The random method. It is a simple algorithm that assigns
We study the total program execution time against varying random values to each phase regardless of the traffic load.
the discrete-time steps T . Figs. 6 and 7 show the execution time • GenNeural. It is a genetic algorithm for finding neural-
in seconds for COP and the proposed algorithm, respectively. network controllers for the traffic lights. For each traffic
Our algorithm clearly improves the execution time, reaching light, a neural network is encoded in a genetic string. Each
SAMRA et al.: LINEAR TIME AND SPACE ALGORITHM FOR TRAFFIC-SIGNAL DURATION AT INTERSECTION 393
TABLE V
T IME AND S PACE C OMPLEXITIES OF COP AND THE N EW A LGORITHM
TABLE VI
M EAN (μ)AND COV OF THE AVERAGE J UNCTION WAITING T IME
FOR A LL E XPERIMENTS
R EFERENCES
[1] S. Sen and L. Head, “Controlled optimization of phases at an
intersection,” Transp. Sci., vol. 31, no. 1, pp. 5–17, Feb. 1997.
[2] L. Head, “Event-based short-term traffic flow prediction model,” Transp.
Res. Rec., vol. 510, no. 1510, pp. 45–52, Jul. 1995.
[3] B. L. Smith and M. J. Demetsky, “Short-term traffic flow prediction
models-a comparison of neural network and nonparametric regression
approaches,” in Proc. IEEE Int. Conf. Syst., Man, Cybern., Humans, Inf.
Technol., Oct. 1994, vol. 2, pp. 1706–1709.
[4] R. Asthana, N. J. Ahuja, M. Darbari, and P. K. Shukla, “A critical review
on the development of urban traffic models and control systems,” Int. J.
Fig. 12. Main matrix of the new algorithm. Sci. Eng. Res., vol. 3, no. 1, pp. 1–6, Jan. 2012.
[5] M. Saito and J. Fan, “Artificial neural network-based heuristic optimal
traffic signal timing,” Comput.-Aided Civil Infrastruct. Eng., vol. 15,
VII. C ONCLUSION AND F UTURE W ORK no. 4, pp. 293–307, Jul. 2000.
[6] B. Chen and H. Cheng, “A review of the applications of agent technology
This paper has presented a new dynamic programming al- in traffic and transportation systems,” IEEE Trans. Intell. Transp. Syst.,
gorithm to find an optimal phase duration sequence for the vol. 11, no. 2, pp. 485–497, Jun. 2010.
traffic-signal control problem at an intersection. The proposed [7] Y. Huang and T. Chung, “Modeling and analysis of urban traffic lights
control systems using timed CP-nets,” J. Inf. Sci. Eng., vol. 24, no. 3,
algorithm achieves linear time and space complexities; it pp. 875–890, May 2008.
achieves O(T 2 ) performance and O(T ) space enhancements [8] H. Ceylan and M. G. Bell, “Traffic signal timing optimisation based
over the well-known COP algorithm that solves the same on genetic algorithm approach, including drivers’ routing,” Transp. Res.
problem optimally. Consequently, it reduces the computation Part B, Methodological, vol. 38, no. 4, pp. 329–342, May 2004.
[9] M. Trabia, M. Kaseko, and M. Ande, “A two-stage fuzzy logic controller
time and the power, allowing for more scalability for real-world for traffic signals,” Transp. Res. Part C, Emerging Technol., vol. 7, no. 6,
applications. The algorithm improves time and space complex- pp. 353–367, Dec. 1999.
ities by not abiding with a strict (cyclic) phase order and by [10] M. Papageorgiou, C. Diakaki, V. Dinopoulou, A. Kotsialos, and Y. Wang,
“Review of road traffic control strategies,” Proc. IEEE, vol. 91, no. 12,
exploring the solution space in a time-oriented fashion, pruning pp. 2043–2067, Dec. 2003.
many nonoptimal states early on. This paper has provided a [11] P. Mirchandani and L. Head, “A real-time traffic signal control system: Ar-
correctness proof and an experimental evaluation. chitecture, algorithms, analysis,” Transp. Res. Part C, Emerging Technol.,
vol. 9, no. 6, pp. 415–432, Dec. 2001.
Future research includes the integration of our algorithm [12] I. Porche and S. Lafortune, “Adaptive look-ahead optimization of traffic
with coordinated/traffic-responsive strategies such as RHODES signals?” J. Intell. Transp. Syst., vol. 4, no. 3/4, pp. 260–264, 1999.
[11] and parallelizing the algorithm to provide for multiple [13] C. O. Kim, Y. Park, and J.-G. Baek, “Optimal signal control using adap-
tive dynamic programming,” in Proc. ICCSA, vol. 3483, Lecture Notes
intersections control. Moreover, we are currently exploring an in Computer Science, O. Gervasi et al., Ed., Jan. 2005, pp. 148–160,
optimization for enhancing the cost function computation time Springer Berlin Heidelberg.
to O(1) instead of O(|P |) for each dynamic programming state. [14] F. Fang, “Optimal adaptive signal control for diamond interchanges us-
ing dynamic programming,” M.S. thesis, Pennsylvania State Univ., State
College, PA, USA, 2004.
[15] C. Cai and T. Le, “Approximate dynamic programming controller for
A PPENDIX multiple intersections,” in Proc. 12th World Conf. Transp. Res., Lisbon,
Portugal, 2010, pp. 1–23.
Here, we derive the computation complexities for our new [16] T. Li, D. Zhao, and J. Yi, “Adaptive dynamic programming for multi-
algorithm and the COP algorithm. intersections traffic signal intelligent control,” in Proc. 11th IEEE ITSC,
Oct. 2008, pp. 286–291.
Fig. 11 shows the main data structure (matrix) of the COP
[17] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction to
algorithm. The matrix dimensions are (T − r) and j, where Algorithms, 2nd ed. Cambridge, MA, USA: MIT Press, 2001.
j depends on the stopping criterion [25], which is |P |T in [18] Arnekoopman, Caezonne, Marcowier and Stsnel, “GLD.” [Online].
the worst case. Each cell of this matrix examines (T − γ) Available: http://sourceforge.net/projects/stoplicht
[19] M. Wiering, J. Van Veenen, J. Vreeken, and A. Koopman, “Intelligent
cells from a previous stage; each previous stage cell requires traffic light control,” Inst. Inf. Comput. Sci. Utrecht Univ., Utrecht,
O(|P |) computation time. Thus, the current cell computation The Netherlands, Tech. Rep. UU-CS-2004-029, 2004.
SAMRA et al.: LINEAR TIME AND SPACE ALGORITHM FOR TRAFFIC-SIGNAL DURATION AT INTERSECTION 395
[20] M. Wiering, J. Vreeken, J. Van Veenen, and A. Koopman, “Simulation Ahmed El-Mahdy received the B.Sc. and M.Sc.
and optimization of traffic in a city,” in Proc. IEEE Intell. Veh. Symp., degrees from Alexandria University, Alexandria,
Jun. 2004, pp. 453–458. Egypt, in 1995 and 1998, respectively, and the Ph.D.
[21] S.-B. Cools, C. Gershenson, and B. D’Hooghe, “Self-organizing traffic degree from University of Manchester, Manchester,
lights: A realistic simulation,” in Advances in Applied Self-Organizing U.K., in 2001.
Systems. New York, NY, USA: Springer-Verlag, 2008, pp. 41–50. He is an Associate Professor with, and the act-
[22] M. Ben-Akiva, M. Bierlaire, H. Koutsopoulos, and R. Mishalani, “Dy- ing Chair of, the Department of Computer Science
naMIT: A simulation-based system for traffic prediction,” presented and Engineering, School of Electronics, Commu-
at the Proc. DACCORS Short Term Forecasting Workshop, Delft, nications and Computing, Egypt–Japan University
The Netherlands, 1998, Citeseer. of Science and Technology (E-JUST), Alexandria,
[23] C. Liu, B. Lu, and J. Wang, “Traffic flow prediction based on wavelet Egypt, on leave from the Department of Computer
analysis, improved genetic algorithm, BP neural network,” in Proc. ASCE, and Systems Engineering, Faculty of Engineering, Alexandria University. He
2014, vol. 10, pp. 1126–1133. participated in the research and development of one of the first research
[24] Z. Sun and G. Fox, “Traffic flow forecasting based on combination of multicore processors, Jamaica. He has been a Visiting Scientist with the
multidimensional scaling and SVM,” Int. J. Intell. Transp. Syst. Res., IBM Center for Advanced Studies, Cairo, Egypt, where he holds six U.S.
vol. 12, no. 1, pp. 20–25, Jan. 2014. patents, with many other patents filed. He is currently the Chair of the
[25] S. Samra, A. El-Mahdy, W. Gomaa, Y. Wada, and A. Shoukry, “Efficient Parallel Computing Laboratory (http://labs.ejust.edu.eg/pcl) and the Smart
parallel implementations of controlled optimization of traffic phases,” in City Facility, E-JUST, carrying out many research projects related to high-
Proc. 11th Int. Conf. ICA3PP Algorithms Archit. Parallel Process. Part I, performance computing cloud and compilation in collaboration with Japanese
Melbourne, Vic., Australia, Oct. 24–26, 2011, pp. 270–281, Springer. and French institutes. He has also established a research cloud prototype at
E-JUST. His research interests include multicore architecture and program-
ming, analytical performance modeling, and computer graphics.
Dr. El-Mahdy is a member of the Association for Computing Machinery.
He was a Co-organizer of the first conference on multicore technologies in
the region [International Forum on Next-Generation Multicore/Manycore Tech-
nologies (IFMT) in 2008]. He was also invited to serve on the Technical Pro-
gram Committee of Architecture of Computing Systems (ARCS) conferences.
His projects are/have been funded by many funding bodies including IBM,
Amazon, Information Technology Industry Development Agency, and The
Egyptian Academy of Science and Research.