Simulating City Traffic with AI Agents

Author: Denis Avetisyan


Researchers have developed a new framework that uses artificial intelligence to create realistic and adaptable traffic simulations based on natural language commands.

The TrafficSimAgent framework establishes a comprehensive system for simulating traffic interactions, offering a structured approach to understanding and influencing complex vehicular behaviors.
The TrafficSimAgent framework establishes a comprehensive system for simulating traffic interactions, offering a structured approach to understanding and influencing complex vehicular behaviors.

TrafficSimAgent is a hierarchical multi-agent system leveraging large language models and Model Context Protocol for autonomous traffic optimization and generalizable simulation.

Despite the importance of traffic simulation for optimizing transportation systems, existing platforms often present a steep learning curve for users designing and executing complex experiments. To address this challenge, we introduce TrafficSimAgent: A Hierarchical Agent Framework for Autonomous Traffic Simulation with MCP Control, a novel system leveraging large language models and a multi-agent architecture to enable intuitive, natural language-driven simulation and autonomous optimization. This framework facilitates experiment design and execution through collaborative agents operating at multiple levels, yielding superior performance compared to existing methods and state-of-the-art LLM approaches. Could this paradigm shift towards autonomous, agent-based simulation unlock new levels of efficiency and insight in urban planning and traffic management?


Unveiling the Complexity of Modern Traffic Simulation

Traditional traffic simulations, despite their value, often fall short when attempting to replicate the intricacies of real-world driving. These systems frequently simplify complex behaviors, representing vehicles as point masses or relying on pre-defined routes and limited interaction models. This simplification neglects crucial factors like nuanced driver intention, unpredictable pedestrian movements, and the cascading effects of even minor incidents. Consequently, autonomous systems trained solely within these constrained environments can exhibit brittle performance when deployed on actual roadways, struggling with unforeseen circumstances or exhibiting unsafe maneuvers. The inability to accurately model this complexity presents a significant bottleneck in the development and validation of robust, truly autonomous vehicles, necessitating more sophisticated simulation frameworks capable of capturing the full spectrum of real-world traffic dynamics.

Current approaches to traffic simulation frequently depend on pre-programmed instructions that dictate how individual vehicles – the ‘agents’ – behave. These systems often struggle because they cannot adequately model the unpredictable and complex interplay between drivers, pedestrians, and varying road conditions. While useful for basic testing, such simulations fall short of replicating the subtle negotiations, anticipatory adjustments, and occasional errors that characterize real-world traffic. This limitation hinders the development of robust autonomous systems, as these systems require exposure to a far wider range of behaviors than hand-crafted rules can provide; a truly dynamic environment demands agents capable of learning and adapting, rather than simply following predetermined paths.

The progression of autonomous driving and the realization of truly smart cities hinge upon the development of traffic simulation frameworks capable of both scale and adaptation. Current limitations in simulating complex, real-world traffic scenarios necessitate systems that can efficiently model vast urban environments and a high density of interacting agents. Crucially, these frameworks must move beyond static representations, instead incorporating the ability to learn and evolve alongside changes in infrastructure, traffic patterns, and the behaviors of diverse road users. Such adaptability is paramount, allowing for the continuous refinement of autonomous algorithms and the proactive assessment of novel urban planning strategies, ultimately fostering safer, more efficient, and more resilient transportation ecosystems.

TrafficSimAgent generates user data reflecting diverse age and gender distributions across different user groups.
TrafficSimAgent generates user data reflecting diverse age and gender distributions across different user groups.

TrafficSimAgent: Orchestrating Dynamic Simulation with LLMs

TrafficSimAgent utilizes Large Language Models (LLMs) as a central control mechanism for traffic simulations, enabling dynamic adaptation beyond the constraints of traditional, statically defined scenarios. The LLM functions as an orchestrator, receiving high-level simulation requests and translating them into a sequence of actionable steps. This approach allows for the creation of simulations with variable parameters and complex events – such as incident management or dynamic rerouting – without requiring extensive pre-programming of every possible condition. The LLM’s reasoning capabilities facilitate the generation of diverse and realistic traffic patterns, thereby increasing the simulation’s capacity to model unpredictable real-world conditions and assess the impact of novel traffic management strategies.

