Pandemic Activity Modifier: Intro

Our new open-source Python library for generating and modifying transport demand scenarios

Fred Shone
Arup’s City Modelling Lab
5 min readMay 15, 2020

--

Fred is a data scientist at Arup working on machine learning and city modelling.

The Pandemic Activity Modifier (PAM)is our little contribution to the efforts against COVID-19. In a nutshell PAM is a modelling tool for pragmatically changing the behaviours of a population based on new government policies.

This is part one of a short series on PAM:

Part 2: Pandemic Activity Modifier: Activity Plans

Part 3: Pandemic Activity Modifier: Applying Complex Policies

Who is this for?

PAM is a tool for planners working with tour or activity based representations for their transport models. It is for quickly updating these models for lockdowns and sensibly modelling potential staged lockdown easing scenarios.

More generally if you work with activity data then we think PAM provides a pretty handy set of tools for all sorts of future work- related to modifying activity plans.

Motivation

Suddenly the world has changed and a lot of existing models are out of date — there are new rules and people aren’t behaving the same way.

Cities have to keep operating in this new reality in the short term and planning for the medium-term, when normal might look different. Some of the decisions planners are going to make, for example about which stations to open, how many buses to run, even how much loo roll to stock are going to be tricky without up to date models.

Activity Plans

PAM uses 24hr Activity Plans as the underlying framework for modifying people’s behaviour. This gives PAM access to a powerful group of levers to make change to how agents in our model behave. PAM can make changes to the type of activities an individual engages in, the times, durations, locations, distances, modes, person attributes, household attributes and sequences. PAM provides an API to leverage this information to make sensible changes — like removing or adding activities of a certain type in a certain area — or moving them to a new time.

Example Activity Plans

Activity Plans can then be used to drive all sorts of models. We tend to use them for transport demand but they can also be used for modelling societal change, commercial demand, utility demand or virus transmission.

Features

The PAM API has three core functionalities: Read, Modify and Write.

PAM feature overview — read, modify & write

Read — Load some population data into Activity Plan format (we currently support a variety of tabular formats and MATSim xml). This module includes the functionality to read in travel diary data and infer activities.

Modify — Apply ‘Policies’ to change the activity plans of the population. Policies have a modifier (eg: “remove this activity…”), a probability (“…from 50%...”) and a filter (“…of people over the age of 16.”).

Write — Output the adjusted population back onto a useful format such as trip diaries or OD matrices.

Design

PAM works with class based data formats (Populations, Households, People, Plans, Activities and Legs). This is slower than working with databases. However, what we lose in performance we gain in usability — as a result it’s easy to implement lots of really nuanced changes.

PAM data structure

Beyond the simple policy changes (e.g. stopping leisure activities or shifting more people to work from home), we’ve implemented some pretty complex policies. Here are four examples that illustrate complex policies:

Household Quarantine policy: This is a modifier that probabilistically assigns persons as having the virus. This probability can be adjusted to reflect the person’s age or occupation (for example). If a person is assigned as infected then the whole household has to stay at home.

The one person shopping policy: This is a modifier that searches through a household’s shared activities (think family grocery shopping trips) and removes all but one of the tours. The result is that only one person in a household will take a shopping trip, compared to all members of the household participating in the same shopping trip.

Education removal: In most cases this policy removes all education activities from a household. But if a household is care-constrained, i.e. all the adults are key-workers, then the education activities are maintained.

Closer to home: This policy moves activity tours closer to home (think grocery shopping again). This policy only moves isolated tours closer to home — it doesn’t affect chained tours of other activities (like stopping at the shop on the way back from work or at lunch time). We can also adjust the agent’s travel mode for the new closer to home trip (e.g. making the trip a walking trip, instead of a trip by car or public transit).

Combined together, these policies form a pragmatic way of updating activity plans. Along with the read and write capability, this makes PAM a really quick way of building new scenarios.

Example Policies for creating a simple COVID-19 Baseline Scenario

Validation

We’ve done some experiments already and calibrated them using Google Mobility data (take a look at this paper for the details of what is being measured). This is a crude form of validation but preliminary results are very encouraging. Because the policies we are applying are based on representative systems, like households, tours and activity sequences — we can implement some really complex policy mechanisms relatively easily. For predicting future scenarios, we think this pragmatic approach will adapt really well.

Next Steps

PAM is an open source (MIT license) python project on GitHub. It is work in progress but has a stable API and is maintaining over 80% test coverage.

We’re still busy adding functionality and documentation — if you like what you see and want to get involved or make use of PAM then please get in touch — citymodelling@arup.com

The Team

PAM has lurched from idea to minimum viable product (MVP) in only four weeks thanks to evenings and weekends from the following contributors: Andrew Kay, Ella Dahan, Iseul Song, Kasia Kozlowska, Michael Fitzmaurice, Rory Sedgwick and Theodore Chatziioannou.

--

--

Fred Shone
Arup’s City Modelling Lab

Technical Lead @ Arup City Modelling Lab. Making simulations really big and really useful.