RubyKaigi 2015

Prepare yourself against Zombie epidemic

http://rubykaigi.org/2015/presentations/toch

The news is everywhere: some weird disease makes the dead walking. We do not know yet if it is highly contagious. What should we do? What we do everyday: writing code.

This couldn't be a better moment to use an agent based model — a technique that simulates interactions between agents in a environment to understand their effects as a whole. For such, we'll visit its minimal Ruby implementation, address some common design, simulate the Zombie epidemic, visualize it, and test different survival strategies to hopefully find the best one.

We can code, we'll be prepared ... or not.

RubyKaigi 2015

00:00:00.000 Hi, I'm Christophe, and I'm from Belgium, a tiny country in Europe. It's so small that you can spot it from space. In fact, astronauts use Belgium as a reference point while in orbit. So if you see a lot of light over there, that's Belgium. I enjoy beer, and I heard that you all do too. I also appreciate homemade waffles and chocolate. In fact, I have a gift for you today: I brought some Belgian chocolate! Feel free to come say hello during the break and grab a piece. I co-founded the Ruby Belgium Association, and we organize various events, such as Ruby rallies and gatherings. The next event will be a Ruby dev room at FOSDEM, which is one of the biggest open source community events in Europe. The Ruby dev room is a mini-conference that focuses on Ruby implementations. If you're in Europe, please drop by and say hello!
00:01:05.400 I also work on Code Review, which is a service for Ruby on Rails, and I do some freelance work primarily focused on simulations of diseases. I would like to share my experiences with you today. It all started when there were some cases reported in a local newspaper, leading to speculation about a rabies-like disease causing people to bite one another. At first, the news seemed like sensationalist hype, but two weeks later it was clear that it was a serious outbreak that was highly contagious. The army had to take action, applying curfews and quarantines, while some zones were already shut down. The World Health Organization and various experts have joined forces to assist the army in handling the situation. And here you are, just a software developer trying to navigate this chaos. So, what can you do to survive? In moments like these, I believe that writing code can actually help you prepare against a zombie epidemic!
00:02:32.490 Today, I will present one of the techniques we use to simulate the complex dynamics and propagation of diseases. This technique is called agent-based modeling, which is particularly useful when you want to gain insights at the individual level. Agent-based modeling may seem specialized, but it can be applied to many scenarios. For example, we can simulate the propagation of the flu around the world through airlines, or understand road traffic better and find the best configurations for traffic lights to reduce congestion. The image I displayed here illustrates the electrical grid in Europe, and agent-based modeling can also be used to prevent electrical outages or study the robustness of the Internet's backbone.
00:03:26.520 The key aspect of agent-based modeling is that it focuses on understanding dynamic interactions among individuals, which can indeed lead to a variety of outcomes based on their behaviors. For our model, we need agents, which, in this case, will be humans. We also need an environment for these agents to interact within, and rules that dictate how they behave in relation to each other and their surroundings.
00:04:02.730 To create a zombie epidemic simulation, we must consider that zombies need to make physical contact with humans to infect them. Their movement capabilities are crucial, and we will use a simple 2D map to represent the agents' physical presence. This model will help us establish rules for proximity and neighborhoods. Each point on our grid simulates a location that consists of neighborhoods where agents can encounter each other. We will define the movements and interactions of agents, such as moving, staying in place, or attacking. An agent can move to different points on this grid, which represents their actions.
00:04:51.180 As we design our agents, we must also define their states. Each agent will have certain properties, including its age, position, and health state. An agent must perceive its surroundings, checking if there are other agents nearby and determining if any are zombies. This perception will help the agent decide on their action—be it moving, staying put, or attacking another agent. The interactions could be quite simple initially, but they reveal complex dynamics in the simulation.
00:05:59.690 So let's dive into a quick visual demonstration. We have a simple map that displays agents in different states, represented by their colors: green for susceptible agents, yellow for infected ones, and red for zombies. As these agents move around, you’ll see their states change based on their interactions. For example, when a susceptible agent comes into close contact with a zombie, it may become infected. Additionally, as agents age, their health states change, which further impacts their vulnerability to infection. The simulation results in a dynamic that shows how interactions among agents evolve over time. We can also increase the fight capabilities of susceptible agents, allowing them to resist or eliminate zombies, creating a more hopeful survival scenario.
00:08:27.810 It's crucial to validate and calibrate these models, especially since interactions among agents can become complex. During validation testing, I simulate different situations to check if the output aligns with expectations. For instance, if I run a simulation where all agents are susceptible, they should remain uninfected over time. By plotting the proportions of susceptible agents over time, I can confirm that the population consistently remains stable if there are no infections occurring.
00:10:07.040 To facilitate calibration, I sometimes lack some input data, so I might need to simulate various scenarios to find the right combination of parameters that yield the correct outputs. For instance, in preparing for a zombie solution, if I know certain infection rates but lack incubation times, I can run multiple simulations, adjusting just that parameter until I find a match to the expected output.
00:11:26.420 Let’s now take a look at a live demonstration. The initial state machine defines different agents and states, such as susceptible, infected, zombie, and dead. As I adjust the rules in real time, you will see how agents interact with each other. When I enable the transition rule that allows susceptible agents to become infected, it prompts the yellow dots (representing infected agents) to appear on the grid. When I adjust additional transitions, like how infected agents turn into zombies after a set period, you'll notice how the agent states dynamically shift in response. The simulation vividly demonstrates how quickly a simple model can become a complex interactive system.
00:14:03.480 As I conclude my talk, I want to emphasize the potential applications of agent-based modeling not only for dealing with fictional zombie outbreaks but also for real-life diseases, helping inform strategies to combat them. Ultimately, we are looking to prepare ourselves for any future challenges, including a potential zombie epidemic! You can find the source code for my simulations on GitHub, and please feel free to reach out to me on Twitter for any discussions or questions. And of course, don’t forget to grab a piece of Belgian chocolate before you leave! Thank you very much for your attention!