更新SIR模型中的出生率和死亡率

时间:2014-03-22 08:36:01

标签: netlogo

我想使用NetLogo软件使用代理基础模型模拟疾病传播。 如何在SIR模型中更新出生率和死亡率。

1 个答案:

答案 0 :(得分:1)

作为起点,您可以尝试http://ccl.northwestern.edu/netlogo/models/SimpleBirthRates 有一种方法可以调整不同种群的生育能力

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

对于SIR模型,请参阅https://en.wikipedia.org/wiki/SIR_model#The_SIR_model

你可能想要三种不同的蓝色(S易感),红色(I传染性)和绿色(R恢复)。您想要更改代码,以便将beta I S蓝调更改为红色,并将nu I红色更改为绿色。 betanu是模型参数。通过杀死和孵化相同数量的蓝色和红色可能更容易。

以下代码实现了这一点。我有三套不同的海龟,最初比其他颜色更蓝。主要部分发生在reproduce,将蓝调变为红色:

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]
      ]

完整的代码是。您需要为betanu添加滑块,在green-count的图表和green-count的监视器中添加一行。这些数字是通过猜测工作选择的,这似乎表现出良好的效果。

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