Add contiguity constraints
Add constraints to a conservation planning problem() to ensure
that all selected planning units are spatially connected with each other
and form a single contiguous unit.
## S4 method for signature 'ConservationProblem,ANY,ANY' add_contiguity_constraints(x, zones, data) ## S4 method for signature 'ConservationProblem,ANY,data.frame' add_contiguity_constraints(x, zones, data) ## S4 method for signature 'ConservationProblem,ANY,matrix' add_contiguity_constraints(x, zones, data)
x |
|
zones |
|
data |
|
This function uses connection data to identify solutions that form a single contiguous unit. It was inspired by the mathematical formulations detailed in Önal and Briers (2006).
Object (i.e. ConservationProblem) with the constraints
added to it.
The argument to data can be specified using the following formats.
NULLconnection data should be calculated automatically
using the adjacency_matrix() function. This is the default
argument. Note that the connection data must be manually defined
using one of the other formats below when the planning unit data
in the argument to x is not spatially referenced (e.g.
in data.frame or numeric format).
matrix, Matrix
where rows and columns represent
different planning units and the value of each cell indicates if the
two planning units are connected or not. Cell values should be binary
numeric values (i.e. one or zero). Cells that occur along the
matrix diagonal have no effect on the solution at all because each
planning unit cannot be a connected with itself.
data.framecontaining the fields (columns)
"id1", "id2", and "boundary". Here, each row
denotes the connectivity between two planning units following the
Marxan format. The field boundary should contain
binary numeric values that indicate if the two planning units
specified in the fields "id1" and "id2" are connected
or not. This data can be used to describe symmetric or
asymmetric relationships between planning units. By default,
input data is assumed to be symmetric unless asymmetric data is
also included (e.g. if data is present for planning units 2 and 3, then
the same amount of connectivity is expected for planning units 3 and 2,
unless connectivity data is also provided for planning units 3 and 2).
In early versions, this function was named as the
add_connected_constraints() function.
Önal H and Briers RA (2006) Optimal selection of a connected reserve network. Operations Research, 54: 379–388.
# load data
data(sim_pu_raster, sim_features, sim_pu_zones_stack, sim_features_zones)
# create minimal problem
p1 <- problem(sim_pu_raster, sim_features) %>%
add_min_set_objective() %>%
add_relative_targets(0.2) %>%
add_binary_decisions() %>%
add_default_solver(verbose = FALSE)
# create problem with added connected constraints
p2 <- p1 %>% add_contiguity_constraints()
## Not run:
# solve problems
s <- stack(solve(p1), solve(p2))
# plot solutions
plot(s, main = c("basic solution", "connected solution"), axes = FALSE,
box = FALSE)
## End(Not run)
# create minimal problem with multiple zones, and limit the solver to
# 30 seconds to obtain solutions in a feasible period of time
p3 <- problem(sim_pu_zones_stack, sim_features_zones) %>%
add_min_set_objective() %>%
add_relative_targets(matrix(0.2, ncol = 3, nrow = 5)) %>%
add_binary_decisions() %>%
add_default_solver(time_limit = 30, verbose = FALSE)
# create problem with added constraints to ensure that the planning units
# allocated to each zone form a separate contiguous unit
z4 <- diag(3)
print(z4)
p4 <- p3 %>% add_contiguity_constraints(z4)
# create problem with added constraints to ensure that the planning
# units allocated to each zone form a separate contiguous unit,
# except for planning units allocated to zone 2 which do not need
# form a single contiguous unit
z5 <- diag(3)
z5[3, 3] <- 0
print(z5)
p5 <- p3 %>% add_contiguity_constraints(z5)
# create problem with added constraints that ensure that the planning
# units allocated to zones 1 and 2 form a contiguous unit
z6 <- diag(3)
z6[1, 2] <- 1
z6[2, 1] <- 1
print(z6)
p6 <- p3 %>% add_contiguity_constraints(z6)
## Not run:
# solve problems
s2 <- lapply(list(p3, p4, p5, p6), solve)
s2 <- lapply(s2, category_layer)
s2 <- stack(s2)
# plot solutions
plot(s2, axes = FALSE, box = FALSE,
main = c("basic solution", "p4", "p5", "p6"))
## End(Not run)
# create a problem that has a main "reserve zone" and a secondary
# "corridor zone" to connect up import areas. Here, each feature has a
# target of 30% of its distribution. If a planning unit is allocated to the
# "reserve zone", then the prioritization accrues 100% of the amount of
# each feature in the planning unit. If a planning unit is allocated to the
# "corridor zone" then the prioritization accrues 40% of the amount of each
# feature in the planning unit. Also, the cost of managing a planning unit
# in the "corridor zone" is 45% of that when it is managed as the
# "reserve zone". Finally, the problem has constraints which
# ensure that all of the selected planning units form a single contiguous
# unit, so that the planning units allocated to the "corridor zone" can
# link up the planning units allocated to the "reserve zone"
# create planning unit data
pus <- sim_pu_zones_stack[[c(1, 1)]]
pus[[2]] <- pus[[2]] * 0.45
print(pus)
# create biodiversity data
fts <- zones(sim_features, sim_features * 0.4,
feature_names = names(sim_features),
zone_names = c("reserve zone", "corridor zone"))
print(fts)
# create targets
targets <- tibble::tibble(feature = names(sim_features),
zone = list(zone_names(fts))[rep(1, 5)],
target = cellStats(sim_features, "sum") * 0.2,
type = rep("absolute", 5))
print(targets)
# create zones matrix
z7 <- matrix(1, ncol = 2, nrow = 2)
print(z7)
# create problem
p7 <- problem(pus, fts) %>%
add_min_set_objective() %>%
add_manual_targets(targets) %>%
add_contiguity_constraints(z7) %>%
add_binary_decisions() %>%
add_default_solver(verbose = FALSE)
## Not run:
# solve problems
s7 <- category_layer(solve(p7))
# plot solutions
plot(s7, "solution", axes = FALSE, box = FALSE)
## End(Not run)Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.