View source: R/add_cost_penalties.R
| add_cost_penalties | R Documentation |
Add penalties to a conservation planning problem to penalize
solutions that select planning units with higher cost values.
These penalties assume a linear trade-off between the cost and the primary
objective of the conservation planning problem (e.g.,
number of targets met for add_max_n_targets_met_objective().
add_cost_penalties(x, penalty)
x |
|
penalty |
|
This function penalizes solutions that have higher values according
to the sum of the cost values associated with each planning unit,
weighted by status of each planning unit in the solution.
Note that this function provided as a convenient alternative for
adding linear penalties (per add_linear_penalties()) to a problem().
An updated problem() object with the penalties added to it.
The cost penalties are implemented using the following
equations.
Let I denote the set of planning units
(indexed by i), Z the set of management zones (indexed by
z), and X_{iz} the decision variable for allocating
planning unit i to zone z (e.g., with binary
values indicating if each planning unit is allocated or not). Also, let
P_z represent the penalty scaling value for zones
z \in Z (per penalty), and
D_{iz} represent the cost data for allocating planning unit
i \in I to zones z \in Z
(per data in matrix format).
\sum_{i}^{I} \sum_{z}^{Z} P_z \times D_{iz} \times X_{iz}
Note that when the problem objective is to maximize some measure of
benefit and not minimize some measure of cost, the term P_z is
replaced with -P_z.
Other functions for adding penalties:
add_asym_connectivity_penalties(),
add_boundary_penalties(),
add_connectivity_penalties(),
add_feature_weights(),
add_linear_penalties(),
add_neighbor_penalties()
# set seed for reproducibility
set.seed(600)
# load data
sim_complex_pu_raster <- get_sim_complex_pu_raster()
sim_complex_features <- get_sim_complex_features()
# create layer with 1s for all planning units
sim_ones_complex_raster <- (sim_complex_pu_raster * 0) + 1
# here we will formulate a multi-objective optimization problem
# that (i) minimizes the largest target shortfall for feature representation,
# (ii) minimizes the overall target shortfalls for feature representation,
# and (iii) minimizes the cost of the solution. since the
# first objective is to minimize the largest shortfall and the second
# objective is to minimize overall target shortfalls,
# this helps balance shortfalls among all features and better
# achieve complementarity. additionally, we will specify that
# (approximately) 30% of the study area should be selected (i.e., by
# specifying a budget for the upper threshold and a linear constraint for
# the lower threshold on the number of selected planning units).
# calculate budget based on 30% of the number of planning units
budget <-
0.3 * terra::global(sim_ones_complex_raster, "sum", na.rm = TRUE)[[1]]
# build multi-objective conservation planning problem
mp <-
multi_problem(
obj1 =
problem(sim_ones_complex_raster, sim_complex_features) %>%
add_min_largest_shortfall_objective(budget = budget) %>%
add_auto_targets("jung") %>%
# note that this constraint only needs to be specified once
add_cost_constraints(sense = ">=", budget = budget * 0.9) %>%
add_binary_decisions(),
obj2 =
problem(sim_ones_complex_raster, sim_complex_features) %>%
add_min_shortfall_objective(budget = budget) %>%
# note that we use the same targets for both obj1 and obj2
add_auto_targets("jung") %>%
add_binary_decisions(),
obj3 =
problem(sim_complex_pu_raster, sim_complex_pu_raster) %>%
add_min_penalties_objective(budget = NULL) %>%
# note a value of 1 is here because only the costs minimized
add_cost_penalties(1) %>%
add_binary_decisions()
) %>%
add_default_solver(gap = 0.01, verbose = FALSE)
# to explore trade-offs between how well the feature targets
# are met and cost, we will generate a matrix of relative tolerance values
# for the hierarchical approach. note that the first column of this
# matrix will have only zeros to help promote balanced
# shortfalls across different features, and the second column
# will have non-zeros because we are interested in trade-offs between
# overall feature shortfalls and cost
rel_tol_matrix <- matrix(0, ncol = 2, nrow = 10)
rel_tol_matrix[, 2] <- seq(0, 0.5, length.out = nrow(rel_tol_matrix))
# display matrix
print(rel_tol_matrix)
# add hierarchical approach to multi-objective problem
mp <-
mp %>%
add_hier_approach(rel_tol = rel_tol_matrix)
# generate solutions and remove duplicates
ms <- solve(mp, remove_duplicates = TRUE)
# plot the solutions
plot(terra::rast(ms), axes = FALSE)
# extract objective values for the solutions
obj_matrix <- attributes(ms)$objective
# print the objective values
print(obj_matrix)
# plot the objectives values to visualize trade-offs
# (note that smaller values are better for both objectives)
plot(
obj_matrix[, 2:3],
main = "Trade-offs between objectives",
xlab = "Species representation (overall shortfall)",
ylab = "Solution cost"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.