Supervised Project · SCE · Computer Science · Beer Sheva

Smart Traffic Control

A reinforcement-learning traffic-signal controller trained in a custom four-way intersection simulation to adapt signal phases to changing queue conditions.

2024–2025Or Avital Butbul · Lotem CohenQ-learningReinforcement learningTraffic simulationAdaptive control
12incoming lanes
6signal phases
6,000training episodes per reported run
5independent seeds in stability analysis
Research question

Can a learning-based controller outperform a fixed cyclic signal policy?

The project builds a custom Python simulation of a four-way intersection and trains a Q-learning agent to select signal actions from the observed traffic state. The comparison baseline is a Round-Robin controller that cycles through the available phases without learning from congestion.

The optimization target is operational rather than purely algorithmic: increase throughput, reduce average waiting time, and improve the cumulative reward generated by the control policy.

Environment design

  • Four-way intersection
  • 12 incoming lanes
  • Six non-conflicting movement phases
  • Poisson vehicle arrivals
  • Queue-length observations
  • OpenAI Gym-style interface
Learning pipeline

Discretize the traffic state, then learn which signal action to take.

The controller never sees raw traffic; it sees a compact summary of the intersection and picks one signal action per time step. Learning is tabular Q-learning, so every state and action has an entry in a table that is improved from experience.

State

Queue lengths of the 12 lanes plus the active phase (0 to 5), a 13-value vector. Each queue is binned into four congestion levels (0 to 6, 7 to 13, 14 to 20, 21 or more cars), which keeps the table small enough to learn.

Actions

A choice of signal phase (six non-conflicting movement groups) and how many vehicles to release from each active lane (0 to 30 in steps of 5): 6 × 7 = 42 actions.

Reward

Higher is better. The reward penalizes waiting time and queue length, with extra penalties for queues above 35 and 45 cars, and rewards each vehicle that passes, plus a small bonus for keeping lanes lightly loaded. Throughput and fairness across approaches both matter.

The update rule

After each step the agent nudges the value of the action it took toward what it actually observed:

Q(s,a) ← Q(s,a) + α [ r + γ · max Q(s′,a′) − Q(s,a) ]

In words: the new estimate of an action's value moves a little (learning rate α = 0.1) toward the reward just received plus the best value available from the next state, discounted by γ = 0.9 so that future traffic still counts. Early on the agent mostly explores random actions; the exploration rate ε starts at 1.0 and decays each episode toward a floor of 0.1, so it increasingly follows the best-known action. Each training episode lasts 200 time steps, and training runs for 6,000 episodes.

Traffic-control pipeline from four-way intersection simulation through discretized state representation and Q-learning to adaptive signal actions, evaluated against a Round-Robin baseline.
The controller is evaluated on reward, throughput, and average waiting time rather than on reward alone.
Simulation view

A graphical view of the simulated intersection.

The simulation can be inspected visually. The report describes this view as enabling intuitive tracking of traffic flow and congestion and as providing visual validation of the agent’s decision-making.

Top-down view of the simulated four-way intersection at time step 4, with queued vehicles drawn as colored rectangles in each lane, traffic lights at the junction and white numbered circles at the lane edges showing queue lengths. The label above reads Traffic Intersection, Step 4, Active: north_straight, south_straight.
Simulated intersection at time step 4. The active phase is north_straight and south_straight, shown by the green lights facing those directions. Vehicles are colored rectangles queued in their lanes, and the numbered circles at the lane edges show the real-time queue length. Figure from the student final report. Select the image to open it full size.
What changed during development

The first agent was not good enough, and that became part of the engineering result.

Initial model

The early Q-learning configuration performed worse than the Round-Robin baseline and showed high variability. The report attributes this to a coarse reward function, limited state representation, and an inefficient action space.

Reward redesign

The reward function was expanded to penalize waiting and queue buildup more strongly, including severe-congestion penalties, while also rewarding throughput and balanced flow.

State refinement

