raptr: Representative and Adequate Prioritization Toolkit in R

Overview

This vignette illustrates the basic usage of the raptr R package.

To load the raptr R package and learn more about the package, type the following code into R.

# load raptr R package
library(raptr)

# show package overview
?raptr

The raptr R package uses a range of S4 classes to store conservation planning data, parameters, and prioritizations (Table 1).

Table 1: Main classes in the raptr R package

Class Description
ManualOpts place-holder class for manually specified solutions
GurobiOpts stores parameters for solving optimization problems using Gurobi
RapUnreliableOpts stores control variables parameters for the unreliable problem formulation
RapReliableOpts stores control variables for the reliable problem formulation
DemandPoints stores the coordinates and weights for a given species and attribute space
PlanningUnitPoints stores the coordinates and ids for planning units that can be used to preserve a given species
AttributeSpace stores the coordinates for planning units and the demand points for each species
RapData stores the all the planning unit, species, and attribute space data
RapUnsolved stores all the data, control variables, and parameters needed to generate prioritizations
RapResults stores the prioritizations and summary statistics generated after solving a problem
RapSolved stores the input data and output results

Getting started

This tutorial is designed to provide users with an understanding of how to use the raptr R package to generate and compare solutions. This tutorial uses several additional packages, so first we will run the following code to load them.

# load packages for tutorial
library(parallel)
library(plyr)
library(dplyr)
library(ggplot2)
library(RandomFields)
library(rgeos)

# set seed for reproducibility
set.seed(500)

# set number of threads for computation
threads <- as.integer(max(1, detectCores() - 2))

Now we will check if the the Gurobi software suite and the gurobi R package are installed. To do this, run the following code.

is.GurobiInstalled(verbose = TRUE)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## [1] TRUE

Simulated examples

Data

To investigate the behavior of the problem, we will generate prioritizations for three simulated species. We will use the unreliable formulation of the problem to understand the basics, and later move onto the reliable formulation. The first species (termed ‘uniform’) will represent a hyper-generalist. This species will inhabit all areas with equal probability. The second species (termed ‘normal’) will represent a species with a single range core. The third species (termed ‘bimodal’) will represent a species with two distinct ecotypes, each with their own range core. To reduce computational time for this example, we will use a 10 \(\times\) 10 grid of square planning units.

# make planning units
sim_pus <- sim.pus(100L)

# simulate species distributions
sim_spp <- lapply(c("uniform", "normal", "bimodal"), sim.species, n = 1,
                  x = sim_pus, res = 1)

Let’s see what these species’ distributions look like.

# plot species
plot(stack(sim_spp),
     main = c("Uniform species", "Normal species", "Bimodal species"),
     addfun = function() lines(sim_pus), nc = 3)
_Distribution of three simulated species. Each square represents a planning unit. The color of each square denotes the probability that individuals from each species occupy it._

Distribution of three simulated species. Each square represents a planning unit. The color of each square denotes the probability that individuals from each species occupy it.

Next, we will generate a set of demand points. To understand the effects of probabilities and weights on the demand points, we will generate the demand points in geographic space. These demand points will be the centroids of the planning units. Additionally, we will use the same set of demand points for each species and only vary the weights of the demand points between species. Note that we are only using the same distribution of demand points for different species for teaching purposes. It is strongly recommended to use different demand points for different species in real-world conservation planning exercises. See the case-study section of this tutorial for examples on how to generate suitable demand points.

# generate coordinates for pus/demand points
pu_coords <- gCentroid(sim_pus, byid = TRUE)

# calculate weights
sim_dps <- lapply(sim_spp, function(x) extract(x, pu_coords))

# create demand point objects
sim_dps <- lapply(sim_dps, function(x) DemandPoints(pu_coords@coords,
                                                    weights = c(x)))

Now, we will construct a RapUnsolved object to store our input data and parameters. This contains all the information to generate prioritizations.

## create RapUnreliableOpts object
# this stores parameters for the unreliable formulation problem (ie. BLM)
sim_ro <- RapUnreliableOpts()

## create RapData object
# create data.frame with species info
species <- data.frame(name = c("uniform", "normal", "bimodal"))

## create data.frame with species and space targets
# amount targets at 20% (denoted with target=0)
# space targets at 20% (denoted with target=1)
targets <- expand.grid(species = 1:3, target = 0:1, proportion = 0.2)

# calculate probability of each species in each pu
pu_probabilities <- calcSpeciesAverageInPus(sim_pus, stack(sim_spp))

## create AttributeSpace object
# this stores the coordinates of the planning units in an attribute space
# and the coordinates and weights of demand points in the space
pu_points <- PlanningUnitPoints(coords = pu_coords@coords,
                                ids = seq_len(nrow(sim_pus@data)))

attr_spaces <- AttributeSpaces(
  list(AttributeSpace(planning.unit.points = pu_points,
                      demand.points = sim_dps[[1]],
                      species = 1L),
       AttributeSpace(planning.unit.points = pu_points,
                      demand.points = sim_dps[[2]],
                      species = 2L),
       AttributeSpace(planning.unit.points = pu_points,
                      demand.points = sim_dps[[3]],
                      species = 3L)),
  name = "geographic")

# generate boundary data information
boundary <- calcBoundaryData(sim_pus)

## create RapData object
# this stores all the input data for the prioritization
sim_rd <- RapData(sim_pus@data, species, targets, pu_probabilities,
                  list(attr_spaces), boundary, SpatialPolygons2PolySet(sim_pus))

## create RapUnsolved object
# this stores all the input data and parameters needed to generate
# prioritizations
sim_ru <- RapUnsolved(sim_ro, sim_rd)

Single-species prioritizations

Amount-based targets

To investigate the effects of space-based targets, we will generate a prioritization for each species using only amount-based targets and compare them to prioritizations generated using amount- and space-based targets. To start off, we will generate a prioritization for the uniform species using amount-based targets. To do this, we will generate a new sim_ru object by extracting out the data for the uniform species from the sim_ru object. Then, we will update the targets in the new object. Finally, we will solve the object to generate a prioritization that fulfills the targets for minimal cost.

# create new object with just the uniform species
sim_ru_s1 <- spp.subset(sim_ru, "uniform")

# update amount targets to 20% and space targets to 0%
sim_ru_s1 <- update(sim_ru_s1, amount.target = 0.2, space.target = NA,
                    solve = FALSE)
options(error = function() {
    traceback()
    q("no", 1, FALSE)
})

# solve problem to identify prioritization
sim_rs_s1_amount <- solve(sim_ru_s1, Threads = threads)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Optimize a model with 1 rows, 100 columns and 100 nonzeros
## Variable types: 0 continuous, 100 integer (100 binary)
## Coefficient statistics:
##   Matrix range     [5e-01, 5e-01]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [1e+01, 1e+01]
## Found heuristic solution: objective 20
## Presolve removed 1 rows and 100 columns
## Presolve time: 0.00s
## Presolve: All rows and columns removed
## 
## Explored 0 nodes (0 simplex iterations) in 0.00 seconds
## Thread count was 1 (of 4 available processors)
## 
## Solution count 1: 20 
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 2.000000000000e+01, best bound 2.000000000000e+01, gap 0.0000%
## show summary
# note the format for this is similar to that used by Marxan
# see ?raptr::summary for details on this table
summary(sim_rs_s1_amount)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL    20   20             20                220
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1              42               168               10
##   Connectivity_In_Fraction
## 1                0.1909091
# show amount held
amount.held(sim_rs_s1_amount)
##   uniform
## 1     0.2
# show space held
space.held(sim_rs_s1_amount)
##   uniform (Space 1)
## 1        -0.2363636

Now that we have generated a prioritization, let’s see what it looks like. We can use the spp.plot method to see how the prioritization overlaps with the uniform species’ distribution. Note that since all planning units have equal probabilities for this species, all planning units have the same fill color.

# plot the prioritization and the uniform species' distribution
spp.plot(sim_rs_s1_amount, 1, main = "Uniform species")
_A prioritization for the uniformly distributed species generated using amount-based targets (20\%). Sqaures represent planning units. Planning units with a green border are selected for prioritization, and their colour denotes the probability they are inhabited by the species._

