首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在SIR模型中更新出生率和死亡率

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

Stack Overflow用户
提问于 2014-03-22 16:36:01
回答 1查看 396关注 0票数 0

我想用NetLogo软件用智能体模型来模拟疾病的传播。如何在SIR模型中更新出生率和死亡率。

EN

回答 1

Stack Overflow用户

发布于 2014-03-22 18:04:19

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

代码语言:javascript
运行
复制
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中:

代码语言:javascript
运行
复制
ifelse color = blue
[
  if (random-float 100) < (beta * red-count * blue-count ) / 1000000
    [set color red]
]

从红色到绿色

代码语言:javascript
运行
复制
      ifelse color = red
      [
        if (random-float 100) < (nu * red-count ) / 10000
          [set color green]
      ]

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

代码语言:javascript
运行
复制
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22575318

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档