我想用NetLogo软件用智能体模型来模拟疾病的传播。如何在SIR模型中更新出生率和死亡率。
发布于 2014-03-22 18:04:19
作为一个起点,您可以尝试使用http://ccl.northwestern.edu/netlogo/models/SimpleBirthRates,它有一个方法reproduce,可以调整不同种群的生育能力
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
红色更改为绿色。beta
和nu
是模型参数。从杀死和孵化相同数量的蓝色和红色开始可能更容易。
下面的代码实现了这一点。我有三组不同的乌龟,最初的颜色比其他颜色多得多。主要部分发生在将蓝调转换为红色的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]
]
完整的代码是。您需要为beta
和nu
添加滑块,在图形中为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
https://stackoverflow.com/questions/22575318
复制相似问题