A prioritization for the uniformly distributed species generated using amount-based targets (20%). Sqaures represent planning units. Planning units with a green border are selected for prioritization, and their colour denotes the probability they are inhabited by the species.

The prioritization for the uniform species appears to be just a random selection of planning units. This behavior is due to the fact that any prioritization with 20 planning units is optimal. By relying on just amount targets, this solution may preserve a section of the species’ range core, or just focus on the range margin, or some random part of its range–no emphasis is directed towards preserving different parts of the species’ range. This behavior highlights a fundamental limitation of just using amount-based targets. In the absence of additional criteria, conventional reserve selection problems do not contain any additional information to identify the most effective prioritization.

Now, we will generate a prioritization for the normally distributed species using amount-based targets. We will use a similar process to what we used for the uniformly distributed species, but for brevity, we will use code to generate solutions immediately after updating the object.

# create new object with just the normal species
sim_ru_s2 <- spp.subset(sim_ru, "normal")
# update amount targets to 20% and space targets to 0% and solve it
sim_rs_s2_amount <- update(sim_ru_s2, amount.target = 0.2, space.target = NA,
                           solve = TRUE, Threads = threads)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Optimize a model with 1 rows, 100 columns and 100 nonzeros
## Variable types: 0 continuous, 100 integer (100 binary)
## Coefficient statistics:
##   Matrix range     [7e-02, 7e-01]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [7e+00, 7e+00]
## Found heuristic solution: objective 27
## Presolve removed 0 rows and 86 columns
## Presolve time: 0.00s
## Presolved: 1 rows, 14 columns, 14 nonzeros
## Variable types: 0 continuous, 14 integer (0 binary)
## Presolved: 1 rows, 14 columns, 14 nonzeros
## 
## 
## Root relaxation: objective 9.864476e+00, 6 iterations, 0.00 seconds
## 
##     Nodes    |    Current Node    |     Objective Bounds      |     Work
##  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
## 
##      0     0    9.86448    0    1   27.00000    9.86448  63.5%     -    0s
## H    0     0                      10.0000000    9.86448  1.36%     -    0s
## 
## Explored 1 nodes (6 simplex iterations) in 0.00 seconds
## Thread count was 2 (of 4 available processors)
## 
## Solution count 2: 10 27 
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 1.000000000000e+01, best bound 1.000000000000e+01, gap 0.0000%
## Warning in validityMethod(object): some species have space.held values less
## than 0, and are really poor represented
# show summary
summary(sim_rs_s2_amount)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL    10   10             10                220
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1              12               192               16
##   Connectivity_In_Fraction
## 1               0.05454545
# show amount held
amount.held(sim_rs_s2_amount)
##      normal
## 1 0.2026153
# show space held
space.held(sim_rs_s2_amount)
##   normal (Space 1)
## 1        0.5909494

Now let’s visualize the prioritization we made for the normal species.

# plot the prioritization and the normal species' distribution
spp.plot(sim_rs_s2_amount, 1, main = "Normal species")
_A prioritization for the normally distributed species generated using amount-based targets (20\%). See Figure 3 caption for conventions._

A prioritization for the normally distributed species generated using amount-based targets (20%). See Figure 3 caption for conventions.

The amount-based prioritization for the normal species focuses only on the species’ range core. This prioritization fails to secure any peripheral parts of the species’ distribution. As a consequence, it may miss out on populations with novel adaptations to environmental conditions along the species’ range margin.

Now, let’s generate an amount-based target for the bimodally distributed species view it.

# create new object with just the bimodal species
sim_ru_s3 <- spp.subset(sim_ru, "bimodal")
# update amount targets to 20% and space targets to 0% and solve it
sim_rs_s3_amount <- update(sim_ru_s3, amount.target = 0.2,
                           space.target = NA, Threads = threads)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Optimize a model with 1 rows, 100 columns and 100 nonzeros
## Variable types: 0 continuous, 100 integer (100 binary)
## Coefficient statistics:
##   Matrix range     [7e-03, 9e-01]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [7e+00, 7e+00]
## Found heuristic solution: objective 21
## Presolve removed 0 rows and 75 columns
## Presolve time: 0.00s
## Presolved: 1 rows, 25 columns, 25 nonzeros
## Variable types: 0 continuous, 25 integer (0 binary)
## Presolved: 1 rows, 25 columns, 25 nonzeros
## 
## 
## Root relaxation: objective 7.919039e+00, 17 iterations, 0.00 seconds
## 
##     Nodes    |    Current Node    |     Objective Bounds      |     Work
##  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
## 
##      0     0    7.91904    0    1   21.00000    7.91904  62.3%     -    0s
## H    0     0                       8.0000000    7.91904  1.01%     -    0s
## 
## Explored 1 nodes (17 simplex iterations) in 0.01 seconds
## Thread count was 2 (of 4 available processors)
## 
## Solution count 2: 8 21 
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 8.000000000000e+00, best bound 8.000000000000e+00, gap 0.0000%
## Warning in validityMethod(object): some species have space.held values less
## than 0, and are really poor represented
# plot the prioritization and the bimodal species' distribution
spp.plot(sim_rs_s3_amount, 1, main = "Bimodal species")
_A prioritization for the bimodally distributed species generated using amount-based targets (20\%). See Figure 3 caption for conventions._

A prioritization for the bimodally distributed species generated using amount-based targets (20%). See Figure 3 caption for conventions.

# show summary
summary(sim_rs_s3_amount)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL     8    8              8                220
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1               9               197               14
##   Connectivity_In_Fraction
## 1               0.04090909
# show amount held
amount.held(sim_rs_s3_amount)
##     bimodal
## 1 0.2018391
# show space held
space.held(sim_rs_s3_amount)
##   bimodal (Space 1)
## 1         0.1200278

The amount-based prioritization for the bimodally distributed species only selects planning units in the bottom left corner of the study area. This prioritization only preserves individuals belonging to one of the two ecotypes. As a consequence, this prioritization may fail to preserve a representative sample of the genetic variation found inside this species.

Amount-based and space-based targets

Now that we have generated a prioritization for each species using only amount-based targets, we will generate a prioritizations using both amount-based and space-targets. To do this we will update the space targets in our amount-based prioritizations to 85%, and store the new prioritizations in new objects.

First, let’s do this for the uniform species.

# make new prioritization
sim_rs_s1_space <- update(sim_rs_s1_amount, amount.target = 0.2,
                          space.target = 0.85, Threads = threads)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Warning for adding variables: zero or small (< 1e-13) coefficients, ignored
## Optimize a model with 10102 rows, 10100 columns and 40000 nonzeros
## Variable types: 0 continuous, 10100 integer (10100 binary)
## Coefficient statistics:
##   Matrix range     [5e-01, 8e+01]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [1e+00, 1e+02]
## Found heuristic solution: objective 95
## Presolve removed 31 rows and 0 columns (presolve time = 5s) ...
## Presolve removed 36 rows and 0 columns
## Presolve time: 6.31s
## Presolved: 10066 rows, 10100 columns, 40104 nonzeros
## Variable types: 0 continuous, 10100 integer (10100 binary)
## Presolved: 10066 rows, 10100 columns, 40104 nonzeros
## 
## Presolve removed 10066 rows and 10100 columns
## 
## Root simplex log...
## 
## Iteration    Objective       Primal Inf.    Dual Inf.      Time
##        0    1.0000000e+02   0.000000e+00   1.000000e+02      7s
##      621    2.0000000e+01   0.000000e+00   0.000000e+00      7s
##      621    2.0000000e+01   0.000000e+00   0.000000e+00      7s
## 
## Root relaxation: objective 2.000000e+01, 621 iterations, 0.26 seconds
## 
##     Nodes    |    Current Node    |     Objective Bounds      |     Work
##  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
## 
## *    0     0               0      20.0000000   20.00000  0.00%     -    6s
## 
## Explored 0 nodes (1587 simplex iterations) in 6.84 seconds
## Thread count was 2 (of 4 available processors)
## 
## Solution count 2: 20 95 
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 2.000000000000e+01, best bound 2.000000000000e+01, gap 0.0000%
## Warning in validityMethod(object): some species have space.held values less
## than 0, and are really poor represented
# show summary
summary(sim_rs_s1_space)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL    20   20             20                220
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1              11               143               66
##   Connectivity_In_Fraction
## 1                     0.05
# show amount held
amount.held(sim_rs_s1_space)
##   uniform
## 1     0.2
# show space held
space.held(sim_rs_s1_space)
##   uniform (Space 1)
## 1         0.9206061

