4.3: Traffic#
Learning objectives
Implement and Analyse Model Metrics:
Define key metrics within an ABM model to quantify agent behaviours and overall system performance.
Calculate these metrics during model execution and interpret their significance in understanding model dynamics.
Perform Parameter Sweeps:
Conduct one-dimensional, two-dimensional, and three-dimensional parameter sweeps to systematically explore the effects of varying model parameters on agent behaviour and system outcomes.
Analyse the outcomes of these sweeps to understand the sensitivity of the model to different parameters and to identify key factors influencing model dynamics.
Data Transformation and Visualisation:
Transform model output data into a format suitable for analysis, such as a pandas DataFrame.
Apply data reshaping techniques, such as melting, to organise the data for effective visualisation.
Visualise the results using tools like Seaborn’s FacetGrid, employing line plots, heatmaps, or other visualisation techniques to represent the data in a multi-dimensional context.
Modify and Evaluate Model Behaviour:
Understand how changes in agent behaviours and model parameters impact overall system dynamics.
Implement modifications to the model to include new behavioural rules or parameters that influence agent interactions.
Visualise the results of these behavioural changes using appropriate plots and animations.
Analyse the broader implications of modified agent behaviours on system performance, efficiency, and resilience.
*The code is based on an agent-based traffic model, designed to simulate and analyse traffic dynamics and behaviours. This model provides a simplified yet insightful representation of vehicle interactions on a circular road, allowing us to explore various aspects of traffic flow, congestion, and the impact of driver behaviours.
In this model, we simulate a number of vehicles (agents) driving on a circular road. Each vehicle has its own speed, acceleration, and deceleration characteristics, which can be adjusted based on different scenarios and driver behaviours.
The traffic simulation starts with a specified number of vehicles, each placed at an initial position on the road with a randomly assigned speed. Vehicles interact with one another by adjusting their speed and position based on the distance to the car in front of them. This adjustment depends on factors such as the driver’s carefulness, lookahead distance, and reaction time.
The model progresses in discrete time steps. During each step, each vehicle updates its position and speed based on its own dynamics and the behaviour of the vehicle in front. Vehicles may slow down to avoid collisions or speed up if the road ahead is clear.
As the simulation progresses, we can observe the formation of traffic patterns, such as smooth flow, stop-and-go waves, or traffic jams. This model allows us to study how different parameters, such as acceleration, deceleration, and driver carefulness, affect overall traffic dynamics and congestion levels over time.*
Before modelling the system, watch the short experiment below. The drivers receive no instruction to create congestion: a small variation in speed is enough for a backwards-moving traffic wave to emerge.
A traffic model is simply a set of drivers, each one speeding up when the road is clear and braking when it is not. The activity below places such drivers on a ring road and lets you make it busier. Before you do, predict whether adding cars slows the traffic smoothly, or whether the flow holds up until it suddenly collapses into a stop-and-go jam.
Key takeaways#
Key takeaways
Traffic flow emerges from drivers accelerating, braking, and reacting to the gap ahead.
Density and behavioural parameters can produce qualitatively different regimes, including congestion waves.
The exercises move from one run to parameter sweeps with repeated simulations.
Begin with 4.3.1: Exercises to build, run, test, and extend the model.