00:00:24.490
Hello everyone, I'm Christophe. You can find me on Twitter or GitHub, up on the left. I'm from Belgium, and I'm really happy to be here. We've had some great sessions!
00:00:32.800
I'm a board member of Ruby Belgium and I help organize their events, including conferences. If you're a Ruby enthusiast, you should definitely attend! I'm also the founder of Poor Review, an automated code review service for Rails applications. Additionally, I'm a freelancer developing disease simulation models for various companies.
00:00:53.870
Today, I'd like to discuss that experience in a fun way, using the theme of zombies. Initially, we heard about some unusual cases of a disease in certain villages. According to local newspapers, it resembled rabies, where infected individuals bit others. It seemed like a sensational story.
00:01:13.880
However, two weeks later, the situation escalated. The disease turned out to be serious, deadly, and highly contagious. The army took action by establishing curfews in affected zones, and the World Health Organization dispatched experts to assist. Under such dire circumstances, your life is at risk, and survival becomes a priority.
00:02:24.000
But what can you do as a software developer? You can write code! The question is, can you survive with that? Perhaps you can! I believe you can prepare for a potential zombie epidemic using programming.
00:02:39.080
There are several techniques for disease simulation, and I want to present the agent-based model because it is particularly useful for understanding interactions at the individual level. Here, we need to comprehend how interactions play out between zombies and healthy individuals.
00:03:02.890
While some may think this model is specific to disease propagation, it's not limited. Agent-based models can simulate other situations like outbreaks through flight routes. They can also be applied to traffic analysis to determine the best configurations to alleviate congestion.
00:03:40.440
Additionally, they're used for simulating electrical consumption to understand impacts on the power grid, predicting behaviors in groups, especially in stock markets or during crises, and analyzing social networks to understand trust dynamics.
00:04:12.500
As you can see, this approach is suitable for simulating dynamics resulting from interactions among agents in a specific environment. To simulate the spread of zombies, we must define what an agent is, the environment they inhabit, and the rules governing their interactions.
00:05:06.560
Now let's begin with the environment. Since the zombie apocalypse is quite physical, we need to establish a model that captures that effectively. We start with a simple two-dimensional map, incorporating a notion of proximity.
00:05:32.840
On this map, we define neighborhoods. When two agents are located close to each other, we consider them neighbors, which allows for potential contact between them. Next, we need to define our agents and their capabilities. An agent's state is determined by factors like age, position, and health.
00:06:04.880
During the simulation, agents can perform various actions. They can perceive their surroundings, which helps them to identify if there are any neighbors in their vicinity. Possible actions include staying still, walking, or fighting. If they choose to walk, they will move in a specified direction; staying still does nothing.
00:06:43.099
Fighting occurs when the agent is capable of defending itself, or in the case of a zombie, attacking others. Agents may age throughout the simulation, contributing to the dynamic elements of the environment. This entire simulation revolves around calculating the next state of every agent based on both their individual states and the overall environment.
00:07:32.130
To accomplish this, we utilize what's known as asynchronous updates, meaning we calculate all future states for all agents based on their previous states before updating any of them. Now that we've outlined the environment and the agents, we need to define the health states.
00:08:32.430
For example, a susceptible health state indicates that an agent is unprotected against a disease and could become infected. For each health state, we establish the possible actions available to the agent. In the susceptible state, an agent can walk, stay still, or fight.
00:09:07.800
Conversely, in the case of a zombie, they can only fight and bite others. Additionally, the model defines conditions for transitioning from one state to another. For instance, we can define a condition where an agent goes from susceptible to infected state, with the condition set to always true.
00:09:50.320
This means that this transition is inevitable. By considering different potential transitions between states, we can derive new states for our agents. All these rules help us establish what is known as a state transition machine, which is crucial for managing and predicting transitions between various states.
00:10:57.330
In this model, there are four essential states: susceptible, infected, zombie, and dead. Susceptible agents can contract the disease if bitten by a zombie, leading to an infection. The agent then incubates the virus without yet becoming a zombie, until a defined incubation period has passed.
00:11:36.360
Once that period is over, the agent becomes a zombie. If a susceptible infected agent successfully fights back against a zombie, it may revert to a healthy state.
00:12:05.290
Next, we need to define default initial states for all agents. When we run the simulation, we essentially loop through this process. For example, we could simulate the outbreak over 100 days. Initially, we create all the agents and place them on the map.
00:12:30.420
Then, at each step, we allow each agent to act. Following their actions, we calculate the new states and commit these changes accordingly. Dead agents are removed from the map.
00:13:19.490
Here are two examples of the simulation. The colors represent different states: green for susceptible (healthy) agents, yellow for infected agents, red for zombies, and black for dead agents. On the left, the future seems bleak, while on the right, the healthy agents effectively fight back.
00:13:45.140
A few remarks: once your simulator is implemented, you must validate and calibrate it. Validation involves integration tests to ensure your simulator behaves as expected in various scenarios.
00:14:11.410
For example, if there are only susceptible agents, they should remain unaffected indefinitely. You might also compare your results with real data to confirm accuracy.
00:14:32.360
Calibration involves adjusting parameters until the output matches expected results. This process ensures that your model can accurately predict disease propagation.
00:15:57.740
Let me quickly show you the simulator. On the left, you see the simulation. The agents' colors correspond to their states, but I've disabled some transitions for demonstration purposes.
00:16:34.690
In this example, if a susceptible agent is adjacent to a zombie, they may become infected. Now, I will run the simulation. Assuming that agents are good at fighting back, the healthy agents over time will eliminate the zombies.
00:17:23.630
Even with a simple implementation, you can model complex behaviors. This simulation is inspired by actual work, showing that we can predict epidemic outcomes.
00:17:43.680
You can also explore strategies to combat the disease, such as quarantines and vaccinations. The code is available on GitHub. If you have any questions or want to discuss any topics after the session, feel free to reach out. Thank you!