1

I have a set of positive COVID-19 cases by district in a state. I want to use agent based modelling to make the infected cases move around the state and count the number of infected, number of healthy and number of immune. I have a set of code which the number of population is random and not based on the location. Tried to watch youtube for the tutorial but could not find one which really helps. the code is as below. I want to insert the map of the state, number of population for each district and number of infected in Netlogo. The codes in Netlogo are as below.

turtles-own [illness]

to setup
  clear-all
  reset-ticks
  create-turtles 200 [
    setxy random-xcor random-ycor
    set shape "person"
    set color pink
    set size 1.0
    set illness 0
  ]
  ask n-of starting-number-infected turtles [
    set color yellow
    set shape "X"
    set size 1.0
  ]
end

to go
  tick
  move
  infect
  recover
  lose-immunity
end

to move
 ask turtles [
   rt random 360
   fd movement
  ]
end

to infect
  ask turtles [
    if color = yellow [
      ask turtles in-radius infect-distance [
        if random-float 200 < infect-chance [
         if color = pink [
           set color yellow
           set shape "X"
          ]
        ]
      ]
    ]
  ]
end

to recover
 ask turtles [
    if color = yellow [
      set illness illness + 1
      if illness > infectious-period [
        set color white
        set shape "circle"
        set size 1.0
        set illness 0
      ]
    ]
  ]
end

to lose-immunity
  ask turtles [
    if color = white and waning-immunity < random-float 100 [
      set color pink
      set shape "person"
    ]
  ]
end
  • 1
    If you can get GIS data for your location you can try out [the GIS extension](https://ccl.northwestern.edu/netlogo/docs/gis.html). There [is a detailed tutorial for it](https://github.com/NetLogo/GIS-Extension/wiki/Vector-Tutorial) that walks through gathering and preparing your data, then importing it into NetLogo to use in your model. – Jasper Oct 03 '22 at 13:44

1 Answers1

0

Our trout model provides an example of using the GIS extension to import a set of polygons that represent the places where agents live. In our case, the polygons are habitat "cells", and the agents are fish; but you could use the same approach to import districts and keep track of which people are in which district.

Our model does not represent where a fish is within a polygon, but only which polygon they are in. We use a separate breed of agent called "cells" that contain the variables of the polygon. Each NetLogo patch has a variable "patches-cell" that says which cell it belongs to.

The model is here: https://ecomodel.humboldt.edu/instream-7-and-insalmo-7 (look for inSTREAM7.3). Look at the procedure build-cells.

Steve R.

Steve Railsback
  • 1,251
  • 6
  • 7