if (FALSE) {
# load data
sim_pu_raster <- get_sim_pu_raster()
sim_features <- get_sim_features()
# create problem
p <-
problem(sim_pu_raster, sim_features) %>%
add_min_set_objective() %>%
add_relative_targets(0.1) %>%
add_binary_decisions() %>%
add_default_solver(gap = 0.02, verbose = FALSE)
# create problem with default portfolio
p1 <- p %>% add_default_portfolio()
# create problem with cuts portfolio with 4 solutions
p2 <- p %>% add_cuts_portfolio(4)
# create problem with shuffle portfolio with 4 solutions
p3 <- p %>% add_shuffle_portfolio(4)
# create problem with extra portfolio
p4 <- p %>% add_extra_portfolio()
# create problem with top portfolio with 4 solutions
p5 <- p %>% add_top_portfolio(4)
# create problem with gap portfolio with 4 solutions within 50% of optimality
p6 <- p %>% add_gap_portfolio(4, 0.5)
# solve problems to obtain solution portfolios
s <- list(solve(p1), solve(p2), solve(p3), solve(p4), solve(p5), solve(p6))
# plot solution from default portfolio
plot(terra::rast(s[[1]]), axes = FALSE)
# plot solutions from cuts portfolio
plot(terra::rast(s[[2]]), axes = FALSE)
# plot solutions from shuffle portfolio
plot(terra::rast(s[[3]]), axes = FALSE)
# plot solutions from extra portfolio
plot(terra::rast(s[[4]]), axes = FALSE)
# plot solutions from top portfolio
plot(terra::rast(s[[5]]), axes = FALSE)
# plot solutions from gap portfolio
plot(terra::rast(s[[6]]), axes = FALSE)
}
Run the code above in your browser using DataLab