Let’s take a look at the prioritization for the uniform species with amount-based and space-based targets. Then, let’s compare the solutions for the amount-based prioritization with the new prioritization using both amount and space targets.

# plot the prioritization and the uniform species' distribution
spp.plot(sim_rs_s1_space, "uniform", main = "Uniform species")
_A prioritization for the uniformly distributed species generated using amount-based targets (20\%) and space-based targets (85\%). See Figure 3 caption for conventions._

A prioritization for the uniformly distributed species generated using amount-based targets (20%) and space-based targets (85%). See Figure 3 caption for conventions.

# plot the difference between old and new prioritizations
plot(sim_rs_s1_amount, sim_rs_s1_space, 1, 1,
     main = "Difference between solutions")
_Difference between two prioritizations for the uniformly distributed species. Prioritisation $X$ was generated using just amount-based targets (20\%), and prioritization $Y$ was generated using an additional space-based target (85\%)._

Difference between two prioritizations for the uniformly distributed species. Prioritisation \(X\) was generated using just amount-based targets (20%), and prioritization \(Y\) was generated using an additional space-based target (85%).

Here we can see that by including a space-target, the prioritization is spread out evenly across the species’ distribution. Unlike the amount-based prioritization, this prioritization samples all the different parts of the species’ distribution.

Now, let’s generate a prioritization for the normally distributed species that considers amount-based and space-based targets. Then, let’s visualize the new prioritization and compare it to the old amount-based prioritization.

# make new prioritization
sim_rs_s2_space <- update(sim_rs_s2_amount, amount.target = 0.2,
                          space.target = 0.85, Threads = threads)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Warning for adding variables: zero or small (< 1e-13) coefficients, ignored
## Optimize a model with 10102 rows, 10100 columns and 40000 nonzeros
## Variable types: 0 continuous, 10100 integer (10100 binary)
## Coefficient statistics:
##   Matrix range     [7e-02, 4e+01]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [1e+00, 6e+01]
## Found heuristic solution: objective 91
## Presolve removed 220 rows and 0 columns
## Presolve time: 4.42s
## Presolved: 9882 rows, 10100 columns, 41664 nonzeros
## Variable types: 0 continuous, 10100 integer (10100 binary)
## Presolved: 9882 rows, 10100 columns, 41664 nonzeros
## 
## Presolve removed 9882 rows and 10100 columns
## 
## Root simplex log...
## 
## Iteration    Objective       Primal Inf.    Dual Inf.      Time
##     2580    1.3878213e+01   0.000000e+00   3.015458e+02      5s
##     4165    1.2325699e+01   0.000000e+00   0.000000e+00      5s
##     4165    1.2325699e+01   0.000000e+00   0.000000e+00      5s
## 
## Root relaxation: objective 1.232570e+01, 4165 iterations, 0.81 seconds
## 
##     Nodes    |    Current Node    |     Objective Bounds      |     Work
##  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
## 
##      0     0   12.32570    0  290   91.00000   12.32570  86.5%     -    5s
## H    0     0                      13.0000000   12.32570  5.19%     -    5s
## 
## Explored 1 nodes (4528 simplex iterations) in 5.84 seconds
## Thread count was 2 (of 4 available processors)
## 
## Solution count 2: 13 91 
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 1.300000000000e+01, best bound 1.300000000000e+01, gap 0.0000%
## Warning in validityMethod(object): some species have space.held values less
## than 0, and are really poor represented
# show summary
summary(sim_rs_s2_space)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL    13   13             13                220
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1               6               174               40
##   Connectivity_In_Fraction
## 1               0.02727273
# show amount held
amount.held(sim_rs_s2_space)
##      normal
## 1 0.2042594
# show space held
space.held(sim_rs_s2_space)
##   normal (Space 1)
## 1        0.8517463
# plot the prioritization and the normal species' distribution
spp.plot(sim_rs_s2_space, "normal", main = "Normal species")
_A prioritization for the normally distributed species generated using amount-based targets (20\%) and space-based targets (85\%). See Figure 3 caption for conventions._

A prioritization for the normally distributed species generated using amount-based targets (20%) and space-based targets (85%). See Figure 3 caption for conventions.

# plot the difference between old and new prioritizations
plot(sim_rs_s2_amount, sim_rs_s2_space, 1, 1,
     main = "Difference between solutions")
_Difference between two prioritizations for the normally distributed species. See Figure 7 caption for conventions._

Difference between two prioritizations for the normally distributed species. See Figure 7 caption for conventions.

We can see by using both amount-based and space-based targets we can obtain a prioritization that secures both the species’ range core and parts of its range margin. As a consequence, it may capture any novel adaptations found along the species’ range margin–unlike the amount-based prioritization.

Finally, let’s generate a prioritization for the bimodal species using amount-based and space-based targets.

# make new prioritization
sim_rs_s3_space <- update(sim_rs_s3_amount, amount.target = 0.2,
                          space.target = 0.85, Threads = threads)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Warning for adding variables: zero or small (< 1e-13) coefficients, ignored
## Optimize a model with 10102 rows, 10100 columns and 40000 nonzeros
## Variable types: 0 continuous, 10100 integer (10100 binary)
## Coefficient statistics:
##   Matrix range     [7e-03, 9e+01]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [1e+00, 7e+01]
## Found heuristic solution: objective 87
## Presolve removed 552 rows and 15 columns (presolve time = 5s) ...
## Presolve removed 589 rows and 15 columns
## Presolve time: 8.73s
## Presolved: 9513 rows, 10085 columns, 51461 nonzeros
## Variable types: 0 continuous, 10085 integer (10085 binary)
## Presolved: 9513 rows, 10085 columns, 51461 nonzeros
## 
## Presolve removed 9513 rows and 10085 columns
## 
## Root simplex log...
## 
## Iteration    Objective       Primal Inf.    Dual Inf.      Time
##        0    1.0000000e+02   0.000000e+00   1.000000e+02      9s
##     5690    8.9807917e+00   0.000000e+00   0.000000e+00     10s
##     5690    8.9807917e+00   0.000000e+00   0.000000e+00     10s
## 
## Root relaxation: objective 8.980792e+00, 5690 iterations, 0.93 seconds
## 
##     Nodes    |    Current Node    |     Objective Bounds      |     Work
##  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
## 
##      0     0    8.98079    0   75   87.00000    8.98079  89.7%     -    9s
## H    0     0                      10.0000000    8.98079  10.2%     -   10s
##      0     0     cutoff    0        10.00000   10.00000  0.00%     -   10s
## 
## Cutting planes:
##   Gomory: 1
##   MIR: 1
##   Zero half: 1
## 
## Explored 1 nodes (5889 simplex iterations) in 10.30 seconds
## Thread count was 2 (of 4 available processors)
## 
## Solution count 2: 10 87 
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 1.000000000000e+01, best bound 1.000000000000e+01, gap 0.0000%
## Warning in validityMethod(object): some species have space.held values less
## than 0, and are really poor represented
# show summary
summary(sim_rs_s3_space)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL    10   10             10                220
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1               7               187               26
##   Connectivity_In_Fraction
## 1               0.03181818
# show amount held
amount.held(sim_rs_s3_space)
##     bimodal
## 1 0.2226414
# show space held
space.held(sim_rs_s3_space)
##   bimodal (Space 1)
## 1         0.8562891
# plot the prioritization and the bimodal species' distribution
spp.plot(sim_rs_s3_space, 'bimodal', main='Bimodal species')
_A prioritization for the normally distributed species generated using amount-based targets (20\%) and space-based targets (85\%). See Figure 3 caption for conventions._

A prioritization for the normally distributed species generated using amount-based targets (20%) and space-based targets (85%). See Figure 3 caption for conventions.

# plot the difference between old and new prioritizations
plot(sim_rs_s3_amount, sim_rs_s3_space, 1, 1,
     main = "Difference between solutions")
_Difference between two prioritizations for the bimodally distributed species. See Figure 7 caption for conventions._

Difference between two prioritizations for the bimodally distributed species. See Figure 7 caption for conventions.