TrafficSimAgent utilizes a modular architecture where complex simulation requests are broken down into discrete subtasks by the Orchestrator Module. This module then dynamically routes each subtask to the appropriate specialized component for execution. For example, a request to simulate traffic in a new city would first be directed to the Map Generator to create the road network. Subsequently, the Trip Generator would be activated to define origin-destination pairs and vehicle routes. This decomposition and dynamic routing approach allows for flexible simulation design and efficient resource allocation, enabling the system to address a wider range of scenarios than traditional, monolithic simulation tools.

TrafficSimAgent addresses the limitations of traditional traffic simulation by integrating Large Language Model (LLM)-based reasoning with established platforms such as SUMO. Prior methods typically rely on pre-defined scenarios, restricting adaptability to novel or unforeseen conditions. TrafficSimAgent, however, utilizes the LLM to dynamically adjust simulation parameters and generate diverse traffic patterns, enabling improved generalization across a wider range of scenarios. This approach moves beyond static, rule-based systems to a more flexible framework capable of responding to variable inputs and complex interactions, thereby enhancing the robustness and realism of the simulations.

TrafficSimAgent’s LLM-driven approach to traffic simulation facilitates optimization of several key performance indicators. Specifically, the framework targets a reduction in carbon emission through optimized route planning and speed control. Simultaneously, it aims to minimize average queue length at intersections by dynamically adjusting signal timings and traffic flow. Furthermore, TrafficSimAgent seeks to maximize cumulative throughput – the total number of vehicles successfully navigating the simulated network – by efficiently managing congestion and prioritizing vehicle movement. These metrics are continuously evaluated and adjusted during simulation runs, enabling the framework to identify and implement strategies for improved traffic network performance.

TrafficSimAgent generates user data reflecting varying levels of education, allowing for analysis across different demographic groups.
TrafficSimAgent generates user data reflecting varying levels of education, allowing for analysis across different demographic groups.

Dissecting the Architecture: Functional Integration for Adaptive Control

The Task Understanding Module utilizes natural language processing (NLP) to convert user-defined objectives and simulation parameters from plain language into a structured, executable format. This allows users to define complex simulation scenarios – such as modeling traffic flow during peak hours with specific incident conditions – without requiring specialized scripting or coding knowledge. The module parses instructions relating to parameters like vehicle density, road network configurations, and desired performance metrics, translating these into the necessary inputs for subsequent modules. This intuitive interface streamlines the simulation setup process and broadens accessibility for users without expertise in traffic modeling or simulation software.

The Autonomous Planning Module facilitates dynamic workflow construction by integrating available functional modules – such as task understanding, optimization, and simulation execution – on demand. This module eschews pre-defined, rigid sequences, instead leveraging an event-driven architecture to respond to the specific requirements of each simulated traffic scenario. It assesses incoming simulation parameters and objectives, then intelligently chains together the necessary modules to achieve the desired outcome. This adaptability allows the system to handle a wider range of traffic conditions, incident management protocols, and control strategies without requiring manual reconfiguration or pre-scripted responses.

The Optimization Module utilizes full-stack automatic optimization techniques to improve simulation performance and derive superior traffic control strategies. This functionality extends beyond parameter tuning, encompassing simultaneous optimization across multiple layers of the simulation stack – including signal timings, routing decisions, and vehicle speed profiles. Benchmarking demonstrates that strategies identified by the Optimization Module consistently outperform traditional Traffic Signal Control (TSC) algorithms, achieving reductions in average travel time, queue length, and overall network congestion as measured by key performance indicators during simulated traffic flows.

The Simulation Executor component functions as the central control unit for running simulation tasks, abstracting the complexities of the underlying simulation engine. It currently integrates with the Simulation of Urban MObility (SUMO) platform, utilizing SUMO’s capabilities for traffic microsimulation, network definition, and vehicle movement. This integration allows the system to leverage SUMO’s established features for road network construction, traffic demand modeling, and the implementation of various traffic control strategies. The Executor manages the transfer of parameters and configurations to SUMO, initiates the simulation run, and retrieves results for analysis by other modules. Support for additional simulation platforms is planned through a modular interface, enabling the system to adapt to different simulation environments and validation tools.

