# NOT RUN {
# load data
data(sim_pu_raster, sim_pu_zones_stack, sim_features, sim_features_zones)
# create problem with minimum shortfall objective
p1 <- problem(sim_pu_raster, sim_features) %>%
add_min_shortfall_objective(1800) %>%
add_relative_targets(0.1) %>%
add_binary_decisions()
# }
# NOT RUN {
# solve problem
s1 <- solve(p1)
# plot solution
plot(s1, main = "solution", axes = FALSE, box = FALSE)
# }
# NOT RUN {
# create multi-zone problem with minimum shortfall objective,
# with 10 % representation targets for each feature, and set
# a budget such that the total maximum expenditure in all zones
# cannot exceed 3000
p2 <- problem(sim_pu_zones_stack, sim_features_zones) %>%
add_min_shortfall_objective(3000) %>%
add_relative_targets(matrix(0.1, ncol = 3, nrow = 5)) %>%
add_binary_decisions()
# }
# NOT RUN {
# solve problem
s2 <- solve(p2)
# plot solution
plot(category_layer(s2), main = "solution", axes = FALSE, box = FALSE)
# }
# NOT RUN {
# create multi-zone problem with minimum shortfall objective,
# with 10 % representation targets for each feature, and set
# separate budgets for each management zone
p3 <- problem(sim_pu_zones_stack, sim_features_zones) %>%
add_min_shortfall_objective(c(3000, 3000, 3000)) %>%
add_relative_targets(matrix(0.1, ncol = 3, nrow = 5)) %>%
add_binary_decisions()
# }
# NOT RUN {
# solve problem
s3 <- solve(p3)
# plot solution
plot(category_layer(s3), main = "solution", axes = FALSE, box = FALSE)
# }
Run the code above in your browser using DataLab