Earlier we found that the amount-based prioritization only preserved individuals from a single ecotype, and would have failed to adequately preserve the intra-specific variation for this species. However, here we can see that by including space-based targets, we can develop prioritizations that secure individuals belonging to both ecotypes. This new prioritization is much more effective at sampling the intra-specific variation for this species.

Overall, these results demonstrate that under the simplest of conditions, the use of space-based targets can improve prioritizations. However, these prioritizations were each generated for a single species. Prioritizations generated using multiple species may do a better job at preserving the intra-specific variation for individuals species by preserving them in different parts of their range. We will investigate this in the next section.

Multi-species prioritizations

Effects of including space-based targets

So far we have generated prioritizations using only a single species at a time. However, real world prioritizations are often generated using multiple species to ensure that they preserve a comprehensive set of biodiversity. Here, we will generate multi-species prioritizations that preserve all three of the simulated species. First, we will generate a prioritization using amount-based targets that only aims to preserve 20% of the area they occupy. Then, we will generate a prioritization that also incorporate space-based targets to also preserve 85% of their geographic distribution. We will then compare the two prioritizations.

# make prioritizations
sim_mrs_amount <- update(sim_ru, amount.target = c(0.2, 0.2, 0.2),
                         space.target = c(0, 0, 0), Threads = threads)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Warning for adding variables: zero or small (< 1e-13) coefficients, ignored
## Optimize a model with 30306 rows, 30100 columns and 120000 nonzeros
## Variable types: 0 continuous, 30100 integer (30100 binary)
## Coefficient statistics:
##   Matrix range     [7e-03, 9e+01]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [1e+00, 8e+02]
## Found heuristic solution: objective 98
## Presolve time: 4.24s
## Presolved: 30306 rows, 30100 columns, 120000 nonzeros
## Variable types: 0 continuous, 30100 integer (30100 binary)
## Presolved: 30306 rows, 30100 columns, 120000 nonzeros
## 
## Presolve removed 30306 rows and 30100 columns
## 
## Root simplex log...
## 
## Iteration    Objective       Primal Inf.    Dual Inf.      Time
##        0    1.0000000e+02   0.000000e+00   1.000000e+02      5s
##     2464    2.0000000e+01   0.000000e+00   0.000000e+00      8s
##     2464    2.0000000e+01   0.000000e+00   0.000000e+00      8s
## 
## Root relaxation: objective 2.000000e+01, 2464 iterations, 3.58 seconds
## 
##     Nodes    |    Current Node    |     Objective Bounds      |     Work
##  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
## 
## *    0     0               0      20.0000000   20.00000  0.00%     -    9s
## 
## Explored 0 nodes (6504 simplex iterations) in 9.96 seconds
## Thread count was 2 (of 4 available processors)
## 
## Solution count 2: 20 98 
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 2.000000000000e+01, best bound 2.000000000000e+01, gap 0.0000%
## Warning in validityMethod(object): some species have space.held values less
## than 0, and are really poor represented
sim_mrs_space <- update(sim_ru, amount.target = c(0.2, 0.2, 0.2),
                        space.target = c(0.85, 0.85, 0.85),
                        Threads = threads)
## The rgorubi R package is not installed
## 
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Warning for adding variables: zero or small (< 1e-13) coefficients, ignored
## Optimize a model with 30306 rows, 30100 columns and 120000 nonzeros
## Variable types: 0 continuous, 30100 integer (30100 binary)
## Coefficient statistics:
##   Matrix range     [7e-03, 9e+01]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [1e+00, 1e+02]
## Found heuristic solution: objective 99
## Presolve removed 124 rows and 15 columns (presolve time = 5s) ...
## Presolve removed 265 rows and 15 columns (presolve time = 10s) ...
## Presolve removed 271 rows and 15 columns (presolve time = 15s) ...
## Presolve removed 360 rows and 15 columns (presolve time = 20s) ...
## Presolve removed 360 rows and 15 columns
## Presolve time: 21.27s
## Presolved: 29946 rows, 30085 columns, 131504 nonzeros
## Variable types: 0 continuous, 30085 integer (30085 binary)
## Presolve removed 67 rows and 1 columns
## Presolved: 29879 rows, 30084 columns, 127194 nonzeros
## 
## Presolve removed 29879 rows and 30084 columns
## 
## Root simplex log...
## 
## Iteration    Objective       Primal Inf.    Dual Inf.      Time
##        0    1.0000000e+02   0.000000e+00   1.000000e+02     24s
##     2768    3.0505401e+01   0.000000e+00   9.958621e+03     25s
##     5715    2.0000000e+01   0.000000e+00   0.000000e+00     28s
##     5715    2.0000000e+01   0.000000e+00   0.000000e+00     28s
## 
## Root relaxation: objective 2.000000e+01, 5715 iterations, 6.23 seconds
## Total elapsed time = 30.11s
## 
##     Nodes    |    Current Node    |     Objective Bounds      |     Work
##  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
## 
## *    0     0               0      20.0000000   20.00000  0.00%     -   30s
## 
## Explored 0 nodes (11023 simplex iterations) in 30.22 seconds
## Thread count was 2 (of 4 available processors)
## 
## Solution count 2: 20 99 
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 2.000000000000e+01, best bound 2.000000000000e+01, gap 0.0000%
## Warning in validityMethod(object): some species have space.held values less
## than 0, and are really poor represented
# show summaries
summary(sim_mrs_amount)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL    20   20             20                220
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1               9               144               67
##   Connectivity_In_Fraction
## 1               0.04090909
summary(sim_mrs_space)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL    20   20             20                220
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1               8               141               71
##   Connectivity_In_Fraction
## 1               0.03636364
# show amount held for each prioritization
amount.held(sim_mrs_amount)
##   uniform    normal  bimodal
## 1     0.2 0.2265352 0.278574
amount.held(sim_mrs_space)
##   uniform    normal   bimodal
## 1     0.2 0.2038885 0.2214711
# show space held for each prioritization
space.held(sim_mrs_amount)
##   uniform (Space 1) normal (Space 1) bimodal (Space 1)
## 1         0.9042424        0.8799987         0.9255109
space.held(sim_mrs_space)
##   uniform (Space 1) normal (Space 1) bimodal (Space 1)
## 1         0.9363636        0.9123203         0.9311194
# plot multi-species prioritization with amount-based targets
plot(sim_mrs_amount, 1, main = "Amount-based targets")
_A multi-species prioritization for the uniformly, normally, and bimodally distributed species generated using just amount-based targets (20\%). Squares represent planning units. Dark green planning units are selected for preservation._

A multi-species prioritization for the uniformly, normally, and bimodally distributed species generated using just amount-based targets (20%). Squares represent planning units. Dark green planning units are selected for preservation.

# plot multi-species prioritization with amount- and space-based targets
plot(sim_mrs_space, 1, main = "Amount and space-based targets")
_A multi-species prioritization for the uniformly, normally, and bimodally distributed species generated using amount-based targets (20\%) and space-based targets (85\%). See Figure 12 caption for conventions._

A multi-species prioritization for the uniformly, normally, and bimodally distributed species generated using amount-based targets (20%) and space-based targets (85%). See Figure 12 caption for conventions.

# difference between the two prioritizations
plot(sim_mrs_amount, sim_mrs_space, 1, 1, main = "Difference between solutions")
_Difference between two multi-species prioritizations. See Figure 7 caption for conventions.)

_Difference between two multi-species prioritizations. See Figure 7 caption for conventions.)

Here we can see that the inclusion of space-based targets changes which planning units are selected for prioritization, but also the number of planning units that are selected. The amount-based prioritization is comprised of 20 units, and the space-based prioritization is comprised of 20 units. This result suggests that an adequate and representative prioritization can be achieved for only a minor increase in cost.

Uncertainty in species’ distributions

The unreliable formulation does not consider the probability that the planning units are occupied by features when calculating how well a given solution secures a representative sample of an attribute space. Thus solutions identified using the unreliable formulation may select regions of an attribute space for a species using planning units that only have a small chance of being inhabited. As a consequence, if the prioritization is implemented, it may fail to secure regions of an attribute space if individuals do not inhabit these planning units, and ultimately fail to fulfill the space-based targets.

