我的模型是代表流感通过两个不同品种的成人和儿童传播。
我想做的是为成人和儿童分别接种疫苗,允许我从接口中指定两个疫苗值,从而使两个品种的海龟都有机会接种疫苗。
我目前的代码如下,我想要做的是使用接口值成人-免疫接种的百分比在该品种的海龟。
ask turtles with [ adult? = true ]
[
if (adult-vaccination = 1)
[
reset-node
set exposed? false
set susceptible? false
set temp-infected? false
show-turtle
set color pink
]
]发布于 2014-03-04 15:29:17
如果adult-vaccination是从0到1的概率,你可以像这样给成年人接种疫苗:
ask turtles with [ adult? ] [
if random-float 1 < adult-vaccination [
... ; vaccination code here
]
]如果您希望adult-vaccination实际确定接种疫苗的人口比例,您可以这样做:
let adults turtles with [ adult? ]
ask n-of round (adult-vaccination * count adults) adults [
...; vaccination code here
]还有几个小道消息:
variable = true总是true或false,则variable将与true相同。adults品种和children品种。然后你可以做一些像ask adults [ do stuff ]这样的事情,给大人和孩子不同的变量等等。https://stackoverflow.com/questions/22146832
复制相似问题