forageMod: Run CPF model

Description Usage Arguments Details Value Examples

View source: R/forageMod.R

Description

forageMod runs central-place foraging model given forager and world data.

Function to run central-place foraging (CPF) model based on the ideal-free distribution (IFD). Takes a list of nest parameters, and a list of world parameters, runs the model until convergence, and then returns a list containing a matrix of competitive effects, and a list of matrices of foraging parameters (e.g. time in patch, foraging currency experienced at each cell). Use cpf2df() to convert this to a more readable dataframe.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
forageMod(
  world,
  nests,
  iterlim = 5000,
  verbose = FALSE,
  parallel = FALSE,
  ncore = 4,
  parMethod = "SOCK",
  tol = .Machine$double.eps^0.25
)

Arguments

world

World structure. List.

nests

Nests structure. List of lists.

iterlim

Limit to number of iterations. Default = 5000.

verbose

Should function display progress?

parallel

Should parallel processing be used for large tasks?

ncore

Number of SNOW cores to use (if parallel = TRUE).

parMethod

Message passing for parallel processing (see details below).

tol

Tolerance range for optimization function. Default = .Machine$double.eps^0.25.

Details

parMethod must be either 'SOCK' (Default) or 'MPI'. Requires doSNOW (Windows) and RMPI (Linux) packages.

world should be a named list containing:

nests should be a named list containing:

Value

List containing world structure (competition term) and nest structure (forager distribution)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#Create test world for run
nu_i<-0.3/3600 #Nectar production/hr for a single flower
flDens<-520 #Flower density/m2
e_i<-14.35 #Energetic value/unit
l_i<-1 #Canola standing crop (1uL)
f_i<-0.86 #Inter-flower flight time

#World structure
cellSize<-10 #10m cells (100m^2)
worldSize<-120 #120x120m field (100x100m field with 10m buffer zone worth nothing)
world1<-list(mu=matrix(0,worldSize/cellSize,worldSize/cellSize),
            flDens=matrix(0,worldSize/cellSize,worldSize/cellSize),
            e=matrix(0,worldSize/cellSize,worldSize/cellSize),
            l=matrix(0,worldSize/cellSize,worldSize/cellSize),
            f=matrix(0,worldSize/cellSize,worldSize/cellSize),
            alphaVal=matrix(0,worldSize/cellSize,worldSize/cellSize),
            cellSize=cellSize) #Empty world

world1$mu[c(2:11),c(2:11)]<-nu_i #Per-flower nectar production in canola-filled cells
world1$flDens[c(2:11),c(2:11)]<-flDens*cellSize^2 #Flower number per cell
world1$e[c(2:11),c(2:11)]<-e_i #Energy production in canola-filled cells
world1$l[c(2:11),c(2:11)]<-l_i #Standing crop in cells with no competition
world1$f[c(2:11),c(2:11)]<-f_i #Inter-flower flight time world1$patchLev
world1$alphaVal[c(2:11),c(2:11)] <- 0.013 #proportion increase in flight cost with load

world1$forageType <- 'omniscient' #Foraging style for flowers within patch

#Constants for foragers
honeybeeConstants<-list(L_max=59.5, #Max load capacity (uL) - Schmid-Hempel (1987)
                       v=7.8, #Velocity (m/s) - Unloaded flight speed (Wenner 1963)
                       betaVal=0.102/59.5, #Reduction of flight speed with load (v-v_load)/(v*L_max)
                       p_i=1, # Max loading rate (uL/s)
                       h=1.5, #Handling time per flower (s)
                       #Unloaded flight energetic cost (J/s) (Dukas and Edelstein Keshet 1998)
                       c_f=0.05,
                       c_i=0.0042, #Cost of non-flying activity
                       H=100 #Time spent in the hive (s)
                       )

#Nest structure (social rate maximizers)
nests1<-list(xloc=1,yloc=1,n=1000,whatCurr='rat',sol=FALSE,constants=honeybeeConstants,eps=0)

#Run model
testOutput1<-forageMod(world1,nests1,2000,verbose=FALSE,parallel=FALSE)

#Visualize distribution of foragers
image(testOutput1$nests$n)

samuelVJrobinson/CPForage documentation built on Jan. 20, 2021, 6:22 p.m.