A simple solution to this issue would be to ensure that planning units cannot be assigned to demand points if they have a low probability of occupancy. This can be achieved by setting a probability threshold for planning units, such that planning units with a probability of occupancy below the threshold are effectively set to zero.

# make new prioritization with probability threshold of 0.1 for each species
sim_mrs_space2 <- solve(prob.subset(sim_mrs_space, species = 1:3,
                                    threshold = c(0.1, 0.1, 0.1)),
                        Threads = threads)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Warning for adding variables: zero or small (< 1e-13) coefficients, ignored
## Optimize a model with 30306 rows, 30100 columns and 119974 nonzeros
## Variable types: 0 continuous, 30100 integer (30100 binary)
## Coefficient statistics:
##   Matrix range     [7e-03, 9e+01]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [1e+00, 1e+02]
## Found heuristic solution: objective 99
## Presolve removed 193 rows and 15 columns (presolve time = 5s) ...
## Presolve removed 267 rows and 15 columns (presolve time = 10s) ...
## Presolve removed 330 rows and 15 columns (presolve time = 15s) ...
## Presolve removed 360 rows and 15 columns
## Presolve time: 19.27s
## Presolved: 29946 rows, 30085 columns, 131478 nonzeros
## Variable types: 0 continuous, 30085 integer (30085 binary)
## Presolve removed 67 rows and 1 columns
## Presolved: 29879 rows, 30084 columns, 127168 nonzeros
## 
## Presolve removed 29879 rows and 30084 columns
## 
## Root simplex log...
## 
## Iteration    Objective       Primal Inf.    Dual Inf.      Time
##        0    1.0000000e+02   0.000000e+00   1.000000e+02     22s
##     4744    2.1438326e+01   0.000000e+00   6.386622e+03     25s
##     5682    2.0000000e+01   0.000000e+00   0.000000e+00     26s
##     5682    2.0000000e+01   0.000000e+00   0.000000e+00     26s
## 
## Root relaxation: objective 2.000000e+01, 5682 iterations, 7.12 seconds
## 
##     Nodes    |    Current Node    |     Objective Bounds      |     Work
##  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
## 
## *    0     0               0      20.0000000   20.00000  0.00%     -   26s
## 
## Explored 0 nodes (6073 simplex iterations) in 26.88 seconds
## Thread count was 2 (of 4 available processors)
## 
## Solution count 2: 20 99 
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 2.000000000000e+01, best bound 2.000000000000e+01, gap 0.0000%
## Warning in validityMethod(object): some species have space.held values less
## than 0, and are really poor represented
# show summary
summary(sim_mrs_space2)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL    20   20             20                220
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1               7               141               72
##   Connectivity_In_Fraction
## 1               0.03181818
# plot prioritization
plot(sim_mrs_space2, 1)
_A multi-species prioritization for the uniformly, normally, and bimodally distributed species generated using amount-based targets (20\%) and space-based targets (85\%). This prioritization was generated to be robust against low occupancy probabilities, by preventing planning units with low probabilities from being used to represent demand points. See Figure 12 caption for conventions._

A multi-species prioritization for the uniformly, normally, and bimodally distributed species generated using amount-based targets (20%) and space-based targets (85%). This prioritization was generated to be robust against low occupancy probabilities, by preventing planning units with low probabilities from being used to represent demand points. See Figure 12 caption for conventions.

# difference between prioritizations that use and do not use thresholds
plot(sim_mrs_space2, sim_mrs_space, 1, 1, main = "Difference between solutions")
_Difference between two multi-species prioritizations. See Figure 7 caption for conventions._

Difference between two multi-species prioritizations. See Figure 7 caption for conventions.

But this method requires setting somewhat arbitrary thresholds. A more robust solution to this issue is to actually use the probability that species occupy planning units to generate the prioritizations. This is what the reliable formulation does. First we will try and generate a solution using existing targets and the reliable formulation. To reduce computational time, we will set the maximum backup \(R\)-level to 1.

# make new prioritization using reliable formulation
sim_mrs_space3 <- try(update(sim_mrs_space, formulation = "reliable",
                             max.r.level = 1L, Threads = threads))
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Warning for adding variables: zero or small (< 1e-13) coefficients, ignored
## Optimize a model with 364206 rows, 181900 columns and 3847200 nonzeros
## Variable types: 0 continuous, 60700 integer (60700 binary)
## Semi-Variable types: 121200 continuous, 0 integer
## Coefficient statistics:
##   Matrix range     [8e-04, 1e+02]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [7e-03, 1e+02]
## Presolve removed 338600 rows and 156700 columns (presolve time = 5s) ...
## Presolve removed 338606 rows and 156703 columns
## Presolve time: 7.05s
## 
## Explored 0 nodes (0 simplex iterations) in 8.48 seconds
## Thread count was 1 (of 4 available processors)
## 
## Solution count 0
## 
## Model is infeasible
## Best objective -, best bound -, gap -

However, this fails. The reason why we cannot generate a prioritization that fulfills these targets is because even the solution that contains all the planning units is still insufficient when we consider probabilities. The negative maximum targets printed in the error message indicate that planning units have low probabilities of occupancy. To fulfill the targets, we must obtain more planning units with higher probabilities of occupancy. We also could attempt resolving the problem using a higher \(R\)-level. Instead, we will set lower targets and generate solution.

# make new prioritization using reliable formulation and reduced targets
sim_mrs_space3 <- update(sim_mrs_space, formulation = "reliable",
                         max.r.level = 1L, space.target = -1000,
                         Threads = threads)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Warning for adding variables: zero or small (< 1e-13) coefficients, ignored
## Optimize a model with 364206 rows, 181900 columns and 3847200 nonzeros
## Variable types: 0 continuous, 60700 integer (60700 binary)
## Semi-Variable types: 121200 continuous, 0 integer
## Coefficient statistics:
##   Matrix range     [8e-04, 1e+02]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [7e-03, 8e+05]
## Presolve removed 311803 rows and 130000 columns (presolve time = 5s) ...
## Presolve removed 333703 rows and 151600 columns (presolve time = 10s) ...
## Presolve removed 333903 rows and 151800 columns (presolve time = 15s) ...
## Presolve removed 333903 rows and 151800 columns
## Presolve time: 18.35s
## Presolved: 30303 rows, 30100 columns, 90300 nonzeros
## Variable types: 0 continuous, 30100 integer (30100 binary)
## Found heuristic solution: objective 27.0000000
## Presolved: 30303 rows, 30100 columns, 90300 nonzeros
## 
## Presolve removed 30303 rows and 30100 columns
## 
## Root simplex log...
## 
## Iteration    Objective       Primal Inf.    Dual Inf.      Time
##        0    1.0000000e+02   0.000000e+00   1.000000e+02     21s
##      129    2.0000000e+01   0.000000e+00   0.000000e+00     21s
##      129    2.0000000e+01   0.000000e+00   0.000000e+00     21s
## 
## Root relaxation: objective 2.000000e+01, 129 iterations, 1.16 seconds
## 
##     Nodes    |    Current Node    |     Objective Bounds      |     Work
##  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
## 
## *    0     0               0      20.0000000   20.00000  0.00%     -   21s
## 
## Explored 0 nodes (182 simplex iterations) in 21.31 seconds
## Thread count was 2 (of 4 available processors)
## 
## Solution count 2: 20 27 
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 2.000000000000e+01, best bound 2.000000000000e+01, gap 0.0000%
# show summary
summary(sim_mrs_space3)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL    20   20             20                220
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1              20               156               44
##   Connectivity_In_Fraction
## 1               0.09090909
# plot prioritization
plot(sim_mrs_space3, 1)
_A multi-species prioritization for the uniformly, normally, and bimodally distributed species generated using amount-based targets (20\%) and space-based targets (85\%). This prioritization was generated to be robust against low occupancy probabilities, by explicitly using the probability of occupancy data when deriving a solution. See Figure 12 caption for conventions._

A multi-species prioritization for the uniformly, normally, and bimodally distributed species generated using amount-based targets (20%) and space-based targets (85%). This prioritization was generated to be robust against low occupancy probabilities, by explicitly using the probability of occupancy data when deriving a solution. See Figure 12 caption for conventions.

# difference between prioritizations based on unreliable and reliable formulation
plot(sim_mrs_space3, sim_mrs_space, 1, 1, main = "Difference between solutions")
_Difference between two multi-species prioritizations. See Figure 7 caption for conventions._

