Inspiration
Have you ever been stuck at a traffic light for a very long period of time due to congestion?
Many traffic signals still operate on fixed timing plans that cannot adapt to real-time traffic demand. This often leads to situations where one direction has long queues while another direction receives green time with little traffic.
I wanted to explore whether AI reasoning models could dynamically manage traffic signals and make smarter decisions based on the current state of the intersection. My goal was to simulate how an intelligent controller could reduce waiting time, shorten queues, and maintain balanced traffic flow.
What it does
FlowMind is an AI-powered traffic signal controller designed to manage a four-way intersection.
Instead of using fixed signal durations, FlowMind observes the current traffic state, including:
- Queue length at each direction
- Estimated vehicle arrival rates
- Road discharge capacity
Based on this information, the Amazon Nova determines the optimal duration of the next signal phase to minimize waiting time and reduce congestion.
The system simulates real-world traffic using stochastic vehicle arrivals modeled with Poisson processes, meaning vehicle arrivals fluctuate naturally rather than appearing at fixed intervals. This allows the controller to operate under more realistic traffic conditions.
Through this approach, FlowMind demonstrates how reasoning-based AI can dynamically adjust signal timing to improve traffic efficiency.
How I built it
FlowMind was built as a traffic simulation combined with an AI decision engine.
The system consists of several main components:
Simulated Traffic Data
- Generates vehicle arrivals for each direction using a Poisson distribution
- Simulates queue growth and vehicle discharge at the intersection
- Models a four-direction intersection (North, South, East, West)
Dynamic Signal Optimizer
Alternates between two phases:
- NS (North–South green)
- EW (East–West green)
The full workflow includes the following steps:
Start
The control loop begins and continuously monitors the traffic environment.Update Traffic Data
The system retrieves the latest traffic metrics (e.g., vehicle counts, queue lengths, or sensor data).Check Signal State
The system checks whether the current traffic signal phase is yellow.If NOT Yellow
The system continues updating traffic data until the signal reaches the yellow phase.
This ensures that decisions are made right before the next signal transition.If Yellow
The system captures the current traffic state, including relevant metrics from all monitored lanes or intersections.Agentic AI Decision (Amazon Nova 2 Lite)
The captured traffic state is sent to the Agentic AI module powered by Amazon Nova 2 Lite.
The AI analyzes the traffic conditions and determines the optimal next signal phase and green light duration, and provides a short explanation describing the reason behind the decision.Update Signal Plan
The system updates:- The next traffic signal phase
- The duration of the green signal
Loop
After updating the signal plan, the process returns to traffic data monitoring and repeats continuously.
Challenges I ran into
One of the main challenges was designing a prompt and decision logic that produced stable and realistic traffic control behavior. To address this, I had to carefully structure the controller logic so that the AI:
- prioritizes the next phase queues
- still considers the queues in the current phase
- maintains balanced service over time
- avoids excessively long or short signal durations
Another challenge was simulating realistic traffic conditions. Instead of deterministic arrivals, I implemented Poisson-based stochastic traffic generation, which better represents how vehicles actually arrive at intersections.
Accomplishments that I'm proud of
I successfully built a working AI-controlled traffic signal simulation that can dynamically adjust signal timing based on traffic conditions.
Key accomplishments include:
- Building a stochastic traffic simulator with realistic arrival patterns
- Designing a reasoning-based traffic signal optimizer
- Creating a visualization interface to observe the system's behavior
Most importantly, I demonstrated how AI can move beyond static signal timing and adapt to real-time traffic demand. Using the same settings, Nova reduces the queue length by half, decreases and balances the waiting time across directions, and serves more vehicles overall. The demo illustrates these results.
What I learned
Through this project, I learned several key insights:
- Traffic systems are highly dynamic, and small timing decisions can significantly affect congestion.
- Stochastic modeling (such as Poisson arrivals) is crucial for realistic traffic simulations.
- Large language models can be used as adaptive decision-makers, but they require carefully structured prompts and constraints.
- Combining domain knowledge (traffic engineering heuristics) with AI reasoning leads to much more stable and effective behavior.
What's next for FlowMind
FlowMind is just the beginning. Future improvements could include:
- Using real-world traffic data for more accurate simulations
- Supporting multi-intersection coordination and handling multiple vehicle types with varying priority levels
- Scaling the simulation to model entire urban traffic networks
My vision is to explore how intelligent systems like FlowMind could eventually help create smarter and more adaptive traffic infrastructure for modern cities.
Built With
- amazon-web-services
- python
- streamlit
Log in or sign up for Devpost to join the conversation.