mc_prioritize: Metapopulation capacity-based prioritization

Description Usage Arguments Value Examples

View source: R/mc-prioritize.r

Description

This function is a thin wrapper around optim() that performs conservation prioritization using simulated annealing.

Usage

1
2
mc_prioritize(objective, nsf, x, n = 10000L, itemp = 10, n_temp = 10L,
  maximize = TRUE, verbose = TRUE)

Arguments

objective

an objective function to optimize over, typically created by generate_objective().

nsf

a neighbour selection function, typically created by generate_nsf().

x

logical vector specifying which planning units are selected as a starting point. Traditional conservation prioritization methods, such as those implemented by the prioritizr R package, can be used to generate starting solutions.

n

integer; number of simulated annealing iterations.

itemp

numeric; initial temperature for the simulated annealing cooling schedule. Higher temperatures will result in bad changes being more likely to be accepted.

n_temp

integer; number of objective function evaluations at each temperature in the annealing process.

maximize

logical; whether the objective function is to be maximized or minimized. The standard objective function generated by generate_objective() is meant to be maximized.

verbose

logical; whether to print the simulated annealing output as the heuristic progresses.

Value

A logical vector indicating which planning units are selected in the final solution.

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
# generate features
r <- raster::raster(nrows = 10, ncols = 10, crs = "+proj=aea",
                    vals = sample(0:1, 100, replace = TRUE))
s <- raster::stack(r, r, r)
s[[2]][] <- sample(0:1, 100, replace = TRUE, prob = c(0.6, 0.4))
s[[3]][] <- sample(0:1, 100, replace = TRUE, prob = c(0.8, 0.2))
names(s) <- c("a", "b", "c")
features <- raster::rasterToPolygons(s)
features <- sf::st_as_sf(features)
# cost
features$cost <- runif(nrow(features))
# dispersal functions
disp_f <- list(a = dispersal_negexp(1 / 0.01),
               b = dispersal_negexp(1 / 0.005),
               c = dispersal_negexp(1 / 0.02))

# calculate scale factors
scale_mc <- mc_reserve(features, rep(TRUE, nrow(features)), disp_f)

# set budget at 50% of total
budget <- 0.5 * sum(features$cost)

# build an objective function and neighbour selection function
objective <- generate_objective(features, disp_f, budget, delta = 0.001,
                                blm = 0.001, units = "km")
nsf <- generate_nsf(features, buffer = 20)

# random starting point
x_start <- sample(c(FALSE, TRUE), 100, replace = TRUE, prob = c(0.9, 0.1))

# optimize
mc_prioritize(objective, nsf, x_start, n = 50L)

mstrimas/metacapa documentation built on Dec. 3, 2019, 3:16 p.m.