marxan_problem: _Marxan_ conservation problem

View source: R/marxan_problem.R

marxan_problemR Documentation

Marxan conservation problem

Description

Create a conservation planning problem() following the mathematical formulations used in Marxan (detailed in Beyer et al. 2016). Note that these problems are solved using exact algorithms and not simulated annealing (i.e., the Marxan software).

Usage

marxan_problem(x, ...)

## Default S3 method:
marxan_problem(x, ...)

## S3 method for class 'data.frame'
marxan_problem(x, spec, puvspr, bound = NULL, blm = 0, symmetric = TRUE, ...)

## S3 method for class 'character'
marxan_problem(x, ...)

Arguments

x

character file path for a Marxan input file (typically called "input.dat"), or data.frame containing planning unit data (typically called "pu.dat"). If the argument to x is a data.frame, then each row corresponds to a different planning unit, and it must have the following columns:

id

integer unique identifier for each planning unit. These identifiers are used in the argument to puvspr.

cost

numeric cost of each planning unit.

status

integer indicating if each planning unit should not be locked in the solution (0) or if it should be locked in (2) or locked out (3) of the solution. Although Marxan allows planning units to be selected in the initial solution (using values of 1), these values have no effect here. This column is optional.

...

not used.

spec

data.frame containing information on the features. The argument to spec must follow the conventions used by Marxan for the species data file (conventionally called "spec.dat"). Each row corresponds to a different feature and each column corresponds to different information about the features. It must contain the columns listed below. Note that the argument to spec must contain at least one column named "prop" or "amount"β€”but not both columns with both of these namesβ€”to specify the target for each feature.

id

integer unique identifier for each feature These identifiers are used in the argument to puvspr.

name

character name for each feature.

prop

numeric relative target for each feature (optional).

'

amount

numeric absolute target for each feature (optional).

puvspr

data.frame containing information on the amount of each feature in each planning unit. The argument to puvspr must follow the conventions used in the Marxan input data file (conventionally called "puvspr.dat"). It must contain the following columns:

pu

integer planning unit identifier.

species

integer feature identifier.

amount

numeric amount of the feature in the planning unit.

bound

NULL object indicating that no boundary data is required for the conservation planning problem, or a data.frame containing information on the planning units' boundaries. The argument to bound must follow the conventions used in the Marxan input data file (conventionally called "bound.dat"). It must contain the following columns:

id1

integer planning unit identifier.

id2

integer planning unit identifier.

boundary

numeric length of shared boundary between the planning units identified in the previous two columns.

blm

numeric boundary length modifier. This argument only has an effect when argument to x is a data.frame. The default argument is zero.

symmetric

logical does the boundary data (i.e., argument to bound) describe symmetric relationships between planning units? If the boundary data contain asymmetric connectivity data, this parameter should be set to FALSE. Defaults to TRUE.

Details

This function is provided as a convenient wrapper for solving Marxan problems using the prioritizr package. Please note that it requires installation of the data.table package to import Marxan data files.

Value

A problem() object.

Notes

In previous versions, this function could not accommodate asymmetric connectivity data. It has now been updated to handle asymmetric connectivity data.

References

Ball IR, Possingham HP, and Watts M (2009) Marxan and relatives: Software for spatial conservation prioritisation in Spatial conservation prioritisation: Quantitative methods and computational tools. Eds Moilanen A, Wilson KA, and Possingham HP. Oxford University Press, Oxford, UK.

Beyer HL, Dujardin Y, Watts ME, and Possingham HP (2016) Solving conservation planning problems with integer linear programming. Ecological Modelling, 228: 14–22.

See Also

For more information on the correct format for for Marxan input data, see the official Marxan website and Ball et al. (2009).

Examples

# create Marxan problem using Marxan input file
# (note this example requires the data.table package to be installed)
## Not run: 
input_file <- system.file("extdata/marxan/input.dat", package = "prioritizr")
p1 <-
  marxan_problem(input_file) %>%
  add_default_solver(verbose = FALSE)

# solve problem
s1 <- solve(p1)

# print solution
head(s1)

# create Marxan problem using data.frames that have been loaded into R
# (note this example also requires the data.table package to be installed)
## load in planning unit data
pu_path <- system.file("extdata/marxan/input/pu.dat", package = "prioritizr")
pu_dat <- data.table::fread(pu_path, data.table = FALSE)
head(pu_dat)

## load in feature data
spec_path <- system.file(
  "extdata/marxan/input/spec.dat", package = "prioritizr"
)
spec_dat <- data.table::fread(spec_path, data.table = FALSE)
head(spec_dat)

## load in planning unit vs feature data
puvspr_path <- system.file(
  "extdata/marxan/input/puvspr.dat", package = "prioritizr"
)
puvspr_dat <- data.table::fread(puvspr_path, data.table = FALSE)
head(puvspr_dat)

## load in the boundary data
bound_path <- system.file(
  "extdata/marxan/input/bound.dat", package = "prioritizr"
)
bound_dat <- data.table::fread(bound_path, data.table = FALSE)
head(bound_dat)

# create problem without the boundary data
p2 <-
  marxan_problem(pu_dat, spec_dat, puvspr_dat) %>%
  add_default_solver(verbose = FALSE)

# solve problem
s2 <- solve(p2)

# print solution
head(s2)

# create problem with the boundary data and a boundary length modifier
# set to 5
p3 <-
  marxan_problem(pu_dat, spec_dat, puvspr_dat, bound_dat, blm = 5) %>%
  add_default_solver(verbose = FALSE)

# solve problem
s3 <- solve(p3)

# print solution
head(s3)

## End(Not run)

prioritizr/prioritizr documentation built on March 4, 2024, 3:54 p.m.