【问题标题】:Dengue Netlogo Model登革热网络标志模型
【发布时间】:2015-12-26 09:37:05
【问题描述】:

我的团队已经编写了一个代码,用于模拟特定地区的登革热。但是,我们不明白代码有什么问题,因为被感染者不会被感染。抱歉,我们是这个编程的新手。希望您能花时间看一下该计划。谢谢。

breed [humans human]
breed [mosquitoes mosquito]
breed [dead]

globals [
  total-human     ;; Total number of agents that are human
  total-mosquito  ;; Total number of mosquitoes that are human
  angle           ;; Heading for individuals
]

turtles-own [
  kill                  ;; Agent-subset consisting of mosquitoes within          vison of human
  infected-human?       ;; If true, human is infected
  infected-mosquito?    ;; If true, mosquito is infected
  susceptible-human?    ;; If true, human is susceptible
  susceptible-mosquito? ;; If true, mosquito is susceptible
]

to setup
clear-all
setup-people
setup-mosquitoes
create-dead 0
[ set shape "square"
  set color orange ]
reset-ticks
end

to setup-people
create-humans initial-people
[
  setxy random-xcor random-ycor
  set shape "person"
 set color white

  set infected-human? false
  set susceptible-human? true

  if who < initial-infected-people ;; these people are initially infected
  [
    set infected-human? true
    set susceptible-human? false
  ]

  assign-color-human
]
end

to setup-mosquitoes
create-mosquitoes initial-mosquito
[
  setxy random-xcor random-ycor
  set shape "mosquito"
  set color blue

  set infected-mosquito? false
  set susceptible-mosquito? true

  if (random-float 100 < 10) ;; 10% of mosquitoes are initially infected
  [
    set infected-mosquito? true
    set susceptible-mosquito? false
  ]
  assign-color-mosquito
 ]
end

to assign-color-human
  if infected-human? [ set color red ]
  if susceptible-human? [ set color white ]
end

to assign-color-mosquito
  if infected-mosquito? [ set color yellow ]
  if susceptible-mosquito? [set color blue ]
end

to go
   move-mosquitoes
   move-people
    end

to move-mosquitoes
  ask mosquitoes
  [
rt random 100
lt random 100
fd 1
  ]
  tick

end

to move-people
  ask humans
  [
rt random 100 ;people move around the world randomly
lt random 100
fd 1

ifelse infected-human? = true ;there is a chance that if people are       infectious they will infect mosquitoes who bite them
  [ask mosquitoes in-radius bite-likelihood
    [if any? mosquitoes with [susceptible-mosquito? = true]
                  [set infected-mosquito? true
                   set susceptible-mosquito? false]
    ]
  ]

  [ask mosquitoes in-radius bite-likelihood ;there is a chance that if people are not infectious they can be infected by infectious mosquitoes
    [ifelse infected-mosquito? = true ;if mosquitoes are infectious they can infect nearby non-infected people
                  [ask humans in-radius bite-likelihood [if any? humans in-radius bite-likelihood with [susceptible-human? = true]
                                                                          [set infected-human? true
                                                                           set susceptible-human? false]
                                                               ]
                  ]
                  [ask humans in-radius bite-likelihood with [susceptible-human? = true] [if any? humans in-radius bite-likelihood with [susceptible-human? = true]
                                                                          [set infected-human? false
                                                                           set susceptible-human? true]] ;if noninfectious mosquitoes bite noninfectious people, nothing happens

                  ]
    ]
  ]

  ifelse infected-human? = true
  [ask humans in-radius recovery-likelihood [if any? humans in-radius recovery-likelihood with [infected-human? = true]
                                            [
                                             set infected-human? false
                                             set susceptible-human? true
                                            ]
                                           ]
  ]

  [ask humans in-radius death-likelihood [if any? humans in-radius death-likelihood with [infected-human? = true]
                                          [set breed dead]
                                         ]
  ]
  ]





end

【问题讨论】:

  • 请更具体地描述您的问题。最初感染的人不会被感染吗?最初的人会被感染但不会感染蚊子吗?蚊子会被感染但不会感染更多的人吗?最后,咬合可能性的值是多少(因为那是感染半径)?
  • 首先是一般编程建议 - 逐步构建您的模型。例如,在试图传播疾病之前让人和蚊子四处走动。您的模型的其他一般问题 (1) 您应该有 humans-own 变量为 kill,infected-human?和易感人?和mosquitoes-own 带有变量感染蚊子?和易感蚊子?目前,无论它们是否与品种相关,您都为所有海龟提供了相同的变量集。 (2) 将tick移动到go过程的末尾。
  • (3) 你在move people 过程中有太多事情要做。将运动与疾病传播分开。你的go 程序应该有这样的内容:移动蚊子、移动人、感染蚊子、感染人、恢复蚊子、恢复人、打勾,其中每一个都是一个单独的程序。
  • JenB 的所有建议都很好。我将重复并扩展她最重要的建议:不要一次编写这么多代码。从工作代码开始。一次做一个小改动,并在进行下一个改动之前让它发挥作用。保留旧版本,以便在迷路时可以随时返回工作代码。
  • @JenB 是的,最初的感染者不会被感染,也不会感染蚊子。蚊子也没有被感染。 bit-likelihood 的值为 100。好的,我将根据您的反馈继续编写代码。谢谢!!

标签: netlogo


【解决方案1】:

好的,所以问题是最初感染的人不会被感染。如果他们不被感染,他们显然无法感染蚊子,而蚊子则无法感染其他人。这意味着问题可能出在这一行:

if who < initial-infected-people

一般建议 - 如果您使用 who,您可能做错了什么。在这种情况下,我假设您有一个滑块(或其他一些输入方法)将初始感染者设置为某个数字。假设这个数字是 5。然后这条线说要感染任何数量

您需要做的是更好地分离您的品种并使用ask-n-of 原语来感染最初的人类。比如:

breed [humans human]
breed [mosquitoes mosquito]
breed [deads dead]

globals [
  total-human     ;; Total number of agents that are human
  total-mosquito  ;; Total number of mosquitoes that are human
]

humans-own [
  kill                  ;; Agent-subset of mosquitoes within vision
  infected-human?       ;; If true, human is infected
  susceptible-human?    ;; If true, human is susceptible
]

mosquitoes-own [
  infected-mosquito?    ;; If true, mosquito is infected
  susceptible-mosquito? ;; If true, mosquito is susceptible
]

to setup
  ...
  set total-human <some number> (or put on a slider)
  set total-mosquito <some number> (or put on a slider)
  create-humans total-human [<code for shape, position etc]
  ask n-of initial-infected-people humans [set infected-person? TRUE]
  create-mosquitoes total-mosquito [<code for shape, position etc>]
  ...
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-18
    • 1970-01-01
    • 1970-01-01
    • 2019-10-21
    相关资源
    最近更新 更多