Description Usage Arguments Value See Also Examples
Add constraints to a conservation problem to ensure that all selected planning units have at least a certain number of neighbors.
1 | add_neighbor_constraints(x, k, ...)
|
x |
|
k |
|
... |
arguments passed to |
ConservationProblem-class
object with the constraint
added to it.
constraints
for all the available constraints.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # create basic problem
p1 <- problem(sim_pu_polygons, sim_features) %>%
add_min_set_objective() %>%
add_relative_targets(0.2)
# create problem with constraints that require 1 neighbor
p2 <- p1 %>% add_neighbor_constraints(1)
# create problem with constraints that require 2 neighbors
p3 <- p1 %>% add_neighbor_constraints(2)
# create problem with constraints that require 3 neighbors
p4 <- p1 %>% add_neighbor_constraints(3)
# solve problems
s <- list(solve(p1), solve(p2), solve(p3), solve(p4))
# plot solutions
par(mfrow=c(2,2))
plot(s[[1]], main="basic solution")
plot(s[[1]][s[[1]]$solution==1, ], col = "darkgreen", add = TRUE)
plot(s[[2]], main="1 neighbor")
plot(s[[2]][s[[2]]$solution==1, ], col = "darkgreen", add = TRUE)
plot(s[[3]], main="2 neighbors")
plot(s[[3]][s[[3]]$solution==1, ], col = "darkgreen", add = TRUE)
plot(s[[4]], main="3 neighbors")
plot(s[[4]][s[[4]]$solution==1, ], col = "darkgreen", add = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.