Pandemic Activity Modifier (Part 3): Applying Complex Policies

Using our open-source tool to modify activity plans en masse

Kasia Kozlowska
Arup’s City Modelling Lab
8 min readMay 26, 2020

--

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

The Pandemic Activity Modifier (PAM) is an open-source python project which utilises an activity based representation of a population. It makes rules based modifications to individuals’ travel and activities. We described the design and function of PAM in this Intro post and the details behind activity plans in this Activity Plans post.

I’m here to tell you the gory details of what happens under the hood when you apply these activity modifications in PAM.

PAM operates on a population which is a collection of ‘people’. These people eventually become the agents in our agent-based models. Each person has a plan — a list of various activities they do in a day and legs in between which define how they get from one activity to another. Each person belongs to a household.

Example of a three-person household.

The way we go about our day has changed dramatically because of the social distancing measures in place as a result of COVID-19. In many parts of the World, we are living with new, mandated restrictions in what we are allowed to do and where we can go. Different people will of course adhere to these new rules differently, according to their different circumstances. For example, key-workers will have different activities compared to people who can work from home, or may be on furlough, or may be experiencing unemployment. We attempted to capture the differences in an individual’s activity plan pre- vs post-COVID-19 by implementing rules-based, probabilistic modifications. We call these modifications policies.

PAM splits policies into three main levels of application and sampling:

  • Household
  • Person
  • Activity

Household Policies

A household policy is one that is applied to all persons within the household. A household is picked for policy application based on a probabilistic value between 0 and 1, but in the case of a household policy, this value could pertain to any of the possible levels: household, person or activity. Given a value at the particular level we can compute how it affects a particular household.

For example, let’s look at the likelihood of a household having to be quarantined given the likelihood of any one person being infected. For now, let’s keep the likelihood equal for all people. The entire household, which the infected person belongs to, will need to be quarantined. It makes sense that the more people you have in the household, the more likely it will be that someone in the household will be infected — affecting the final likelihood for the household to be quarantined.

In general, the probability of a household being affected by a policy (P_household), based on the probability P_person of a person in the household being affected by that policy is:

where n is the number of people in the household. This follows from computing the probability of no one in the household being selected and taking it away from 1. This can be illustrated by following the right branches of the probability tree below.

Probability tree for a three person household and probability P_p of a person being selected.

Examples of household policies

The household quarantining policy is a simple example to understand how household policies effect activity plans. We can expand on the same framework to build more complex policies.

Let’s consider another example. If all schools are declared closed by a government, we can apply that policy with PAM. We remove all education and education-related escort trips (think parents bringing their child to school) from all members of the selected households:

Example three-person household (pre policy application)
Example three-person household missing education and escort activities (post policy application)

Another household example would be removing some people from shared activity tours. For example removing shopping tours from everyone in the household apart from one person who still goes shopping. We can apply these household activity changes in PAM.

Example three-person household (pre policy application)
Example two-person household where the shopping trips were reduced to one person (post policy application)

Person Policies

A person policy is one that is applied to all relevant activities in a person’s plan. A person is picked for policy application based on a probabilistic value between 0 and 1. In the case of a person policy, this value could pertain to either a person or activity. Given a value at activity level we can compute how it affects a particular person in much the same way as we computed the probability for a household given values for each person.

where n is the number of relevant activities and P_activity is the probability assigned to that activity. There could be a long list of activities, each with their own probability of being selected. Reiterating, we operate under the assumption that selection of one activity from the given list initiates the selection and application of the policy to a person’s plan. Thus, the right hand side of the equation is equal to 1- a product of the probabilities that all the relevant activities in a person’s plan are not selected. Jump to the end of this post to see this written down explicitly.

Examples of person policies

Work related policies are good examples of person policies. For example unemployment, furlough or working from home will all mean removing work activities. In the example below, Bradly is affected by the policy and his work activities are removed.

Example three-person household (pre policy application)
Example household with work activity removed on a person level (post policy application)

Another example could be removing all leisure-type activities or moving shopping or sport activities closer to home. When moving activities, we think of tours of activities to move. A tour is a chain of activities sandwiched by home activities.

Activity Policies

An activity policy is one that is applied to a single activity in a person’s plan. Any relevant activity in a plan has a chance of being selected and modified — in its own right. As before, an activity is picked for policy application based on a probabilistic value between 0 and 1. In the case of an activity policy however, this value can only relate to activity. In other words, we cannot use a probability value aimed at selecting a person or a household to remove single activities. If you are defining an activity based policy, you clearly care about cases where a person has more than one instance of that activity type, so which activity would you remove? You need more detailed information than which person or household to select.

We can summarise this hierarchy and the relationship between probabilities in the following table:

Examples of activity policies

Reducing individual work, health or shopping related activities are good examples of activity policies. People may still be performing such activities, just at a reduced frequency. In the example below, Bradly is affected by the policy. He is working less and a couple of his work activities are removed.

Example three-person household (pre policy application)
Example of a household with reduced work activity (post policy application)

Extras

PAM’s Policies can get a great deal more complicated. So far we have talked about the same probability values for any person or an activity.

Attribute Filters

In the first degree of complication we can choose to have a policy affect only people — or households containing a person — satisfying different personal attribute conditions. For example if we want to remove education and escort activities from households where people can work from home and are not care constrained.

Joint probabilities

In the second degree of complication, we can give the policies joint probabilities that depend on different attributes that a household, person or activity may posses.

Joint probability of belonging in the vulnerable group based on gender and age of an individual.

This is useful if we want personal attributes affecting the individual or household being selected. For example, if we have a joint probability giving likelihood of infection, we can let that drive which household enters quarantine.

In light of this, we can update our summary table in the following way

Chaining probabilities

In the third, and last, degree of complication we can give policies multiple independent probabilities. The final probability of a household/person/activity being chosen is a product of probabilities at that respective level. For example, if we chain a joint probability giving us a likelihood for a person being vulnerable and a probability for removal of individual health activities, then PAM will choose a household using the likelihood of the event that the household is chosen based on vulnerability and the event of the household being chosen based on having individual health activities

Conclusions

We have applied a rules-based, probabilistic approach to modifying agent activities. There are several factors that might explain why a person’s activity plan might be different than it was pre-COVID-19. These factors could be related to household conditions, individual conditions, or activity conditions. Breaking down the problem in these different levels allows the flexibility to test what if scenarios, as policies are likely to change over the next few months.

If you’re interested in using PAM or would like to contribute to the project, you can find the code on github. There, you will also find example notebooks which present the details of how to define and apply these policies.

--

--

Kasia Kozlowska
Arup’s City Modelling Lab

Software Engineer in the City Modelling Lab in Arup, London.