if (FALSE) {
# load data
sim_pu_raster <- get_sim_pu_raster()
sim_features <- get_sim_features()
sim_zones_pu_raster <- get_sim_zones_pu_raster()
sim_zones_features <- get_sim_zones_features()
# 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() %>%
add_default_solver(verbose = FALSE)
# solve problem
s1 <- solve(p1)
# plot solution
plot(s1, main = "solution", axes = FALSE)
# 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_zones_pu_raster, sim_zones_features) %>%
add_min_shortfall_objective(3000) %>%
add_relative_targets(matrix(0.1, ncol = 3, nrow = 5)) %>%
add_binary_decisions() %>%
add_default_solver(verbose = FALSE)
# solve problem
s2 <- solve(p2)
# plot solution
plot(category_layer(s2), main = "solution", axes = FALSE)
# 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_zones_pu_raster, sim_zones_features) %>%
add_min_shortfall_objective(c(3000, 3000, 3000)) %>%
add_relative_targets(matrix(0.1, ncol = 3, nrow = 5)) %>%
add_binary_decisions() %>%
add_default_solver(verbose = FALSE)
# solve problem
s3 <- solve(p3)
# plot solution
plot(category_layer(s3), main = "solution", axes = FALSE)
}
Run the code above in your browser using DataLab