Queue-length categories were adjusted to distinguish moderate from severe congestion more effectively, improving the agent’s sensitivity to traffic conditions.

Action refinement

The action space was simplified from many unit-by-unit vehicle counts to a smaller predefined set of vehicle batches, improving tractability and interpretability.

Reported results

After refinement, the learned policy outperformed the fixed baseline across all three tracked metrics.

The report answers three questions with plots. It gives curves and standard deviations rather than a table of percentage gains, so the figures below are described, not summarized into a single number. Values quoted are read from the axes.

Did learning improve the policy?

Yes. Average reward, recorded every 300 episodes, dips at first (to about −110,000 around episode 600), then rises steadily to about −31,000 by episode 6,000. Average waiting time follows the mirror-image trend, falling from a peak of about 33 s to about 17 s.

Line chart of average reward every 300 training episodes, dipping early and then rising steadily.
Average reward every 300 training episodes. An early dip is followed by a steady climb as the policy improves. Figure from the student final report. Select the image to open it full size.

Does it beat the baseline?

In the evaluation over 300 episodes, the trained agent passes about 4,000 to 4,500 vehicles per episode against roughly 2,000 for Round-Robin, and its average waiting time sits mostly between about 10 and 35 s against roughly 58 s for Round-Robin. Reward is also well above the baseline. Round-Robin stays almost flat because it ignores queues; the learned controller is noisier episode to episode.

Line chart comparing vehicles passed per episode for the Q-learning controller and the Round-Robin baseline.
Vehicles passed per episode: trained Q-learning against Round-Robin over 300 evaluation episodes. Figure from the student final report. Select the image to open it full size.
Line chart comparing average waiting time per episode for the Q-learning controller and the Round-Robin baseline.
Average waiting time per episode: trained Q-learning against Round-Robin. The learned policy is lower but more variable. Figure from the student final report. Select the image to open it full size.

Is it stable across random seeds?

The agent was trained five times with different seeds. The mean reward curve (below) climbs and then flattens, and the shaded ±1 standard deviation band shows the run-to-run spread. Averaged over all episodes, the standard deviation is 21,272 for reward, 129 for vehicles passed and 6.65 s for average waiting time.

Line chart of mean reward over 6,000 episodes across five seeds with a shaded one-standard-deviation band.
Mean reward over five independent training runs, with a ±1 standard deviation band. Figure from the student final report. Select the image to open it full size.
Interpretation

Environment design mattered as much as the learning algorithm.

The strongest lesson from the project is not simply that “Q-learning works.” The initial learning setup failed to beat a simple baseline. Performance improved only after the state representation, reward function, exploration schedule, and action granularity were redesigned together.

That makes the project a useful example of applied reinforcement learning where system formulation and evaluation design are central to whether the learning algorithm succeeds.

Evaluation metrics

  • Total reward
  • Vehicles passed
  • Average waiting time
  • Mean performance over repeated seeds
  • Standard deviation across runs
  • Visual inspection of simulated traffic flow
Scope and limitations

What these results do and do not show.

Simulation only

All results come from the project's own four-way intersection simulator with Poisson arrivals. The report does not test real traffic data or a deployed signal.

Coarse state

Four congestion bins per lane keep the table tractable but hide detail; the agent cannot distinguish a queue of 22 from one of 45.

Designed reward

Behavior depends on hand-set reward weights. The first version of the design failed to beat Round-Robin, and results improved only after the reward, bins and actions were redesigned.

Variability

The learned controller's waiting time swings widely between episodes, and results differ across seeds (see the standard deviations above). Better than the baseline on average is not the same as better in every episode.

Related

Related work

Zone Tag →

Another reinforcement-learning project: two agents learning pursuit and evasion through self-play.

Project materials

Final report.

The student final report for this project, as a PDF.

Supervised project

A compact RL system with a clear baseline and iterative model redesign.

The project combines simulation, tabular reinforcement learning, operational traffic metrics, and repeated-run validation in one end-to-end experimental system.