# NOT RUN {
# set seed for reproducibility
set.seed(500)
# load data
data(sim_pu_raster, sim_features, sim_pu_zones_stack, sim_features_zones)
# create minimal problem with semi-continuous decisions
p1 <- problem(sim_pu_raster, sim_features) %>%
add_min_set_objective() %>%
add_relative_targets(0.1) %>%
add_semicontinuous_decisions(0.5)
# }
# NOT RUN {
# solve problem
s1 <- solve(p1)
# plot solutions
plot(s1, main = "solution")
# }
# NOT RUN {
# build multi-zone conservation problem with semi-continuous decisions
p2 <- problem(sim_pu_zones_stack, sim_features_zones) %>%
add_min_set_objective() %>%
add_relative_targets(matrix(runif(15, 0.1, 0.2), nrow = 5,
ncol = 3)) %>%
add_semicontinuous_decisions(0.5)
# }
# NOT RUN {
# solve the problem
s2 <- solve(p2)
# print solution
print(s2)
# plot solution
# panels show the proportion of each planning unit allocated to each zone
plot(s2, axes = FALSE, box = FALSE)
# }
Run the code above in your browser using DataLab