Optimization method performance, as measured by key metrics, varies across simulation steps, demonstrating differing convergence rates and stability.
Optimization method performance, as measured by key metrics, varies across simulation steps, demonstrating differing convergence rates and stability.

Expanding the Horizon: Agentic Frameworks and the Future of Simulation

The integration of Large Language Models (LLMs) with agentic frameworks – systems like OpenManus, MetaGPT, and WebAgent – represents a significant leap forward in the creation of dynamic and comprehensive simulations. These frameworks allow LLMs to move beyond simple text generation and actively interact within simulated environments, controlling agents and generating multimodal data encompassing text, images, and potentially other sensory inputs. This capability unlocks new avenues for data generation, enabling the creation of synthetic datasets tailored to specific needs, such as training autonomous vehicles or modeling complex social behaviors. By empowering LLMs to act within simulations, researchers can explore scenarios and generate data with a level of realism and adaptability previously unattainable, fostering innovation across a wide spectrum of fields.

Simulated environments gain significantly enhanced fidelity through the incorporation of TrajAgent, a component dedicated to realistically modeling movement trajectories within traffic simulations. Unlike traditional methods that often rely on simplified or pre-defined paths, TrajAgent predicts the likely future positions of individual vehicles and pedestrians based on their current state and interactions with the surrounding environment. This predictive capability extends beyond simple path planning; it accounts for nuanced behaviors like lane changes, yielding to pedestrians, and reacting to unpredictable events. The result is a more dynamic and believable simulation where traffic patterns mirror real-world complexities, allowing for more accurate testing of autonomous systems, evaluation of urban planning strategies, and a deeper understanding of traffic flow dynamics.

Recent advancements demonstrate that integrating Large Language Model-driven traffic signal control algorithms-specifically LLMLight and MPLight-significantly enhances urban traffic management. These algorithms move beyond traditional, pre-programmed timing by dynamically adjusting signal phases in response to real-time traffic conditions. Studies reveal that this adaptive control not only reduces overall congestion and average queue lengths at intersections, but also demonstrably minimizes carbon emissions compared to conventional methods. The optimization stems from the LLMs’ ability to predict traffic flow and proactively adjust signals, creating a smoother, more efficient transportation network and contributing to more sustainable urban environments. This represents a shift toward intelligent traffic systems capable of self-optimization and responsiveness to changing demands.

The development of highly detailed and adaptable simulations, powered by agentic frameworks, promises to reshape fields ranging from urban planning to the advancement of autonomous vehicle technology. These simulations move beyond static representations by modeling complex interactions and dynamic environments with unprecedented realism. Consequently, city planners can now virtually test infrastructure changes – such as new road layouts or public transportation systems – before physical implementation, optimizing for efficiency and sustainability. Simultaneously, the simulations provide a safe and cost-effective environment for training and validating autonomous vehicle algorithms, exposing them to a diverse range of traffic scenarios and edge cases. This iterative process accelerates development, enhances safety protocols, and ultimately fosters the creation of smarter, more responsive urban ecosystems and more reliable self-driving systems.

Looking Ahead: Real-Time Responsiveness and the Evolution of Traffic Systems

The next phase of development for TrafficSimAgent prioritizes a shift towards real-time responsiveness. Currently excelling in modeled scenarios, the framework will be engineered to ingest and process live data feeds – including speed, volume, and incident reports – allowing simulations to mirror actual traffic fluctuations. This adaptation necessitates robust algorithms capable of dynamically adjusting parameters and recalibrating predictions as conditions evolve. By incorporating real-time data, TrafficSimAgent moves beyond predictive modeling to become a powerful tool for adaptive traffic management, enabling proactive responses to congestion, accidents, and other unforeseen events. The goal is not simply to simulate traffic, but to create a digital twin capable of informing and optimizing traffic flow in the present moment, thereby laying the groundwork for truly intelligent transportation systems.

