Tarig
Tarig

Reputation: 1

Update Birth and death rates in an SIR model

i would like to simulate the disease spread using agent base model by using NetLogo software. how to Update Birth and death rates in an SIR model.

Upvotes: 0

Views: 460

Answers (1)

Salix alba
Salix alba

Reputation: 7824

As a starting point you could try the http://ccl.northwestern.edu/netlogo/models/SimpleBirthRates that has a method reproduce which adjusts the fertility of the different populations

to reproduce
  ask turtles
  [
    ifelse color = red
    [
      set fertility floor red-fertility
      set fertility-remainder red-fertility - (floor red-fertility)
    ]
    [
      set fertility floor blue-fertility
      set fertility-remainder blue-fertility - (floor blue-fertility)
    ]
    ifelse (random-float 100) < (100 * fertility-remainder)
      [ hatch fertility + 1 [ wander ]]
      [ hatch fertility     [ wander ]]
  ]
end

For the SIR model see https://en.wikipedia.org/wiki/SIR_model#The_SIR_model

You probably want three different populations blue(S susceptible), red(I infectious), and green(R recovered). You want to change the code so that you change beta I S blues into reds and change nu I reds into greens. beta and nu are model parameters. It might be easier to start by killing and hatching equal numbers of blues and reds.

The following code implements this. I have three different sets of turtles, initially many more blue than the other colours. The main part happens in the reproduce which turns blues to reds:

ifelse color = blue
[
  if (random-float 100) < (beta * red-count * blue-count ) / 1000000
    [set color red]
]

and reds to greens

      ifelse color = red
      [
        if (random-float 100) < (nu * red-count ) / 10000
          [set color green]
      ]

The full code is. You need to add sliders for beta and nu, add a line in the graph for green-count and a monitor for green-count. The numbers have been chosen by guess work which seem to show a good effect.

globals
[
  red-count            ; population of red turtles
  blue-count           ; population of blue turtles
  green-count          ; population of green turtles
]

turtles-own
[

]

to setup
  clear-output
  setup-experiment
end

to setup-experiment
  cp ct
  clear-all-plots
  reset-ticks
  crt carrying-capacity
  [
    setxy random-xcor random-ycor         ; randomize turtle locations
    ifelse who < (carrying-capacity / 10)  ; start out with equal numbers of reds and blues
      [ set color red ]
      [ 
        ifelse who < (2 * carrying-capacity / 10)  ; start out with equal numbers of reds and blues
      [ set color green ]
      [ set color blue ]
 ]
    set size 2                            ; easier to see
  ]
  reset-ticks
end

to go
  reproduce
  tick
end

to reproduce
  ask turtles
  [
    ifelse color = blue
    [
      if (random-float 100) < (beta * red-count * blue-count ) / 1000000
        [set color red]
    ]
    [
      ifelse color = red
      [
        if (random-float 100) < (nu * red-count ) / 10000
          [set color green]
      ]
      [

      ]
    ]
  ]
end

Upvotes: 1

Related Questions