Difference between two multi-species prioritizations. See Figure 7 caption for conventions.

An additional planning unit was selected using the reliable formulation. The prioritization based on the unreliable formulation had 20 planning units, but the prioritization based on the reliable formulation has 20 planning units. This difference occurs because the reliable formulation needs to ensure that all selected planning units with a low chance of being occupied have a suitable backup planning unit. While the reliable formulation can deliver more robust prioritizations, it takes much longer to solve conservation planning problems expressed using this formulation than the unreliable formulation. As a consequence, the reliable formulation is only feasible for particularly small problems, such as those involving few features and less than several hundred planning units.

Fragmentation

Fragmentation is an important consideration in real-world planning situations. Up until now, we haven’t considered the effects of fragmentation on the viability of the prioritization. As a consequence, our prioritizations have tended to contain planning units without any neighbors. We can use the BLM parameter to penalize fragmented solutions.

Let’s generate a new prioritization that heavily penalises fragmentation. Here, we will update the sim_mrs_amount object with BLM of 100.

# update prioritization
sim_mrs_amount_blm <- update(sim_mrs_amount, BLM = 100, Threads = threads)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Warning for adding variables: zero or small (< 1e-13) coefficients, ignored
## Optimize a model with 30666 rows, 30280 columns and 120720 nonzeros
## Variable types: 0 continuous, 30280 integer (30280 binary)
## Coefficient statistics:
##   Matrix range     [7e-03, 9e+01]
##   Objective range  [1e+02, 4e+02]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [1e+00, 8e+02]
## Found heuristic solution: objective 4498
## Presolve time: 4.22s
## Presolved: 30666 rows, 30280 columns, 120720 nonzeros
## Variable types: 0 continuous, 30280 integer (30280 binary)
## Presolved: 30666 rows, 30280 columns, 120720 nonzeros
## 
## Presolve removed 30666 rows and 30280 columns
## 
## Root simplex log...
## 
## Iteration    Objective       Primal Inf.    Dual Inf.      Time
##        0    2.2100000e+04   0.000000e+00   4.010000e+04      5s
##     5033    7.0585765e+02   0.000000e+00   1.059519e+06     10s
##     7759    4.6444444e+02   0.000000e+00   0.000000e+00     14s
##     7759    4.6444444e+02   0.000000e+00   0.000000e+00     14s
## 
## Root relaxation: objective 4.644444e+02, 7759 iterations, 10.13 seconds
## 
##     Nodes    |    Current Node    |     Objective Bounds      |     Work
##  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
## 
##      0     0  464.44444    0 1725 4498.00000  464.44444  89.7%     -   14s
## H    0     0                    2242.0000000  464.44444  79.3%     -   53s
##      0     0  515.39560    0 1776 2242.00000  515.39560  77.0%     -   56s
##      0     0  555.31166    0 1654 2242.00000  555.31166  75.2%     -   60s
##      0     0  555.31166    0 1660 2242.00000  555.31166  75.2%     -   60s
##      0     0  555.31166    0 1678 2242.00000  555.31166  75.2%     -   62s
##      0     0  555.31166    0 1679 2242.00000  555.31166  75.2%     -   62s
##      0     0  555.31166    0 1552 2242.00000  555.31166  75.2%     -   66s
##      0     0  555.31166    0 1553 2242.00000  555.31166  75.2%     -   67s
##      0     0  555.31166    0 1533 2242.00000  555.31166  75.2%     -   70s
##      0     0  558.17064    0 1477 2242.00000  558.17064  75.1%     -   71s
##      0     0  558.17064    0 1470 2242.00000  558.17064  75.1%     -   74s
## H    0     0                    1535.0000000  558.17064  63.6%     -   88s
##      0     0  558.17064    0 1472 1535.00000  558.17064  63.6%     -   88s
##      0     0  558.17064    0 1561 1535.00000  558.17064  63.6%     -   89s
##      0     0  558.17064    0 1611 1535.00000  558.17064  63.6%     -   90s
##      0     0  558.17064    0 1493 1535.00000  558.17064  63.6%     -   94s
##      0     0  558.17064    0 1495 1535.00000  558.17064  63.6%     -  105s
##      0     0  558.17064    0 1485 1535.00000  558.17064  63.6%     -  108s
##      0     0  558.17064    0 1490 1535.00000  558.17064  63.6%     -  116s
##      0     0  558.17064    0 1500 1535.00000  558.17064  63.6%     -  119s
##      0     0  558.17064    0 1479 1535.00000  558.17064  63.6%     -  120s
## H    0     2                    1435.0000000  558.17064  61.1%     -  140s
##      0     2  558.17064    0 1474 1435.00000  558.17064  61.1%     -  140s
##      7     8  678.98618    4 1039 1435.00000  584.51018  59.3%  1644  145s
##     25    26  877.14286   14  692 1435.00000  584.51018  59.3%  1300  150s
## *   34    30              18     920.0000000  584.51018  36.5%  1247  151s
##     47    34  795.00000    5 1340  920.00000  609.93723  33.7%  1160  155s
##     71    43  918.52941   10 1292  920.00000  660.00000  28.3%   962  160s
##     92    43     cutoff    8       920.00000  710.69767  22.8%   954  165s
##    141    54  876.86275   12  909  920.00000  710.90909  22.7%   854  170s
##    183    65  897.99767    5 1504  920.00000  728.57143  20.8%   834  176s
##    210    58  890.42254    5 1209  920.00000  762.85714  17.1%   829  180s
##    269    61  879.45946    7 1506  920.00000  788.33333  14.3%   782  186s
##    313    57  869.70990    5 1247  920.00000  807.09677  12.3%   765  191s
##    360    42     cutoff    8       920.00000  820.00000  10.9%   726  195s
##    402    17     cutoff    8       920.00000  840.00000  8.70%   715  200s
## 
## Cutting planes:
##   Gomory: 3
##   Zero half: 29
## 
## Explored 438 nodes (384090 simplex iterations) in 200.19 seconds
## Thread count was 2 (of 4 available processors)
## 
## Solution count 5: 920 1435 1535 ... 4498
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 9.200000000000e+02, best bound 8.440000000000e+02, gap 8.2609%
## Warning in validityMethod(object): some species have space.held values less
## than 0, and are really poor represented
# show summary of prioritization
summary(sim_mrs_amount_blm)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL   920   20             20                220
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1              35               171               14
##   Connectivity_In_Fraction
## 1                0.1590909
# show amount held for each prioritization
amount.held(sim_mrs_amount_blm)
##   uniform    normal   bimodal
## 1     0.2 0.2272838 0.4224767
# show space held for each prioritization
space.held(sim_mrs_amount_blm)
##   uniform (Space 1) normal (Space 1) bimodal (Space 1)
## 1         0.3272727        0.2964415         0.4715976
# plot prioritization
plot(sim_mrs_amount_blm, 1)
_A multi-species prioritization for the uniformly, normally, and bimodally distributed species generated using only amount-based targets (20\%). Additionally, this prioritization was specified to have high connectivity, by using a high $BLM$ parameter. See Figure 12 caption for conventions._

A multi-species prioritization for the uniformly, normally, and bimodally distributed species generated using only amount-based targets (20%). Additionally, this prioritization was specified to have high connectivity, by using a high \(BLM\) parameter. See Figure 12 caption for conventions.

# difference between the two prioritizations
plot(sim_mrs_amount_blm, sim_mrs_amount, 1, 1,
     main = "Difference between solutions")
_Difference between two multi-species prioritizations. See Figure 7 caption for conventions._

Difference between two multi-species prioritizations. See Figure 7 caption for conventions.

Here we can see that the prioritization generated using a BLM parameter of 100 is much more clustered than the prioritization generated using a BLM of 0. In practice, conservation planners will need to try a variety of BLM parameters to find a suitable prioritization.

Case-study examples

Introduction

