My first experience building an agent based model

Yuhao Sun
Arup’s City Modelling Lab
9 min readJul 21, 2021

Yuhao Sun is a data scientist at Arup working on city modelling projects using data analytics and machine learning.

My first project at Arup was supporting the development of an Agent Based Model (ABM) for Suffolk County Council, with the aim of gaining some specific insights into agent travel choices and motivations for mode choice. I worked with a mixed team from the City Modelling Lab (CML) and Arup’s wider Transport Planning team to deliver insights in 12 weeks. Building a first ‘Alpha’ model in this timeframe is a real challenge and something we’re only able to do because of the tooling we’ve developed.

I would like to use this blog to share my personal experience implementing my first ABM, and trying to solve some strategic challenges in transport planning.

What is an ABM?

Our team wrote a couple of medium posts to introduce ABMs, such as ABM vs traditional transport modelling and ABMs in action. ABMs are a very versatile computational technique which simulates the interactions of individual agents within a system to assess the resulting behaviour of the whole system. Due to limitations in computation power, it didn’t become a widespread tool to solve real-world business problems until the late 1990s. The fundamental elements in ABM are shown in the following figure:

  • Agents: they are distinguished, independent individuals in their characteristics, values and behaviours.
  • Environment: agents are active components of an environment and coexist with other agents
  • Rules: how agents interact among themselves and with environments
Schematic of the typical elements of an agent-based model

In this post, I will focus on the development of an Alpha ABM in a transport planning project.

My experience on simulation models vs CML’s ABM approach

Over the past thirty years, data science has developed from one discipline to a multi-disciplinary field that employs mathematical algorithms and scientific theories to extract insightful information from datasets. I have gained some experience in building predictive models and cloud simulation platforms from my previous research projects. The simulation software and models I have worked on are different compared to CML’s ABM approach but there are some things in common. I will discuss the ABM approach compared to my past experiences on simulation models in terms of three key components: modularity, cloud computing and flexibility.

Modularity:

The bottom-up approach to solve a complex problem is similar between my past experience and the ABM approach. In a bottom-up approach, relatively narrow goals are initially set at the lower levels and then gradually integrated into the framework of the global goals at higher levels. The bottom-up approach has high interactivity between the various modules.

My previous research focused on intelligent manufacturing processes in the metal forming industry. It is a well-established industry that generates vast volumes of data through Finite Element Analysis (FEA). Improving the efficiency of the manufacturing process based on different FE models is difficult because the process is influenced by various segmented domains such as material characterization, tooling and tribology. Meanwhile, the FE results produced in different domains are still isolated within the industrial sectors. Imperial College London Metal Forming Group developed an innovative online FEA platform, called SmartForming in 2019. The platform has different functional modules developed by various domain experts. The user can conduct a multi-objective finite element simulation of a sheet metal forming process in one goal.

In transport planning, there is an increasing need to develop models that can answer questions on complex behaviours, equity and interactions between different agents and modes. These questions are complicated because it is difficult to simulate unpredictable and complex human behaviours. The agent based model is an exciting tool to solve these problems. One of the key advantages of the ABM approach is that it provides a microscopic framework for integrating different transportation related models to solve a problem in one system, and then allows each agent in that system to use the most appropriate model for solving its specific problem.

Cloud computing:

Benefits of cloud computing (Swift pace solutions, 2017)

With the introduction of Industry 4.0 and Internet of Things (IoT), industrial operations are becoming increasingly cloud based, promoting cyber-physical systems, as well as resource sharing and establishing networks that enhance efficiency. Cloud computing offers many benefits with key advantages such as cost reduction, flexibility in work and increased collaboration.

To build a cloud-based platform for multi-objective FE simulations is a challenging process not only because we need experienced cloud engineers to build infrastructure and pipelines to link different modules, but also because the previous FE simulation software is not open-source. In the early stages, my previous research group encountered some drawbacks such as conflict using computational resources from different users due to the limited computation power in using a private cloud.

In terms of our ABM approach, cloud computing is essential because our simulations require significant computing power. It is surprising that our team built the dedicated Amazon Web Service (AWS) environment in a very short period. With previously developed tools, our approach significantly sped up our development of ABMs to facilitate more accurate and faster results, timely experimentation, and optimization. To further reduce the cost and duration of strategic transport agent-based model (ABM) run times is still quite challenging. We had some ongoing plans on extending existing ABM pipeline orchestration tooling to reduce the computational cost with the increased uncertainty around the future of transportation.

Flexibility:

The significance of cloud FEA platform as opposed to the traditional static production line is that it adds flexibility through module-based services that operate on the cloud, data are exchanged freely resulting in more effective solutions and higher productivity. Such cloud FEA services are central to knowledge digitisation as well as intelligent manufacturing, providing essential computer-aided engineering (CAE) tools more widely but also enabling streamlined knowledge and data exchange, particularly between researchers and researchers, researchers and industry users.

Flexibility is also one of the key advantages of our ABM approach. Although the data cannot be exchanged frequently with different transport modellers and researchers due to input data normally is confidential. Different tools we built are open-source, which had been validated for several different transportation projects. These tools make feasible the iteration or reuse of ABMs rather than complete rebuild which greatly shortened the time of implementing the ABM approach.

