Reputation: 71
My model is representing the spread of influenza through two separate breeds adults and children.
What I would like to do is add separate vaccinations for adults and children, allowing me to specify two vaccination values from the interface giving the chance of the two respective breeds turtles being vaccinated
My current code is below, what I want to be able to do is use the interface value adult-vaccination to vaccinate a percentage of the turtles in that breed.
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
]
]
Upvotes: 1
Views: 168
Reputation: 12580
If adult-vaccination
is a probability from 0 to 1, you can probabilistically vaccinate adults like so:
ask turtles with [ adult? ] [
if random-float 1 < adult-vaccination [
... ; vaccination code here
]
]
If you want adult-vaccination
to actually determine the fraction of the population that is vaccinated, you can do that like so:
let adults turtles with [ adult? ]
ask n-of round (adult-vaccination * count adults) adults [
...; vaccination code here
]
A few other tidbits:
variable = true
will be the same as variable
if variable
is always true
or false
. adults
breed and children
breed. Then you can do things like ask adults [ do stuff ]
and give adults and children different variables, etc.Upvotes: 2