Here we will investigate how space-based targets can affect prioritizations using a more realistic dataset. We will generate prioritizations for the four bird species—blue-winged kookaburra, brown-backed honeyeater, brown falcon, pale-headed rosella—in Queensland, Australia. This region contains a broad range of different habitats—such as rainforests, woodlands, and deserts—making it ideal for this tutorial. First, we will generate a typical amount-based prioritization that aims to capture 20% of the species’ distributions. Then we will generate a prioritization that also aims to secure populations in representative parts of the species’ distributions in terms of their geographic location and their environmental heterogeneity. To do this we will generate a prioritization using 20% amount-based targets and 85% space-based targets. Finally, we will compare these prioritizations to Australia’s existing protected network.

Data

Survey data for the species were obtained from BirdLife Australia. The survey data was rarefied using a 100 km\(^2\) grid, wherein the survey with the greatest number of repeat visits in each grid cell was chosen. To model the distribution of each species, environmental data were obtained at survey location (site). Specifically, climatic data (bio1, bio4, bio15, bio16, bio17) and classifications of the vegetation at the site were used. Occupancy-detection models were fit using Stan using manually tuned parameters (adapt deta=0.9, maximum treedepth=20, chains=4 , warmup iterations=1000, total iterations=1500) with five-fold cross-validation. In each replicate, data were partitioned into training and test sites. A full model was fit using quadratic terms for environmental variables in the site-component, and an intercept in the detection-component of the model. The full model was then subject to a step-wise backwards term deletion routine. Terms were retained when their inclusion resulted in a model with a greater area under the curve (AUC) value as calculated using the test data. Maps were generated for each species as an average of the predictions from the best model in each best replicate. To further improve the accuracy of these maps, areas well outside of the species’ known distributions were set to 0. For each species, this was achieved by masking out biogeographic regions where the species was not observed, and regions that did not have a neighboring planning unit where the species was observed. The maps were then resampled (10 km\(^2\) resolution) and cropped to the study area. The resulting maps are stored in the cs_spp object.

# load data
data(cs_spp)

# remove areas with low occupancy (prob < 0.6)
cs_spp[cs_spp < 0.6] <- NA

# plot species' distributions
plot(cs_spp, main = c("Blue-winged kookaburra", "Brown-backed honeyeater",
                      "Brown falcon", "Pale-headed rosella"))
_Distribution map for four Australian bird species. Pixel colours denote probability of occupancy._

Distribution map for four Australian bird species. Pixel colours denote probability of occupancy.

Planning units (50km\(^2\) resolution) were generated across Australia, and then clipped to the Queensland state borders and coastline. Note that we are using excessively coarse planning units so that our examples will complete relatively quickly. In a real-world planning exercise, we would use much finer planning units. To compare our prioritizations to Queensland’s existing protected area network, this network was intersected with the planning units. Planning units with more than 50% of their area inside a protected area had their status set to 2 (following conventions in Marxan). Since we do not have cost data, the prioritizations will aim to select the minimum number of planning units required to meet the targets. The planning units are stored in the cs_pu object.

# load data
data(cs_pus)

## plot planning units
# convert SpatialPolygons to PolySet for quick plotting
cs_pus2 <- SpatialPolygons2PolySet(cs_pus)

# create vector of colours for planning units
# + light green: units not already inside reserve
# + yellow: units already inside reserve
cs_pus_cols <- rep("#c7e9c0", nrow(cs_pus@data))
cs_pus_cols[which(cs_pus$status == 2)] <- "yellow"

# set plotting window
par(mar = c(0.1, 0.1, 4.1, 0.1))

# plot polygons
PBSmapping::plotPolys(cs_pus2, col = cs_pus_cols, border = "gray30",
                      xlab = "", ylab = "", axes = FALSE,
                      main = "Case-study planning units", cex = 1.8)
_Planning units for the case-study examples. Polygons denote planning units. Yellow units have more than 50\% of their area already in a reserve.)

_Planning units for the case-study examples. Polygons denote planning units. Yellow units have more than 50% of their area already in a reserve.)

# reset plotting window
par(mar = c(5.1, 4.1, 4.1, 2.1))

To map the distribution of environmental conditions across the species’ range, 21 bioclimatic layers were obtained. These layers were cropped to Australia and subject to detrended correspondence analysis to produce two new variables. These layers are stored in the cs_space object.

# load data
data(cs_space)

# plot variables
plot(cs_space, main = c("DC1", "DC2"), legend = FALSE, axes = FALSE)
_Broad-scale environmental variation across Australia. The variable DC1 describes the transition from wet and cool to dry and hot conditions. The variable DC2 describes the transition from wet and hot to dry and cool conditions._

Broad-scale environmental variation across Australia. The variable DC1 describes the transition from wet and cool to dry and hot conditions. The variable DC2 describes the transition from wet and hot to dry and cool conditions.

Analysis

To simplify the process of formatting data and generating prioritizations, we can use the rap function. First, we will generate an amount-based prioritization that aims to capture 10% of the rosella’s range. We will use 50 demand points to map the geographic and environmental spaces. Be warned, the examples hereafter can take 5-10 minutes to run.

# make amount-based prioritization
# and ignore existing protected areas by discarding values in the
# status (third) column of the attribute table
cs_rs_amount <- rap(cs_pus[, -2], cs_spp, cs_space, amount.target = 0.2,
                    space.target = NA, n.demand.points = 50L,
                    include.geographic.space = TRUE, formulation = "unreliable",
                    kernel.method = "ks", quantile = 0.7, solve = FALSE)
## Warning in (function (pus, species, spaces = NULL, amount.target = 0.2, :
## argument to pus does not have a "status" column, setting all planning unit
## statuses to 0.
# generate prioritization
cs_rs_amount <- solve(cs_rs_amount, MIPGap = 0.1, Threads = threads)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Optimize a model with 4 rows, 762 columns and 1336 nonzeros
## Variable types: 0 continuous, 762 integer (762 binary)
## Coefficient statistics:
##   Matrix range     [4e+02, 2e+04]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [1e+05, 3e+06]
## Found heuristic solution: objective 159
## Presolve time: 0.02s
## Presolved: 4 rows, 762 columns, 1336 nonzeros
## Variable types: 0 continuous, 762 integer (762 binary)
## Presolved: 4 rows, 762 columns, 1336 nonzeros
## 
## 
## Root relaxation: objective 1.354267e+02, 734 iterations, 0.02 seconds
## 
##     Nodes    |    Current Node    |     Objective Bounds      |     Work
##  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
## 
##      0     0  135.42671    0    4  159.00000  135.42671  14.8%     -    0s
## H    0     0                     136.0000000  135.42671  0.42%     -    0s
## 
## Explored 1 nodes (734 simplex iterations) in 0.07 seconds
## Thread count was 2 (of 4 available processors)
## 
## Solution count 2: 136 159 
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 1.360000000000e+02, best bound 1.360000000000e+02, gap 0.0000%
## Warning in validityMethod(object): some species have space.held values less
## than 0, and are really poor represented
# show summary
summary(cs_rs_amount)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL   136  136            136           98882414
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1         9786021          81270163          7826230
##   Connectivity_In_Fraction
## 1               0.09896624
# plot prioritization
plot(cs_rs_amount, 1)
_Multi-species prioritization generated for four bird species using amount-based targets (20\%). See Figure 12 captions for conventions._

Multi-species prioritization generated for four bird species using amount-based targets (20%). See Figure 12 captions for conventions.

We can also see how well the prioritization secures the species’ distributions in the geographic and environmental attribute spaces.

# plot prioritization in geographic attribute space
p1 <- space.plot(cs_rs_amount, 1, 2, main = "Blue-winged\nkookaburra")
p2 <- space.plot(cs_rs_amount, 2, 2, main = "Brown-backed\nhoneyeater")
p3 <- space.plot(cs_rs_amount, 3, 2, main = "Brown falcon")
p4 <- space.plot(cs_rs_amount, 4, 2, main = "Pale-headed\nrosella")
gridExtra::grid.arrange(p1, p2, p3, p4, ncol = 2)
_Distribution of amount-based prioritization in the geographic attribute space. Points denote combinations of environmental conditions. Green and grey points represent planning unit selected for and not selected for prioritization (respectively). Blue points denote demand points, and their size indicates their weighting._

Distribution of amount-based prioritization in the geographic attribute space. Points denote combinations of environmental conditions. Green and grey points represent planning unit selected for and not selected for prioritization (respectively). Blue points denote demand points, and their size indicates their weighting.

