Description Usage Arguments Value
Second try function for finding a mate, for pararellisation Takes in a female mosquito's position, then finds a single mate for them. Returns the ID of the male mate. NB the input of this function is the row position of a female in the current data.frame of agents. The output is the ID number (a column/variable) of a mate, and not its row position.
1 | find_a_mate(femID, k, max_daily_mates, mozzie.dt)
|
femID |
ID of female mosquito to find a mate for. |
k |
2*k is the width of the bounding box drawn around the mosquito. This function will attempt to find a mate within this box. |
max_daily_mates |
Maximum number of times a male mosquito can mate in one day. |
The ID number of the male mate. Find males inside that boundary I find it easier to do a dplyr::filter and then change to ID numbers etc, system.time of the below on nrow(mozzie.dt) = 91795 gives: user system elapsed 0.008 0.008 0.018 no_bachelors == 0 means that there are no suitable mates. no_bachelors == 1 means there is one suitable bachelor no_bachelors > 1 means there are multiple suitable bachelors We randomly permute them and then take the top of the pile. Return the ID :)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.