The incorporation of reinforcement learning into TrafficSimAgent promises a significant leap in both the effectiveness of traffic management and the fidelity of its simulations. This advanced machine learning approach allows the system to learn optimal traffic control strategies through trial and error, responding dynamically to simulated congestion and incidents. Unlike pre-programmed algorithms, reinforcement learning enables the agent to continuously refine its decisions – adjusting signal timings, lane configurations, or even suggesting dynamic speed limits – based on observed outcomes. This iterative process not only yields more efficient traffic flow within the simulation, reducing travel times and fuel consumption, but also enhances the model’s predictive accuracy by mirroring the adaptability of real-world traffic networks.

The current simulation framework is poised for significant advancement through the inclusion of diverse transportation modalities beyond private vehicles. Researchers aim to integrate detailed models of public transit systems – buses, trains, and trams – accounting for schedules, passenger loads, and route optimization. Simultaneously, pedestrian traffic will be incorporated, simulating movement patterns, crosswalk usage, and interactions with vehicular traffic. This multi-modal approach is crucial for creating a truly comprehensive and realistic simulation environment, as it acknowledges the interconnectedness of various transportation methods within a city. By accurately representing these interactions, the framework will move beyond isolated vehicle simulations to offer insights into the overall efficiency and sustainability of urban transportation networks, ultimately enabling more holistic and effective city planning.

TrafficSimAgent represents a significant step toward fundamentally reshaping how transportation networks are conceived, operated, and refined. This innovative framework offers the capacity to move beyond reactive traffic management – simply responding to congestion as it occurs – toward a proactive, predictive approach. By enabling detailed simulations and optimization of complex traffic scenarios, the system allows planners and engineers to test interventions – from adjusted signal timings to entirely new road layouts – in a risk-free virtual environment. The potential extends beyond simply alleviating gridlock; it facilitates the design of transportation systems that prioritize sustainability through reduced emissions and fuel consumption, and enhance efficiency by minimizing commute times and maximizing throughput. Ultimately, the widespread adoption of TrafficSimAgent promises not merely smoother traffic flow, but the creation of urban centers that are more livable, environmentally responsible, and economically vibrant.

The pursuit of generality in TrafficSimAgent, allowing for adaptable traffic scenarios through natural language, mirrors a fundamental principle of robust system design. Barbara Liskov aptly stated, “It’s one of the great failures of our profession that we don’t have a better understanding of how to design systems that can evolve.” This framework doesn’t merely simulate traffic; it establishes a foundation for adaptable, context-aware behavior. The hierarchical agent structure, coupled with the Model Context Protocol, permits modification and expansion without necessitating a complete overhaul, demonstrating a commitment to systems that gracefully accommodate change. Good architecture is invisible until it breaks, and only then is the true cost of decisions visible.

Beyond the Intersection

The elegance of TrafficSimAgent lies in its ambition-a unified framework for traffic simulation governed by natural language. However, the pursuit of generality often reveals the brittleness of assumptions. If the system survives on duct tape and clever prompting, it’s probably overengineered; a testament to the difficulty of abstracting away the messy particulars of real-world behavior. The current implementation, while promising, operates within a relatively constrained domain. Scaling to truly complex urban environments, replete with unpredictable pedestrian flows and the emergent chaos of human drivers, will demand more than simply increasing model parameters.

The real challenge isn’t generating plausible traffic, but generating robust traffic. Modularity without context is an illusion of control. A hierarchical agent structure is only effective if the interactions between levels are grounded in a coherent understanding of the system’s underlying dynamics. Future work must address the question of how to imbue these agents with a sense of ‘situatedness’ – an awareness of their place within the broader urban ecosystem.

Ultimately, the success of this approach will hinge on its ability to move beyond simulation as a predictive tool, and towards simulation as a platform for exploring possible futures. The framework should not merely replicate traffic patterns, but allow researchers to pose counterfactual questions – “What if we prioritize bicycle lanes?” or “How would a sudden influx of electric vehicles affect congestion?” – and observe the cascading effects with a level of fidelity that transcends intuition.


Original article: https://arxiv.org/pdf/2512.20996.pdf

Contact the author: https://www.linkedin.com/in/avetisyan/

See also:

2025-12-27 22:33