# plot prioritization in environmental attribute space
p1 <- space.plot(cs_rs_amount, 1, 1, main = "Blue-winged\nkookaburra")
p2 <- space.plot(cs_rs_amount, 2, 1, main = "Brown-backed\nhoneyeater")
p3 <- space.plot(cs_rs_amount, 3, 1, main = "Brown falcon")
p4 <- space.plot(cs_rs_amount, 4, 1, main = "Pale-headed\nrosella")
gridExtra::grid.arrange(p1, p2, p3, p4, ncol = 2)
_Distribution of amount-based prioritization in the environmental attribute space. See Figure 28 caption for conventions._

Distribution of amount-based prioritization in the environmental attribute space. See Figure 28 caption for conventions.

Next, let’s generate a prioritization using amount- and space-based targets. This prioritization will secure 70% of the species distribution in geographic and environmental space.

# make amount- and space-based prioritization
cs_rs_space <- update(cs_rs_amount, space.target = 0.7, Threads = threads)
## The rgorubi R package is not installed
## Follow these instructions to install the "rgurobi" R package from GitHub:
##   http://bit.ly/1RF19XO
## Optimize a model with 134012 rows, 134362 columns and 535736 nonzeros
## Variable types: 0 continuous, 134362 integer (134362 binary)
## Coefficient statistics:
##   Matrix range     [1e-07, 2e+04]
##   Objective range  [1e+00, 1e+00]
##   Bounds range     [1e+00, 1e+00]
##   RHS range        [7e-01, 3e+06]
## Presolve removed 4237 rows and 4198 columns (presolve time = 5s) ...
## Presolve removed 4493 rows and 4198 columns (presolve time = 10s) ...
## Presolve removed 5035 rows and 4198 columns (presolve time = 15s) ...
## Presolve removed 5179 rows and 4198 columns (presolve time = 20s) ...
## Presolve removed 5293 rows and 4198 columns (presolve time = 25s) ...
## Presolve removed 5471 rows and 4198 columns (presolve time = 30s) ...
## Presolve removed 5602 rows and 4198 columns (presolve time = 35s) ...
## Presolve removed 5653 rows and 4198 columns (presolve time = 40s) ...
## Presolve removed 5718 rows and 4198 columns (presolve time = 45s) ...
## Presolve removed 5849 rows and 4202 columns (presolve time = 50s) ...
## Presolve removed 5849 rows and 4202 columns (presolve time = 55s) ...
## Presolve removed 5853 rows and 4202 columns (presolve time = 60s) ...
## Presolve removed 5924 rows and 4202 columns (presolve time = 65s) ...
## Presolve removed 6009 rows and 4202 columns (presolve time = 70s) ...
## Presolve removed 6059 rows and 4202 columns (presolve time = 75s) ...
## Presolve removed 6063 rows and 4202 columns (presolve time = 80s) ...
## Presolve removed 6262 rows and 4202 columns (presolve time = 85s) ...
## Presolve removed 7276 rows and 4202 columns (presolve time = 90s) ...
## Presolve removed 7790 rows and 4202 columns (presolve time = 95s) ...
## Presolve removed 8158 rows and 4202 columns (presolve time = 100s) ...
## Presolve removed 8362 rows and 4202 columns (presolve time = 105s) ...
## Presolve removed 8362 rows and 4202 columns (presolve time = 110s) ...
## Presolve removed 8472 rows and 4202 columns (presolve time = 115s) ...
## Presolve removed 8496 rows and 4202 columns (presolve time = 120s) ...
## Presolve removed 8496 rows and 4202 columns (presolve time = 125s) ...
## Presolve removed 8496 rows and 4202 columns (presolve time = 130s) ...
## Presolve removed 8499 rows and 4202 columns (presolve time = 135s) ...
## Presolve removed 8555 rows and 4202 columns (presolve time = 140s) ...
## Presolve removed 8555 rows and 4202 columns (presolve time = 145s) ...
## Presolve removed 9289 rows and 4202 columns (presolve time = 150s) ...
## Presolve removed 9853 rows and 4202 columns (presolve time = 155s) ...
## Presolve removed 9853 rows and 4202 columns (presolve time = 160s) ...
## Presolve removed 9888 rows and 4202 columns (presolve time = 165s) ...
## Presolve removed 9914 rows and 4202 columns (presolve time = 170s) ...
## Presolve removed 10041 rows and 4202 columns (presolve time = 175s) ...
## Presolve removed 10303 rows and 4202 columns (presolve time = 180s) ...
## Presolve removed 10305 rows and 4202 columns (presolve time = 185s) ...
## Presolve removed 10315 rows and 4202 columns (presolve time = 190s) ...
## Presolve removed 10315 rows and 4202 columns (presolve time = 195s) ...
## Presolve removed 10315 rows and 4202 columns (presolve time = 203s) ...
## Presolve removed 10315 rows and 4260 columns (presolve time = 225s) ...
## Presolve removed 10330 rows and 4260 columns (presolve time = 239s) ...
## Presolve removed 10330 rows and 4260 columns
## Presolve time: 238.69s
## Presolved: 123682 rows, 130102 columns, 569395 nonzeros
## Variable types: 0 continuous, 130102 integer (130102 binary)
## Found heuristic solution: objective 234.0000000
## Presolve removed 464 rows and 0 columns (presolve time = 5s) ...
## Presolve removed 464 rows and 0 columns
## Presolved: 123218 rows, 130102 columns, 567623 nonzeros
## 
## Presolve removed 104092 rows and 17312 columns
## 
## Root simplex log...
## 
## Iteration    Objective       Primal Inf.    Dual Inf.      Time
##        0    0.0000000e+00   1.230612e+02   1.557797e+10    249s
##     4574    1.4228378e+02   0.000000e+00   3.983764e+02    250s
##    15552    1.3626140e+02   0.000000e+00   1.513368e+03    255s
##    24372    1.3589302e+02   0.000000e+00   8.590940e+02    260s
##    30252    1.3570763e+02   0.000000e+00   8.974873e+01    265s
##    35544    1.3566386e+02   0.000000e+00   7.364645e+01    270s
##    40248    1.3562114e+02   0.000000e+00   1.055640e+02    275s
##    42208    1.3561855e+02   0.000000e+00   3.706944e+02    280s
##    45932    1.3560659e+02   0.000000e+00   4.279998e+01    285s
##    48088    1.3559183e+02   0.000000e+00   9.821829e+01    290s
##    50048    1.3558554e+02   0.000000e+00   1.118795e+02    295s
##    52400    1.3557375e+02   0.000000e+00   9.572379e+01    300s
##    54752    1.3556571e+02   0.000000e+00   2.030073e+01    305s
##    57888    1.3556148e+02   0.000000e+00   3.830872e+00    310s
##    60632    1.3555770e+02   0.000000e+00   1.386931e+00    316s
##    62200    1.3555724e+02   0.000000e+00   1.561330e+00    320s
##    63974    1.3555580e+02   0.000000e+00   0.000000e+00    324s
##    63974    1.3555580e+02   0.000000e+00   0.000000e+00    324s
## 
## Root relaxation: objective 1.355558e+02, 63974 iterations, 82.46 seconds
## Total elapsed time = 326.90s
## Total elapsed time = 330.24s
## 
##     Nodes    |    Current Node    |     Objective Bounds      |     Work
##  Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time
## 
##      0     0  135.55580    0  570  234.00000  135.55580  42.1%     -  330s
## H    0     0                     136.0000000  135.55580  0.33%     -  333s
## 
## Explored 1 nodes (79466 simplex iterations) in 333.11 seconds
## Thread count was 2 (of 4 available processors)
## 
## Solution count 2: 136 234 
## 
## Optimal solution found (tolerance 1.00e-01)
## Best objective 1.360000000000e+02, best bound 1.360000000000e+02, gap 0.0000%
## Warning in validityMethod(object): some species have space.held values less
## than 0, and are really poor represented
# show summary
summary(cs_rs_space)
##   Run_Number  Status Score Cost Planning_Units Connectivity_Total
## 1          1 OPTIMAL   136  136            136           98882414
##   Connectivity_In Connectivity_Edge Connectivity_Out
## 1         9411314          80869912          8601188
##   Connectivity_In_Fraction
## 1               0.09517682
# plot prioritization
plot(cs_rs_space, 1)