initiateAgents: 'SELES' - Initiate agents

Description Usage Arguments Value Author(s) Examples

Description

Sets the the number of agents to initiate. THIS IS NOT FULLY IMPLEMENTED.

A SELES-like function to maintain conceptual backwards compatibility with that simulation tool. This is intended to ease transitions from SELES.

You must know how to use SELES for these to be useful.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
initiateAgents(map, numAgents, probInit, asSpatialPoints = TRUE, indices)

## S4 method for signature 'Raster,missing,missing,ANY,missing'
initiateAgents(map, numAgents,
  probInit, asSpatialPoints)

## S4 method for signature 'Raster,missing,Raster,ANY,missing'
initiateAgents(map, probInit,
  asSpatialPoints)

## S4 method for signature 'Raster,numeric,missing,ANY,missing'
initiateAgents(map, numAgents,
  probInit, asSpatialPoints = TRUE, indices)

## S4 method for signature 'Raster,numeric,Raster,ANY,missing'
initiateAgents(map, numAgents,
  probInit, asSpatialPoints)

## S4 method for signature 'Raster,missing,missing,ANY,numeric'
initiateAgents(map, numAgents,
  probInit, asSpatialPoints = TRUE, indices)

Arguments

map

RasterLayer with extent and resolution of desired return object

numAgents

numeric resulting from a call to numAgents

probInit

a Raster resulting from a probInit call

asSpatialPoints

logical. Should returned object be RasterLayer or SpatialPointsDataFrame (default)

indices

numeric. Indices of where agents should start

Value

A SpatialPointsDataFrame, with each row representing an individual agent

Author(s)

Eliot McIntire

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
library(magrittr)
library(raster)
library(quickPlot)

map <- raster(xmn = 0, xmx = 10, ymn = 0, ymx = 10, val = 0, res = 1)
map <- gaussMap(map, scale = 1, var = 4, speedup = 1)
pr <- probInit(map, p = (map/maxValue(map))^2)
agents <- initiateAgents(map, 100, pr)
if (interactive()) {
  clearPlot()
  Plot(map)
  Plot(agents, addTo = "map")
}

# Note, can also produce a Raster representing agents,
# then the number of points produced can't be more than
# the number of pixels:
agentsRas <- initiateAgents(map, 30, pr, asSpatialPoints = FALSE)
if (interactive()) Plot(agentsRas)

if (require(dplyr)) {
  # Check that the agents are more often at the higher probability areas based on pr
  out <- data.frame(stats::na.omit(crosstab(agentsRas, map)), table(round(map[]))) %>%
     dplyr::mutate(selectionRatio = Freq/Freq.1) %>%
     dplyr::select(-Var1, -Var1.1) %>%
     dplyr::rename(Present = Freq, Avail = Freq.1, Type = Var2)
  out
}

SpaDES.tools documentation built on July 15, 2018, 9:01 a.m.