Learn R Programming

prioritizr (version 3.0.4)

add_feature_weights: Add feature weights

Description

Conservation planning problems that aim to maximize the representation of features may not be able to conserve all of them if the budget is not high enough. In such budget-limited problems, it may be desirable to prefer the representation of some features over other features. Weights can be applied to a problem to favor the representation of some features over other features when making decisions about how the budget should be allocated.

Usage

add_feature_weights(x, weights)

Arguments

weights

numeric weights. Features with higher weights indicate that it is more desirable to represent them in the solution. Weights cannot have negative values.

Value

ConservationProblem-class object with the weights added to it.

Details

Weights can only be applied to a budget-limited type of planning problem (i.e. add_max_cover_objective, and add_max_features_objective. Weights can also be applied to problems that aim to maximize phylogenetic representation (add_max_phylo_objective) to favor the representation of specific features over the representation of some phylogenetic branches.

See Also

targets, objectives.

Examples

Run this code
# NOT RUN {
# create problem
p <- problem(sim_pu_raster, sim_features) %>%
     add_max_cover_objective(budget = 5000)

# problem problem with features weighted according to rarity
# (1 / number occurrences)
w1 <- 1 / cellStats(sim_features, "sum") * 1000
p1 <- p %>% add_feature_weights(w1)

# problem problem with features weighted according to manually specified
# weights
w2  <- c(0.1, 0.2, 0.3, 0.4, 0.5)
p2 <- p %>% add_feature_weights(w2)
# }
# NOT RUN {
# solve solutions
s <- stack(solve(p), solve(p1), solve(p2))

# plot solutions
plot(s, main = c("equal weights", "rarity weights", "manual weights"),
     axes = FALSE, box = FALSE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab