Skip to content
Sahand Hariri edited this page Apr 22, 2015 · 2 revisions

An agent based simulation of the SIR model.

This is a simulation done in C++ for studying the spread of an infectious disease through a community. Visualization of the data is done using MATLAB. The result is to be compared to the ODE model of the SIR system. The ultimate goal is to compute the eigenvalues of the system using the agent based model only. Once this is done, we can add more complexity to the system that cannot be captured by the ODE model, and try and study its eigenvalues.

The ODE

The original ODE model is nonlinear system with three independent variables.

  • S, Population of susceptible people.
  • I, Population of infected people.
  • R, Population of recovered people.

The AB Simulation

Code design

The following is the list of C++ classes that are used to implement the simulation.

Classes:
  • Domain: This class basically defines the "city" or the domain in which the population lives. It has a name and a unique ID.

  • Location: This class represents locations such as homes, schools work places or cemetery. For each instance, there is a unique ID, name, and a list of occupants at any given time.

  • Disease

  • Person

  • Architect

  • Storage

Domain:

This class basically defines the "city" or the domain in which the population lives. It has a name and a unique ID.

Location:

This class represents locations such as homes, schools work places or cemetery. For each instance, there is a unique ID, name, and a list of occupants at any given time.

Disease:

Class for creating a disease. It specifies the name of the disease, average incubation, infection and recovery periods.

Person:

Use to instantiate each person. Important members are name, ID, state, location, coordinates, time.

Architect:

Manages time. Marches the simulation forward and calls the update function which in turn calls the Move and UpdateDisease functions for each person.

Storage:

Used to tally and store data.

Visualization

Data visualization is done using MATLAB. A class call Visualization is written to produce both time series plots and video of time laps the population moving through space and contracting the disease.

Results

Population Plots

  1. The following shows population plots with the following parameters:
  • 2000 people.

  • Incubation Period: N(24,5)

  • Recovery Period: N(24,5)

  • Fatality time: N(30,5) SPIRD

  • Simulation Video 1

The following shows population plots with the following parameters:

  • 2000 people.

  • Incubation Period: N(24,5)

  • Recovery Period: N(30,5)

  • Fatality time: N(30,5) SPIRD

  • Simulation Video 2

The following shows population plots with the following parameters:

  • 2000 people.

  • Incubation Period: N(30,5)

  • Recovery Period: N(24,5)

  • Fatality time: N(30,5) SPIRD

  • Simulation Video 3