Agent Based Virus Model using NetLogo: Infection Propagation, Precaution, Recovery, Multi-site Mobility and (Un)Lockdown
aa r X i v : . [ c s . M A ] J a n Agent Based Virus Model using NetLogo: Infection Propagation,Precaution, Recovery, Multi-site Mobility and (Un)Lockdown
Dibakar Das
IIIT Bangalore, [email protected]
Abstract —This paper presents a novel virus propagation modelusing NetLogo. The model allows agents to move across multiplesites using different routes. Routes can be configured, enabled formobility and (un)locked down independently. Similarly, locationscan also be (un)locked down independently. Agents can get in-fected, propagate their infections to others, can take precautionsagainst infection and also subsequently recover from infection.This model contains certain features that are not present inexisting models. The model may be used for educational andresearch purposes, and the code is made available as opensource. This model may also provide a broader framework formore detailed simulations. The results presented are only todemonstrate the model functionalities and do not serve any otherpurpose.
Index Terms —agent based model, netlogo, virus, infection,precaution, recovery, mobility, lockdown
I. I
NTRODUCTION
Agent based models have been explored for virus spreadfor a considerable period of time. These models have evolvedover time based on the newer requirements. NetLogo [1] isone of the agent based modeling platform that has been usedto model virus spread as well.Several agent based models using NetLogo have beenproposed in the literature. NetLogo model library contains abasic model of infection spread [2]. [3] extends [2] with pop-ulation density, degree of immunity, infectiousness, durationof infection. [4] presents a NetLogo model to include travel,isolation, quarantine, inoculation, links between individuals,and spread of an infectious disease in a closed population.[5] presents a probabilistic model of COVID-19 spread usingNetLogo. All these previous works focus on different aspectsof virus spread. This paper presents a novel NetLogo basedvirus infection propagation considering multi-site mobility,route and site (un)lockdowns, precautions and recovery. Tothe best of the knowledge of the author, none of the previousworks addresses these aspects.The paper is organized as follows. The proposed model isdescribed in section II. Implementation aspects are explainedin III. Results to demonstrate the model are presented insection IV. Conclusions are drawn in section V.II. M
ODEL D ESCRIPTION
Fig. 1 shows the features available in the proposed model.There are 5 locations and 8 routes in the model. Since,there are many parameters in the model, some of them areconfigurable in the GUI and several others are hard coded to avoid GUI to be too much cluttered. The model runs based onthe GUI configuration and the hard coded parameters. Thehard coded parameters may be modified to suit the needsof simulation. Red box in Fig. 1 contains the setup and go procedures. The green box on the left shows the routesthat can be configured with switch options. Once a route isconfigured, it cannot be disabled till next run. The blue box ontop right of Fig. 1 contains 5 switch options to infect turtles(agents) in the 5 locations (white circles), namely, red (centre),blue (bottom-left), pink (bottom-right), cyan (top-right) andyellow (top-left). The brown box below the blue contains3 switch options. One of them is to propagate infection toother turtles. The next switch option is to enable precautionsfor the turtles. The last switch option is for turtle recovery.The pink box on the right contains 2 columns, each with 5switch options. Each row of 2 switch options allows a location(white circles) to be locked down and local mobility to bedisabled. If a location is locked down, mobility of turtles alongits configured routes are disabled. If local mobility is alsodisabled along with location lock down, then turtles freezetheir movements in that location. To unlock a location (whitecircle), set the corresponding switch to Off position, enablelocal mobility (if disabled) and then enable mobility of turtlesexplicitly along the associated configured routes. Each routecan be individually locked down (and unlocked again) with the8 switch options shown in the purple box shown on the rightside of Fig. 1 below the pink box. There are 3 plots (yellowboxes) showing the percentage of turtles infected (bottom-leftin Fig. 1), percentage of recovered turtles (bottom-right) andpercentage of turtles taking precautions (on top of the previousbox). Turtles are circles by default, when they are infectedtheir shape change to triangles, when they take precautionstheir shape are squares and when they recover their shapesare stars.Fig. 2 shows the state of the turtles after pressing setup . Ithas the 5 static white circles which are locations containing therespective turtles. These locations are called red, blue, pink,cyan and yellow locations based on the turtles’ colour. Fig. 3shows the state of the turtles after pressing go . All the turtlesmove randomly in their respective 5 home locations.Fig. 4 shows the state of the turtles when all the 8 routesare configured (using the switches in the green box on the leftin Fig. 1). Note that all the routes need not be configured.However, a route once configured cannot be disabled till thenext run. Configured routes can be locked down and unlocked. igure 1. Complete GUI optionsFigure 2. State of turtles after “setup” For example, when route-blue-yellow-enable? isswitched On some of blue turtles destined for location yellow(top-left white circle) move towards their destination. Simi-larly, some yellow turtles start moving towards blue location(bottom-left white circle).Each of the 8 routes can be locked down independently(using the switched in purple box on the right in Fig. 1). Fig.5 shows the state of the turtles when the blue-yellow route islocked down by setting lockdown-blue-yellow? switchto On state. Changing the switch to Off state restores themobility along that route provided either of the locationsblue (bottom-left) and yellow (top-left) is not locked down(explained below).Each of the 5 locations can be locked down independently(pink box on the right in Fig. 1). Locking down one ofthe location shuts down its associated routes. The turtlesin the locked down location move within the region untilthe local mobility is also switched off. Fig. 6 shows thestate of the turtles when the red location (centre) is lockeddown by setting lockdown-red? to On state. All its 4routes to other locations are also locked down automatically,i.e., lockdown-pink-red? , lockdown-blue-red? , lockdown-cyan-red? and lockdown-yellow-red? are all set to On states. If local mobility is also disabled Figure 3. State of turtles after “go”Figure 4. State of the turtles when all the routes are configured by setting local-mobility-red-allow? to Off thenthe turtles is red location stop moving. To unlock redlocation, lockdown-red? should be set to
Off state, local-mobility-red-allow? set to On state, and the 4routes lockdown-pink-red? , lockdown-blue-red? , lockdown-cyan-red? and lockdown-yellow-red? should be set to Off states.Turtles in each of the 5 locations can get infectedindependently by setting the switches infect-red? , infect-blue? , infect-pink? , infect-cyan? and infect-yellow? to On states (using the switches in theblue box on the right in Fig. 1). Some of the randomly selectedturtles in those locations get infected and change their shapefrom circles to triangles as shown in Fig. 7. An infected turtlecan infect another uninfected turtle with certain probabilitywhen the switch propagate-infection? (switch in thebrown box on the right in Fig. 1) is set to On state. The plotassociated with Fig. 7 shows the percentage of turtles infected. igure 5. State of the turtles when blue-yellow interface is locked downFigure 6. State of the turtles when red location (centre) is locked down Turtles (randomly selected) start taking precautions when take-precautions? is set to On state (switch on thebrown box on the right in Fig. 1). Those turtles change theirshapes to squares and they do not get infected by other infectedturtles as shown in Fig. 8. The associated plot with this figureshows the percentage of turtles taking cautions. When moreturtle take precautions, infection rate flattens.Once the start-recovery? is set to On (switch in thebrown box on the right in Fig. 1), infected turtles start recoveryand change their shape to star as shown in Fig. 9. Associatedplot in the figure shows that percentage of turtles recovered.Once the recovery process starts percentage of infected turtlesbegins to drop. III. I MPLEMENTATION
As the title suggests, the model is implemented in NetLogo[1]. The code used minimal features of NetLogo to imple-ment the model. The source code is open sourced [6]. The
Figure 7. Infection PropagationFigure 8. Infection propagation and precaution implementation is simple to understand by going through thecomments. Since, there many parameters to control the model,several of them are hard coded to reduce the number of inputoptions and keep the GUI simple.The setup function does a few typical NetLogo initial-ization steps and then calls static-setup which does theinitial configuration. Function static-setup sets up the 5locations, creates 100 turtles each of 5 different colours, andinitializes private variables of turtles (own variables) e.g., theirmobility destinations, etc., ( my-heading , my-immunity , my-precaution? , my-infection? ), and global booleanflags used by the model. Function static-go called from go moves the turtles within their location till local mobilityis allowed in the respective places. Once routes (maximumof 8) are configured and not locked down, go also enablesmobility of some turtles along their designated routes totheir respective designations, leaving rest of them in their igure 9. Infection propagation and recovery homes. Function static-go also calculates the percent-age of turtles infected which is used for plotting. Function do-recovery randomly selects a certain percentage (hard-coded) of infected turtles (shaped triangle) and moves themto recovered state (shaped star) when start-recovery? is set to On state. This function also calculates the per-centage of recovered turtles used for plotting. Function do-precautions calculates the number of turtles to bemoved to precaution state, they don’t get infected and theirshape changes to squares when take-precautions? isset to On state. This function also calculates the percentageof turtles which take precautions not to get infected. Func-tion start-infection starts turtle infection based on theGUI switch options for the 5 locations. Once, a locationis infected by setting the corresponding switch to On state,it cannot be disabled. For each location, random numberof turtles are set as infected and their shapes change totriangle. However, they start propagating to other neighbourturtles (with certain probability, based on my-immunity , my-precaution? ) in function start-infection when propagate-infection? is set to On state. This func-tion also calculates the percentage of infected turtles usedfor plotting. Function static-lockdown-interface isused to lock down any of the configured 8 routes indepen-dently. Once, a route is locked the turtles, destined to theirrespective location, defined by my-heading , keep movingtill they reach those locations. Further mobility of turtlesstops thereafter. Function static-lockdown locks downany of the 5 locations and their associated routes inde-pendently. Function toss-a-coin generate some amountof randomness whether a turtle can get infected. Function mobility-direction randomly allocates mobility direc-tion to the turtles by setting the variable my-heading .Since, the model has many parameters, some of them hashardcoded. The most important ones are listed below. • Number of turtles per location (fixed during initialization) • Number of turtles that move locally within a site (selected at random from a fixed set) • Number of turtles that move along the routes acrosslocation (selected at random from a fixed set) • Number of turtles that recovers (selected at random froma fixed set) • Number of turtles that take precautions (selected at ran-dom from a fixed set) • Number of turtles that get infected (selected at randomfrom a fixed set) • Direction of movement of turtles that move across sites(selected at random from a fixed set)IV. R
ESULTS
The results presented in this section are only to demonstratethe model functionalities and do not serve any other purpose.The plot in Fig. 10 shows how the infection grows with time.Two plots in Fig. 11 show the behaviour when the infection
Figure 10. Infection growth curveFigure 11. Infection growth curve with turtles taking precautions propagation happens and turtles also take precaution. Infectionpropagation saturates when turtles start taking precaution.Fig. 12 shows two plots which show the behaviour whenthe recovery process starts and infection among turtles startdropping. V. C
ONCLUSION AND F UTURE W ORK
This paper presented a novel NetLogo model for virusspread addressing features, such as, multi-site mobility, siteand route (un)lockdowns, precautions and recovery, which are igure 12. Infection growth curve with turtles recovery not available in the existing models. The results presentedare only to demonstrate the model functionalities and donot serve any other purpose. This model can be used foreducation and research purposes. Also, the model may providea broader framework for more detailed simulations. Moreadvanced features of NetLogo could reduce the code size. Infuture, attempts would be made to make some of the hardcodedparameters configurable.R
EFERENCES[1] U. Wilensky, “Netlogo.” [Online]. Available:https://ccl.northwestern.edu/netlogo/[2] ——, “Netlogo virus model,”