The flexibility of ABM is also reflected in that it allows for unified and systematic modelling of different scenarios at different levels with rapidly changing environments. This post won’t talk about it in detail and you can find more information from another medium post: Pandemic Activity Modifier: Intro.

Development of CML’s ABM approach

We recently built the Alpha ABM for Suffolk County within 12 weeks. From my perspective, the CML’s ABM building process could be divided into four main steps:

  1. Transportation supply(network) and demand(population)
  2. Model configuration and simulation
  3. Post processing
  4. Calibration and validation
The development of CML’s ABM approach

Generate transportation demand and supply

Firstly, population synthesis aims to create representative populations and more detailed agent plans and that would be used for ABM simulation. These agents plans are made up of desired activities undertaken at different locations and linked by travel legs. Our approach applies statistical and geospatial techniques to combine granular travel behaviour information, from travel survey data, with aggregate distributions of the population’s attributes and demand patterns. 24 hour activity plans were created to modify people’s behaviour via a powerful tool called Pandemic Activity Modifier(PAM). The tool allows multiple policies to be combined to build realistic and complex scenarios based on rapid changing environments and policies.

The network is synthesised from two primary sources: Open Street Map (OSM) and General Transit Specification Feed (GTFS) dataset. The realistically detailed network would be generated as required. Some unnecessary detail of network is simplified for computation efficiency. The network includes bus and rail transit services as a separate infrastructure based on GTFS. It can be directly generated using a tool called Network Scenario Generator (GeNet) which helps to maintain correct data structure throughout.

Model Simulation

The Multi-Agent Transport Simulation (MATSim), the core of the modelling process, is used to simulate the baseline behaviour of the population on the transport system. MATSim is an open-source software project which simulates at 1 second resolution for the entire 24-hour day, allowing extraction of outputs in fine detail. The agent within a simulation process optimises their daily schedule by taking different decisions (time, route, mode, destination). MATSim allows agents to vary their time choice, mode selection and even destination alongside route assignment which effectively combines all choices from traditional 4-step modelling steps within the same optimisation.

The development and the running of the simulation require significant computing power, exceeding the capability of a standard laptop commuter. This is due to the complexity of the individual agent’s processing and/or the number of agents in a simulation increase, the number of computational operations performed in each iteration of the simulation increases. Our team have created a dedicated Amazon Web Service (AWS) environment, along with tooling to help manage the cloud infrastructure required for simulations. The approach facilitates access to elastic high-performance computing without the associated high cost.

Post processing

Some simulation outputs from MATSim are saved as xml which is difficult to extract insight from the formatted data. Our team built a tool to process these outputs into more easily useable formats, such as tabular (csv) and spatial (geojson) formats for analysis purposes. The processed outputs provided detailed insights including vehicle volumes, mode share and transport network. The tool is also extendable to follow the instruction to add new features or benchmarks for comparison as they wish.

In terms of model building time, we developed an alpha ABM at county scale within 12 weeks which is much faster than the traditional strategic model. We also performed partially calibration to achieve a very good agreement with benchmarks in a limited time. For our latest county-level project, we simulated a 10% representative population (67k agents) and the result achieved stabilisation after 400 iterations in only 30 hours.

Validation and calibration

Validation of a model is essential as it shows how well the model can reproduce reality. For example, we can use some external historical traffic data as benchmarks to verify vehicle counts and mode distributions. To improve the performance of the model against benchmarks, the calibrated process is conducted on inputs of the simulation. We can explore how model’s results change based on various inputs. The following figure showed an example of a good agreement between simulated hourly car volumes and benchmarks after calibration.

My experience in building our ABM approach

This was my first chance to build and implement an ABM on a transportation-related project. The dedicated tools have been built on network and population generation so that we are able to implement an ABM smoothly in a very short period.

Challenges

The validation and calibration part of our approach is essential and challenging. The preliminary simulation results demonstrated some differences in mode shares with the benchmarks. Our team reacted swiftly by adjusting various inputs and achieved noticeable improvement after calibration. It is not easy to perform calibration in the right way because you need a comprehensively understanding of the methodology. Meanwhile, it is difficult to validate from all aspects of simulation outputs because some of the historical traffic data is not available or in good quality.

Future work

The future for using ABM in transport planning looks bright and some interesting topics we can work on. The demand for using the ABM approach has been steadily increasing, notably in the sector of transportation planning, as the number of vehicles on the road continues to rise year after year while environmental issues remain unaddressed. It would be interesting to integrate transport gas-emission models to population or network and to predict future gas emissions. These predictions are valuable for local authorities and the government to formulate a reasonable policy of emissions control. I would also like to involve in is producing scientific papers for our innovative models and methods to enhance academic and industry communication. Perhaps our approach can be replicated in different industries while bringing new inspiration to academics.

Overall, it is an insightful journey to implement our ABM approach to a real project. It is a challenge for a person who came from non-transportation related background to have an in-depth understanding of our method because transport domain knowledge is required. I am expecting to predict future scenarios and conduct more analytics to discover some new insights for a long-term ABM project.

--

--

Yuhao Sun
Arup’s City Modelling Lab

Data Scientist from Arup. Passionate about using machine learning and data analytics to produce novel solutions to a complex business problems.