RANDOM-SOCIAL-ENCOUNTERBegin NetLogo code:
do-after 1 [add-behaviours list-of-micro-behaviours "Error checking" [RANDOM-SOCIAL-ENCOUNTER-ERROR-CHECKER.html] do-every 1 [do-if my-state = "infected" [do-for-n encounter-rate my-acquaintances [set my-last-encounter the-other add-behaviours list-of-micro-behaviours "Encounter Behaviours" [POSSIBLE-INFECTION.html]]]]]End NetLogo code
The social network that defines my-acquaintances must be defined. There are several choices. INITIALISE-SOCIAL-NETWORK-CONSTANT-SYMMETRIC, INITIALISE-SOCIAL-NETWORK-NORMAL-DISTRIBUTION-SYMMETRIC, and INITIALISE-SOCIAL-NETWORK-POWER-LAW-DISTRIBUTION-SYMMETRIC initialise the network of which agents know which other agents.
Additional encounter behaviours can be added.
This relies upon the POSSIBLE-INFECTION micro-behaviour to possibly infect the other. REPORT-ENCOUNTER-RATE defines the encounter-rate reporter used here. REPORT-ALL-LIVING computes the set of all non-dead individuals.
The RANDOM-ENCOUNTER micro-behaviour differs from RANDOM-SOCIAL-ENCOUNTER in that anyone is possibly infected regardless of the social network.
RANDOM-SPATIAL-ENCOUNTER differs from RANDOM-ENCOUNTER in biasing the selection of the other individuals to someone nearby.
RANDOM-PHYSICAL-ENCOUNTER chooses individuals that are at my location.
This models individuals that have the-encounter-rate encounters per unit time period (e.g., a simulated week). Every second, if I'm still infected (i.e., my-state = "infected") then I pick the-encounter-rate other individuals of my acquaintances (who are not dead) and give them the micro-behaviour POSSIBLE-INFECTION. If the-encounter-rate is a non-integer then the remainder is compared with a random number probabilistically to possibly include one additional individual. I also sets the my-last-encounter variable of the other individuals to me in order to keep track of how many infections I cause.
do-for-n selects n agents and sets the-other to refer to each one.
This also does error checking to produce a warning if run without defining a social network.
This was implemented by Ken Kahn.