Fully Agent Based Modellings of Epidemic Spread Using Anylogic
Fully Agent Based Modellings of Epidemic Spread Using Anylogic
Fully Agent Based Modellings of Epidemic Spread Using Anylogic
Abstract
The question how to model the spread of epidemics has been approached countless times. The
number of different methods used on this problem is not too small either. Ordinary
differential equations (ODE) and Partial differential equations (PDE) have dominated this
field for several decades, if not centuries. In the second half of the last century two alternative
techniques appeared on the stage, namely cellular automata (CA) and agent based (AB)
models, also called multi agent systems (MAS). The difference between the approach with
differential equations and the latter two methods is big. CA and MAS are so called “bottom-
up” approaches, focusing on the smallest unit of the system – a cell or agent, whereas ODEs
try to model the system via causal connections on the macroscopic
level. Setting up a SIR-type model using the AB approach one can
take advantage of state charts to control the behavior of agents.
Using AnyLogic as implementation platform agents and
especially state charts can be programmed very conveniently.
Especially modifications and/or extensions of the final model can
be handled in an elegant way. The right figure does show all
necessary adjustments to expand the SIR- to a SIRS-type
epidemic (additional state transition highlighted). The results
obtained by simulation with such an MAS are comparable to those
of the ODE- and CA-approach, although AB modeling offers a
higher degree of freedom and thus more possibilities of
adjustment.
1 Introduction
1.1 History of Agent Based Systems (ABS)
The first known attempts to analyze patterns of • The definition of autonomy needs to be handled
epidemic outbreaks date back to Hippocrates [1]. Over with care, as we are talking about a pre-
the centuries the understanding of the biological and programmed computer system. Thus it is
chemical processes leading to diseases became better satisfactory if the agent can reach decisions without
and better, the mathematical knowledge grew larger (human) interaction.
and with it the possibilities and models for such
attempts became more and more complex. At the • Flexibility is required in multiple ways. Firstly one
beginning of the 20th century Kermack and demands that the system is operating and acting in
McKendrick published the famous and often cited reasonable time. Secondly the agents are not to be
ODE-system solely reactive but goal-oriented or in the best case
anticipating. And thirdly agents may have the
capability to communicate or interact with other
agents and/or real humans.
In MAS now several of such agents are interacting.
Such multi-agent-systems are characterized by:
for the simulation of a simple SIR-type epidemic,
where S(t) denominates the number of susceptible • agents have a limited point of view (incomplete
individuals at time t, I(t) the number of infected and information and/or problem solving capabilities),
R(t) the number of recovered individuals. The
• the absence of global system control,
variables β and γ represent the infection respectively
the recovery rates. Since then the differential equation • decentralized data and
methods have been refined and improved in various
ways. In the second half of the last century, with the • asynchronous computation of the agents.
rise of computers and increased computing power,
cellular automata (CA) became an interesting field for 2 Modeling
experience. Especially one advantage made them quite
2.1 Simulation Environment – AnyLogic
interesting – the possibility to simulate heterogeneous
populations. In the 1990ies computers finally reached AnyLogic is a programming and simulation
a level making it possible to handle even more environment, mainly aiming at modeling of hybrid
complex structures – ABS, also referred to as multi- systems, based on JAVA. It allows the user to
agent-systems (MAS) were born. These systems allow combine different techniques and approaches such as
for even more flexibility, as the agents may hold differential equations, discrete events and agent based
(many) different characteristics, such as age, or sex. systems. These combination possibilities make it a
very interesting tool for simulation of complex
1.2 Characteristics of MAS systems.
Cellular automata and multi-agent systems are both AnyLogic’s newest version 6.0 is focusing mainly on
classified as “bottom-up” approach. Both methods the agent-based approach and business simulation, but
describe (complex) systems by definition of local allows other methods to be used. A drawback for the
interactions. The interaction of CA is a very limited simulation of exact systems is the lack of a state event
and strict one. Whereas AB-systems lack a clear and finder in the newest version. It is still available in
strict definition, but provide much more flexibility. version 5.5 but was dropped in 6.0 to improve
Numerous varying definitions can be found runtime. On the other hand the performance of and
throughout literature, with one possible definition possibilities for modeling of agent-based systems has
(adapted from [2]) being the following: largely increased. Numerous processes have been
An agent is a computer system situated in an optimized and simplified.
environment, it has the capabilities to flexibly and A clear advantage of AnyLogic is the possibility to
autonomously act in this environment in order to reach use JAVA code at any place of the program and thus
its (predefined) objectives/goals. Which leaves three expand or adopt the model to the programmers needs.
terms that need further specification: Another neat feature of AnyLogic is the possibility to
• Situated in our case means that the agent is immediately create a JAVA applet of a working
interacting with its environment. The agent is model, allowing it to be put on websites or distributed.
capable to receive input from the surrounding In version 5.5 it took quite some time until one
(generally via sensors) and can also manipulate it to became accustomed with the program-layout, version
some extent. 6.0 restructured the GUI, but still requires the user to
get acquainted with it.
The task is to model a SIR-type epidemic, an epidemic As already stated in section 1.2, the basic element of
simplified in several ways. For example we assume a an AB-model is the agent itself. Thus we start by
constant population over the whole simulation, thus no creating an agent. This is done in AnyLogic by
births or deaths may occur. Further there is no creating a new class. The agent is assigned 5 variables,
incubation period or delay time between infection and two real variables for the X- and Y-coordinate of the
infectivity of an agent. agent and another two real variables for the X- and Y-
component of its movement. All four of these
CA are defined via their neighborhood, this means variables are random numbers with an upper limit -
that we need an equivalent to the CA-neighborhood either a given maximum speed or the boundaries of
for our MAS. We are going to solve this by defining a the simulation environment. The fifth variable is, as
field of view for our agents. This field of view is set said before, Boolean and in charge of controlling the
via two parameters: vision-range or -distance and contact status of our agent.
angle of vision (see Fig.1).
The health status of our agent is controlled by a state-
chart which represents the possible states and defines
the state-transitions and actions for these transitions
(see Fig. 2 for the health state chart).
Recovery of the agents is also reached stochastically, Next we need to define the state chart for movement
although with a given minimum for the duration of the and contact of our agent. This is accomplished by the
disease. A recovered agent cannot become infected state chart presented in Fig. 3.
again, thus it is immune to the disease. This is leading
to two possible scenarios:
• The disease infects all agents in our simulation
resulting in a full immunization of our Population.
The infection dies out because of lack of vectors
3 Experiments
3.1 Variation of Movement Speed
First we will take a look on how variation of the
maximum speed affects our model. As implied before,
the speed of the agents is not the same, but assigned
randomly within a certain interval from 0 to Fig. 6 maxSpeed of Agents set to 60
maxSpeed.
Figures 4, 5 and 6 do show the variation of the
maxSpeed from 10 to 30 and 60 units. (The vision
range is kept at 15 during all experiments of this first
set, allowing better comparability with the second set
of experiments).
3.2 Variation of Size of Vision Field This set of experiments presents similar results as the
ones obtained from simulations in the first set. This is
In a next step we will alter the size of the vision field
not further surprising, as both parameter variations are
of the agents. If we take another look at Fig. 1, we can
leading to a higher contact rate between the agents in
easily see that this can be done in two different ways.
the system.
We may either in-/decrease the distance or the angle
of the vision field. In either way we will reach the The infection and recovery rates have not been
same result as the area of the field is in-/decreased and changed through all of these experiments. By
thus the probability that another agent passes trough it. modification and parameterization of all available
The shape of the vision field is of no importance. parameters one can adjust the model to fit the curves
produced by the Kermack and McKendrick ODE-
We choose to modify the vision distance from 5 to 15
system presented in Eq. (1). Although in general the
and 25 units. For better comparability with the first set
infection and recovery rates will not be the same.
of experiments the maxSpeed of the agents is set to 10
throughout this set. Thus Fig. 8 corresponds to Fig. 4 3.3 Expansion of Model – SIRS
of the first set of experiments.
Now we will expand our SIR-type model to simulate a
SIRS-type epidemic, this epidemic pattern is
characterized by the fact that recovered (immunized)
agents do become susceptible again, allowing them to
get infected repeatedly. This changes the whole
behavior of the system, as it adds the possibility, that a
disease does not get instinct but becomes endemic
within the population.
In our case the modification necessary to achieve such
a model behavior is very simple, the implementation
in AnyLogic fast and convenient.
We remember, the state chart “health” (see Fig. 2) of
our agents that controls the health status and now
Fig. 7 Vision range of agents set to 5 return to this state chart to add another transition,
which takes just three clicks, and modifies our state
chart as follows (see Fig. 10).
4 Conclusion
This simulation of a SIR-type epidemic using an
agent-based approach in AnyLogic shows some quite
interesting things. One notices, that the qualitative
outcome of the model corresponds to expected system
behavior known from other modeling techniques, such
as ODE-systems or CA-approaches. Thus using the
agent-based approach appears to be legitimate – at
least in this case.
Further AnyLogic proved to be a sufficient platform
for the modeling of MAS as it provides effective and
helpful tools to the programmer. Especially the
Fig. 15 Duration of immunity set to 40 units of time implementation of state charts and state events is very
convenient. On the other hand it also showed some
In Fig. 14 the curve of the infected population already short comings, especially in terms of data post-
almost reaches the lower bound. If this happened there processing. It does not offer a built in functionality to
would be no more infected individuals within the store the data obtained during simulations. Since
systems meaning that the infection would have died AnyLogic is based on JAVA this can be conquered by
off. This is the case if we further increase the duration a JAVA-based work around, e.g. exporting data to a
of immunity (see Fig. 15). The epidemic dies out and spreadsheet or csv-file during runtime. Although this
after a delay (the duration of immunity) the whole work around needs to be implemented manually.
population becomes susceptible again.
A big advantage of the agent-based approach was
If we compare the epidemic patterns to results shown in section 3.3 when the model was expanded.
obtained using a lattice gas cellular automata (LGCA) Additions or modifications of the model can be
for the modeling of a SIRS-type epidemic, we can see implemented very easily by simply adding the desired
that the qualitative behavior is fairly similar (see Fig. features to the agent.
16).
Although major improvements in terms of runtime
have been achieved from AnyLogic 5.5 to version 6.0
a weakness still remains when simulating huge
systems. But altogether simulation of systems using
MAS appears a convenient and effective method for
certain applications, especially for socio-economic
problems where many aspects and interactions need to
be considered.
5 References
[1] Baylei Norman T. J. The Mathematical Theory of
Infectious Diseases and its Applications. Charles
Griffing & Company LTD, 1975.
[2] Jennings, Sycara, Wooldridge. A Roadmap of
Fig. 16 Simulation of SIRS-type epidemic using Agent Research and Development (Autonomous
LGCA (implementation in MATLAB) Agents and Multi-Agent Systems). Kluwer
Academic Publishers. 1998
The smoothness of curves in Fig.16 is explained by
the fact that the graph represents the average obtained [3] H. Hötzendorfer, N. Popper, F. Breitenecker.
in 40 consecutive simulation runs (Monte Carlo Temporal and Spatial Evolution of a SIR-type
method). Epidemic – ARGESIM Comparison C17 –
Definition
Of course the quantitative behavior of the models http://www.argesim.org/comparisons/index.html
differs, but this again can be solved by a proper
parameterization of the model(s).