Listen on these platforms
If the pandemic has taught us anything, it's that epidemiology is incredibly complex: the millions of edge cases, what-ifs, and counterfactuals make modelling exceptionally difficult. One way of tackling this complexity is through agent-based modelling.
In this episode, Rebecca Parsons and Prem Chandrasekaran are joined by Thoughtworks colleague Jayanta Kshirsagar and Gautam Menom, professor of physics and biology at Ashoka University. They discuss how Thoughtworks has been helping researchers in India using agent-based modelling with two custom-built tools: EpiRust and BharatSim.
Rebecca Parsons: Hello, everybody. Welcome to the Thoughtworks Technology Podcast. I'm Rebecca Parsons, one of your recurring co-hosts, the chief technology officer for Thoughtworks. I'm joined by our co-host, Prem.
Prem Chandrasekaran: Hello, everyone. My name is Prem, as Rebecca said. I play the role of Tech Director. I'm one of the newer recurring hosts on this podcast.
Rebecca: We are joined by two folks. Jayanta, would you introduce yourself first, please?
Jayanta Kshirsagar: Yes. Hi, Rebecca. Jayanta here. I have been part of Engineering for Research team for the last two and a half years. Mostly working with agent-based simulation models.
Rebecca: Gautam, welcome.
Gautam Menon: Hi, Rebecca and Prem. My name is Gautam Menon. I'm a professor of physics and biology at Ashoka University in India. I've been interested in epidemiological modeling for some years, and have recently partnered with Thoughtworks with EFR.
Rebecca: Let's start with why you're here. We've got two different applications to talk about, but they are heavily related to each other. Let's start with EpiRust. Can you tell me what EpiRust is, and what it does, and why it's named EpiRust?
Jayanta: Sure, Rebecca. EpiRust is an agent-based simulation model, which is specifically designed keeping epidemiology as a domain in mind. As the name itself suggests, it has two parts, Epi and Rust. Epi stands for the epidemiology and the simulation tool has been implemented using Rust language. That is why the name is EpiRust. It is a minimalist model of a city, or it can model multiple cities together, where we can analyze the spread of a disease and understand various different interventions and impact of these interventions on the spread of the disease.
Prem: How did this idea come about?
Jayanta: This idea came a few months before COVID itself started. As part of the Engineering for Research team, we have always been fascinated with complex problems in the domain of complex systems. To study complex systems, agent-based simulation models is one way. While discussing these, we felt one of the biggest issues is epidemics. Specifically, if we talk about many countries in the world, there's this epidemic burden. In the case of India, even that burden is there, and how can we study these epidemics with specifically using agent-based models?
That is how we started. Somewhere around when COVID-19 itself started, we thought of, instead of modeling any disease, we started, why not to model COVID-19 itself?
Prem: Got it. Excellent. Now, who is this primarily targeted towards? Is it an epidemiologist? Is it end-users like patients, doctors? Who uses this?
Jayanta: Specifically, EpiRust is targeted towards researchers, scientists, and policymakers as well. As we have been discussing about epidemics, which are complex in nature, to simulate an epidemic, one has to have a good understanding of what are different things related to an epidemic. If we talk about, say, COVID-19 specifically, once a person catches an infection, how long will the person be infected? We need someone from the domain to understand these kinds of intricacies. Once the person knows these details, they can learn a simulation and understand the spread of disease.
It is also important for policymakers to make use of such tools so that they can understand, say, the impact of lockdown. If a city is placed under lockdown for 30 days, instead if it is placed for 15 days, what it means, what will be the impact on the spread of disease? Such questions can be answered using such epidemiological simulation models.
Rebecca: Then the second part of this, BharatSim, what is BharatSim, and how does it relate to EpiRust? How did it come about?
Gautam: BharatSim started really as a way of thinking about how to apply agent-based models to the Indian population. Agent-based models have been known, especially in disease for a while, but there wasn't any work that looked at specifically a low and middle-income country like India, to try to accommodate the complexities of India. The extreme levels of social disparity, economic disparity. The complexity of Indian cities, the complexities of social interactions.
The idea was to try and be somewhat specific in the way we constructed that model to make it general enough to look at a bunch of different diseases and to embed in it, the levels of socioeconomic backgrounds, et cetera, that might be relevant to the understanding of the social determinants of disease. I had been thinking about agent-based models in the Indian context for a while, and then serendipitously, I happened to meet people from EFR in Thoughtworks. In particular, Harshal Hayatnagarkar. We began to discuss work that had already been done at the Thoughtworks end with EpiRust, and what I wanted to do with this very large scale conception of what might be useful in the Indian context.
That's how the discussion started, and of course, it took on a life of its own, and BharatSim now is actually fairly different from the original conception of EpiRust.
Rebecca: In what ways are they different? It sounds like the general problem is similar, but is it the specialization for the Indian market that distinguishes it, or are there other distinguishing characteristics?
Gautam: There's certainly that. The thing is that BharatSim relies on a bunch of different components that come in together. The first component is something called a synthetic population, which is a way of describing, in principle, every member of a population of a large Indian city like Bombay, or Delhi, or something. So-and-so is 18 years old, goes to college, is about 5'11 tall, et cetera, et cetera, is male, this is their home address, this is their work address. All of this is made up. It's synthetic, but it's made up in such a way as to reproduce the statistical properties of the population as well as we know them.
That's a very important part of BharatSim, of getting that part of it right. That's where computer scientists outside of Thoughtworks, the group of people I work with at my university, came to construct that population. Now, the BharatSim takes in that input in more classic, agent-based model ways, and then runs that. It asks, how does disease propagate in a population that is constructed in that manner, where you know where people are spread out in the city that represents the spatial distribution of population within the city? Then you can ask whether COVID, whether TB, et cetera, how does disease spread within this, which is essentially what BharatSim does.
Jayanta: That was from a domain context as well. Even at technical implementation levels, these two are different. EpiRust is specific to epidemiology. It has been written with scale in mind. With EpiRust, we can simulate a population of 100 million plus on the go, and it is very, very fast. Whereas, BharatSim shines specifically in the language of model specification. EpiRust is more of a tool, but BharatSim is a framework. BharatSim has its own domain-specific language, which helps researchers to build their own model. It may not be epidemiology, but if someone wants to create a model which has epidemiology and impact of, say, disease on the economy of the society, they can even write that using BharatSim.
In that way, BharatSim is more open, it's a framework as compared against EpiRust.
Prem: You mentioned that you conceived EpiRust and BharatSim as part of this work that you're doing. Now, were there any solutions that are already there, and why was the need for you to build something from scratch?
Jayanta: Yes, definitely. When we started our journey, we started with NetLogo. NetLogo is time-proven. It has been around for quite some years now. It has a good UI as well, but the biggest problem we faced with NetLogo is about scaling. We as well tried GAMA Platform, which is a JVM-based platform, specifically used for agent-based modeling. Even with GAMA Platform, we struggled a lot when we tried to scale beyond 10,000 agents. Our goal has always been to simulate at a large scale because we see, since agent-based models, the key factor, the most important part is emergence.
That emergence will be better justified if the scale is close to reality. When we are talking about cities like Pune and Mumbai, Mumbai has a population which is close to 10 million plus people, roughly 12 million. We found it difficult to model such scenarios within GAMA Platform or NetLogo. That is why we thought we needed our own tool, our own framework for modeling such high-scale, large-scale models.
Prem: One more related question. We have mentioned agent-based models a few times. For our listeners, what exactly do we mean by an agent-based model?
Gautam: When we talk about agent-based models, what we mean to say is that we want to describe every unit of a population as an individual. These models are also called individual-based models, which means that you should just think of them as real people converted to something that you can simulate on a computer. All of the complexities of the family sizes, the genders, and where people work, et cetera, are all going to be included in the specification of an agent.
This is the most granular way of approaching how diseases spread. There are other approaches to diseases that broaden these categories out, and just look at the numbers of people who are susceptible, the numbers of people are infected, but don't break these up into further subcategories. You cannot get more granular than an agent-based simulation, and that's what makes it a) powerful, and b) numerically and computationally complex.
Rebecca: You had mentioned earlier, Jayanta, that one of the users for this would be policymakers. Gautam, can you explain a little bit about how a policy maker might make use of either BharatSim or EpiRust?
Gautam: Yes, I can do that. Usually, the problem conflicting a policymaker is what's the sort of intervention to use and how to combine interventions to make them better, and more useful in controlling the spread of the disease? For example, should you have a lockdown? Should you combine a lockdown with mask-wearing? What happens if 5% or 3% of people who are supposed to be locked down violate that lockdown? How does it affect the spread of the disease further? How does this affect economics? How does the fact that some people are just economically constrained to have to go out in the middle of a general lockdown into work?
What about people who are essential services people? What happens to them? Should you close schools? Should you not close schools? Should you close offices? Should you close offices in some parts of the city, but not in other parts? What should you do with public transportation? These are difficult questions to answer, in general, and that's where models can really help because they can help you explore counterfactuals. They can help you explore many different types of intervention, and all of this can be done with BharatSim.
Prem: This is really interesting. Are there other real-world uses that you have made with BharatSim and EpiRust?
Gautam: With BharatSim, we have been advising some state governments in India about school reopening, which has been a big issue. Indian schools have been shut for around two years, and they've slowly begun to open up around the beginning of this year. Now, the question is in, when is it safe to open a school, given the children under 18 in India have not been vaccinated? In fact, vaccinations for them started only in the very early part of this year. Then the question was, is there a difference in the policies that different states should adopt?
What helps you decide? How can you look at schools embedded in communities where there's already a fair background of vaccination, a fair background of people who have already caught the disease? Then you can ask that if you've not vaccinated children, but you're sending them to school, where they could contact teachers and other school staff who may be carrying the disease, what impact will that have on the community? This again is a granular question. You can put, children go to the classroom, there's a certain level of mixing. There's not too much of mixing.
You can say if children wear masks or don't wear masks, what happens? All of these questions you can now do very fast because these numbers, if you just looked at a school in the community, you're simulating 20,000 people or 30,000 people, you're not simulating in the millions. That's the question in which you can really explore the statistics of the situation, many different counterfactual scenarios, and then come up with advice that will be useful to a policymaker regarding this fundamental question.
Prem: It's fair to say that this is an invaluable aid for policymakers when they're making those maybe not-so-popular decisions?
Gautam: Absolutely, at least because then they can be backed up by the fact that, look, we have explored these different ways of intervening, and this seems to be the best way at this point that we know of. In addition, if we did this, this, and this, then we could imagine having a stronger impact on suppressing the epidemic.
Rebecca: Let's get back to some of the technical foundations here. For EpiRust, why did you pick Rust? I know you mentioned when you explored some of the existing frameworks we were having performance issues. Was it strictly driven by performance or were there other factors?
Jayanta: A key factor definitely was performance. The major reason for choosing Rust for writing EpiRust, is twofold. Rust is closer to metal. The performance benchmarks, if we compare, they are pretty close to C and C++ languages. We knew we wanted to simulate at a million scale, possibly 100 plus millions, and given these constraints, we decided we'll try and go as close to metal as possible. The second thing is Rust has concurrency in its DNA. The way that it says it, it has fearless concurrency, and we definitely knew that we want to build a tool which can be used with a lower population.
Maybe a researcher who is simulating it for a small town on a laptop with 10,000 population, it should work there. At the same time, if we want to run it for multiple cities, like 20 cities in India, which has a combined population close to, say, 50 million, it should as well be able to run there. We wanted something which can be easily made serial parallel version, and as well as a distributed version. That point, Rust did shine. C++ could have been one option, but as we know, with C++ plus, memory management is the developer's overhead.
The developer needs to make sure that whichever memories are allocated has to be reallocated as well. In case of Rust, that overhead is taken care of by Rust itself, which reduces many of the exceptions, which comes with memory management, like segmentation faults. All of these are converted into compile time measures, which expedites the development cycle.
Rebecca: Also, the computational core underlying BharatSim, is that also in Rust?
Jayanta: No, BharatSim is written in Scala. We did think of Rust, but one key factor, which changed with BharatSim is BharatSim had to be performant, had to be scalable, but at the same time it was a framework. The users who will be interacting with BharatSim will be writing their own model. BharatSim should have DSL, which should be easily understandable by developers and by researchers. These researchers may not be from a computer science background. We wanted a layer of domain-specific language, which can be easily understandable for the people from various different disciplines and domains.
That factor, with that in mind, we decided to go ahead with Scala instead of Rust.
Rebecca: From the perspective of a researcher, then, were we successful at creating a language that, Gautam, allows you to express the questions that you want to express? From what you talked about in terms of economic impacts and such, that feels like it's a pretty broad range of questions you would want to be asking. What can you tell me about that DSL?
Gautam: I think that went very well. It helped with the fact that both Thoughtworks and us had some experience in other alternative ways of doing agent-based models. For example, the GAMA platform and the Covasim, which is another. We knew what we wanted to do. We knew what we wanted to do that was different from what other people had done. We had some idea, the complexities that we wanted to accommodate that could not be accommodated in other ways of doing this. Together with working together with Thoughtworks was a real fun process in the sense of being able to interact, telling them what we wanted.
They're coming back to say that, "Look, we believe we can do this," or, "This may be a little too hard." They very rarely said, "This may be a little too hard." I think they really helped a lot, and this discussion was extremely fruitful at both ends. We really managed to create with BharatSim something that was, I think, unusual and unique.
Prem: Are there other uses that you see with BharatSim and EpiRust working together?
Gautam: With BharatSim, certainly, I think the new frontier really is, for me, the social aspects of something like BharatSim. How do you model societies and societal behavior? In the disease context, what are the socioeconomic determinants of disease? We know this both from the US and from India, that your socioeconomic status determines your propensity to contract COVID-19 in ways that are complicated. They vary across communities, they vary across different parts of the country in delicate ways.
We don't really understand many of these, but with something like BharatSim applied to a US population or any populations we might choose to study, you can try to tease these factors out, and ask, what is it about socioeconomic determinants that predisposes someone to diseases? Predisposes a certain locality, an area, a group to diseases spreading faster there, and other questions about society. Society, economics, the interplay of that with just public health in different context. That's something that has not been explored sufficiently, and with BharatSim, I think we really have a chance to look at that completely afresh and see where that leads us.
Jayanta: Yes, and on the EpiRust specifically, EpiRust has been targeted only towards epidemiology, but what we have been working is, we use different scales. When we started EpiRust, we started with Pune city, which has a population of 3.2 millions. Then we slowly move ahead to Mumbai, which has 12 millions. Right now we are at a stage where we can simulate 100 plus millions. The goal for EpiRust which we have kept is going beyond 100 plus millions, and possibly to a billion scale.
By doing that, we as well want to compare the impact of scale given the specific model and how the outcome changes, I guess which would as well be important for policymakers, if a policy which is prescribed for a small town may or may not be applicable as is for larger cities. That can be one example.
Prem: What you're saying is we're very close to even covering the world population, which is approximately 8 billion at this point in time, so we can do simulations for pretty much people across the globe, or even the entire globe?
Jayanta: Definitely, that's on the agenda. Right now we are at 100 million. Our very first goal is reaching 1 billion, and definitely moving to 8 billion.
Gautam: You have to expand upon that a little bit. You can get to larger numbers, but it depends upon the detail at which you want to describe your population. There are 100 or 200 different attributes that you want to include, then you have to trade that off against the sort of numbers that you can submit. Some questions are perfectly well answered with 20,000, or 200,000, or 2 million, et cetera. Those questions should be answered at that level, but really to show our numerical chops, our computational chops, maybe it would be nice to try something at the level of the whole of the population of India at 1.4 billion, or the population of the world.
Prem: I had a question about that. How are you simulating that data, or where are you getting your data from?
Gautam: That goes into the description of the synthetic population. For that, that's a different set of techniques. These are mainly AI/ML techniques applied to information that you get from surveys. There is public information available from surveys that tell you about demographics. Then you have to figure out a way to extend that across the whole population. You have state-specific information, which you can then apply to each state, and then you can try and bootstrap that into areas where you don't have enough information, but you do have some level of information, partial information.
That is a challenge. Getting a good synthetic population is a challenge anywhere. We hope to incrementally make progress with that, and we have better and better synthetic population. Already, by comparing the average properties of our synthetic population with what we know from large-scale surveys and census information, we know that we're not doing too badly, but that still is a frontier, that's a whole different area of improvement that we'd like to spend more time on in the future.
Prem: Where do you see going from here, are there any specific next steps you have in mind?
Gautam: With BharatSim we'd like to expand the range of diseases that we look at. We thought initially of BharatSim's application as really for COVID-19, and we were funded initially to think about COVID-19 in India, with a special attempt to try and integrate socio-economic determinants into that description, but there are many other types of diseases. Neglected tropical diseases, for example, or diseases that are transmitted by vectors. Malaria being one, dengue being another, chikungunya being a third. All of which afflict countries like India, as well as countries that are in the equatorial belt.
Extending these methods to those problems will be very important for the country, very important source of information for policymakers. That's certainly a direction, which I'd like to take BharatSim in the future.
Prem: And EpiRust?
Jayanta: Yes, and on the EpiRust front, we have been trying to do various different analysis methods on the outcome of EpiRust simulation. One such thing is sensitivity analysis. If there are dozens of input parameters, and which one matters the most, deciding the output. At the same time, stability analysis, so, how stable is my solution? We have been trying to understand various such analysis methods and understand simulations better.
Rebecca: In terms of EpiRust, in particular, you've mentioned that it is specifically designed for questions around epidemiology, and yet, simply being able to do agent-based simulation in that 100 million agent range, how applicable do you think your strategies for being able to scale to that kind of population, how much is that tied to your implementation for epidemiology specifically?
Jayanta: With EpiRust, when we say it's 100 million plus, what we are trying is to model different cities. Imagine if we talk about Mumbai against Pune, Mumbai is very densely populated, whereas Pune is not as dense as Mumbai. Ideally, the data of these two cities is different, and when we run EpiRust from various such different cities, the outcome of these cities differ from each other. At the same time, when COVID started in India, we saw, in the first wave of COVID, many people migrated from Mumbai to their own hometowns, the different cities.
Even such migrations have a huge impact on the spread of disease. Earlier, in few places of India, the COVID may not have been there. When many such people at such scale moved from one city to another, it could, again, trigger waves at these different locations. When we simulate 100 plus millions of people with so many different cities, we can study such phenomena, that such given time, X number of people leave a specific city, and then next specific time, they enter these different cities, so few of them might already be infected. Then the interactions in the hometowns, how it causes spread in these different areas.
Rebecca: I suspect those socio-economic factors that you were mentioning earlier, Gautam, play into the realities of those migrations. Some people are more able to migrate. That's one of the things that we've seen in the US, is many people are now living in places because they could afford to get out of a place like New York City.
Gautam: Yes, that, again, is something that we need to worry about because, in India, you do have these large-scale migrations. People migrate from villages in order to work in cities. At the time the big lockdown started in India, we had people moving back to the cities, being unable to do that because they were under a lockdown situation. Then being released across a period of a few months, going back. Then potentially, as Jayanta said, transferring diseases to places that hadn't seen it before.
All of this complexity, one needs to think about the problem at the level of individuals, which really is what EpiRust and BharatSim are both about, and which is my agent-based models are important because they can accommodate this level of complexity.
Rebecca: If you were talking to an aspiring young scientist, are there recommendations you would have to them on how they might get involved in some of this work? Clearly, being able to study diseases like malaria, and dengue as you mentioned, there's got to be a degree of satisfaction, but what does it take to really get involved in such studies?
Gautam: We're seeing a lot of interest from — I work at primarily undergraduate university, and there's a lot of interest from students, especially post-COVID, in coming to terms with epidemiology, understanding it, seeing they can contribute in some way. I think everywhere people have become more aware of the importance of public health, and especially if you're academically inclined, the need to look at academic and scientific tools in different ways to see if they can be of help, or if they can be of use at all.
I think one interest with BharatSim is the fact that it combines both the sciences and the humanities, the social sciences together in an interesting way, and that very few subjects really can do that. Public health can. Here's an approach, a numerical and computational approach to public health that ties all these different elements together in interesting ways. I think that catches people's attention, and there's certainly been a lot of interest in BharatSim for that reason.
Rebecca: Are you looking at broader collaborations in further developing BharatSim?
Gautam: We're always looking for collaboration. There are many people of interest who are in touch with us. Certainly, one interest would be to take BharatSim outside India to look at, for example, different countries across the world. Malaysia, countries in South Asia and Southeast Asia, where all of us face similar problems, you need different synthetic populations. You need to develop a synthetic population for those countries, and then answer questions. Then the second thing is can we use BharatSim in areas where it hasn't been used before?
For example, in understanding vaccine trials, or modeling the effects of vaccines, multiple strains of, for example, Omicron as the world is seeing now? Whenever you have an infectious disease, it changes dynamically, like COVID-19, these questions will come up, and they need to be answered in real-time. BharatSim offers you a way of doing something like that, of really putting in the complexity as and when you understand it and then asking what are the impacts of it in the future.
Rebecca: Jayanta, the same question, but for a computer scientist who wants to get into this kind of work, both the large-scale simulation and the computational science nature of this. I've done, in my career, a fair amount of work in computational medicine, in computational biology. To me, that interdisciplinary aspect is of interest, but how would you counsel a brand new Thoughtworker on how to get involved in work like this? What kind of tools do they need to bring to such work?
Jayanta: Yes, definitely. While building such large-scale simulation platforms and frameworks, I think understanding of data structures and algorithms is pretty fundamental. At the same time, understanding high-performance computing setups, some bits, levels of DevOps, and as well as how we use different languages such as C++, Rust, in this case, is pretty important. We are very happy to have collaborations, and for the same reason, EpiRust is already open source.
Rebecca: How long did it take you to learn how to speak each other's languages? I distinctly remember a conversation with a molecular biologist, and he was using the word, vector, that you used earlier, Gautam. I said, "I know two definitions of vector, and I don't think he means either one of those."
Gautam: I think it did help, certainly, from our site, for example, that Harshal had some experience, that already the EpiRust people did have some initial grounding in understanding the basics of infectious disease modeling. We had on our site, computer scientists like my colleague, Debayan Gupta, who was able to understand and speak the language that Thoughtworks was comfortable in. I think both of us had to move a certain distance from our comfort zones, but I think Thoughtworks did try to make it easy for us. We've tried to be as clear and as jargon-free as possible in our interactions with them. We both worked hard at it, and I think it worked out finally.
Rebecca: Thank you, Gautam and Jayanta, for joining us today for this fascinating exploration of public health policy, epidemiology, and large-scale agent-based simulation. Thank you very much for taking the time to talk to us. Thank you, Prem.
Jayanta: Thanks, Rebecca. Thanks, Prem.
Gautam: Thank you, Rebecca and Prem.
[END OF AUDIO]