我正在开发一个简单的NetLogo疾病模型,它有4个部分:
S-易感个体,E-暴露个体,I-感染个体,S-恢复个体,再次易感(即没有免疫力)。
我的模拟从一个最初被感染的人开始,其余的人都是易感的。
这是我到目前为止所拥有的代码:
turtles-own [
disease?
latent?
susceptible?
latent-period-time
infectious-period-time
]
to setup
clear-all
create-turtles num-agents [ setxy random-xcor random-ycor
set shape "wolf"
set size 2
become-susceptible
]
ask n-of infected-agents turtles [become-infected]
reset-ticks
end
to go
move
spread
tick
end
to move
ask turtles [
right random 50
left random 50
fd 1 ]
end
to spread
ask turtles [
ifelse disease? [] [
if any? other turtles-here with [ disease? ]
[ become-latent
set latent-period-time 0 ]
]]
ask turtles [
if latent-period-time = latent-period ;latent-period is a slider variable set to 30
[
become-infected
set infectious-period-time 0]
]
ask turtles [
if infectious-period-time = infectious-period ;infectious-period is a slider variable set to 100
[
become-susceptible]
]
ask turtles [
if latent?
[ set latent-period-time latent-period-time + 1 ]
if disease?
[set infectious-period-time infectious-period-time + 1] ]
end
to become-susceptible
set disease? false
set latent? false
set susceptible? true
set color orange
end
to become-latent
set latent? true
set disease? false
set susceptible? false
set color gray
end
to become-infected
set latent? false
set disease? true
set susceptible? false
set color blue
end由于某些原因,只有最初感染的个体似乎会回到易感池,而任何其他新感染的个体都不会回到易感池。最初被感染的人在回到易感人群后也不会再次感染,即使它遇到了受感染的人。
我不确定如何解决这个问题。
谢谢!
发布于 2021-04-28 19:09:54
您的问题是,您从未将潜伏期时间和感染期时间的值重新设置为0。有两种方法可以解决这个问题:
set state-start-time ticks,然后对持续时间进行减法测试。https://stackoverflow.com/questions/67288887
复制相似问题