Generate a portfolio of solutions for a conservation planning problem by extracting all the feasible solutions discovered during the optimization process.

add_pool_portfolio(x, method = 0, number_solutions = 10)

Arguments

x

ConservationProblem-class object.

method

numeric search method identifier that determines how multiple solutions should be generated. Available search modes for generating a portfolio of solutions include: 0 recording all solutions identified whilst trying to find a solution that is within the specified optimality gap, 1 finding one solution within the optimality gap and a number of additional solutions that are of any level of quality (such that the total number of solutions is equal to number_solutions), and 2 finding a specified number of solutions that are nearest to optimality. These search methods correspond to the parameters used by the Gurobi software suite (see http://www.gurobi.com/documentation/8.0/refman/poolsearchmode.html#parameter:PoolSearchMode). Defaults to 0.

number_solutions

integer number of attempts to generate different solutions. Note that this argument has no effect if the argument to method is 0. Defaults to 10.

Value

ConservationProblem-class object with the portfolio added to it.

Details

This strategy for generating a portfolio requires problems to be solved using the Gurobi software suite (i.e. using add_gurobi_solver. Specifically, version 8.0.0 (or greater) of the gurobi package must be installed. Please note that although the solution pool methods are faster than the other methods for generating portfolios of solutions, none of the pool methods are guaranteed to return only solutions within a specified optimality gap. Also, except for when the method argument is set to 2, none of the search methods provide any guarantees on the number of returned solutions.

See also

Examples

# set seed for reproducibility set.seed(600) # load data data(sim_pu_raster, sim_features, sim_pu_zones_stack, sim_features_zones)
# create minimal problem with pool portfolio p1 <- problem(sim_pu_raster, sim_features) %>% add_min_set_objective() %>% add_relative_targets(0.05) %>% add_pool_portfolio() %>% add_default_solver(gap = 0, verbose = FALSE) # solve problem s1 <- solve(p1) # print number of solutions found print(length(s1))
#> [1] 3
# plot solutions plot(stack(s1), axes = FALSE, box = FALSE)
# create minimal problem with pool portfolio and find the top 5 solutions p2 <- problem(sim_pu_raster, sim_features) %>% add_min_set_objective() %>% add_relative_targets(0.05) %>% add_pool_portfolio(method = 2, number_solutions = 5) %>% add_default_solver(gap = 0, verbose = FALSE) # solve problem s2 <- solve(p2) # print number of solutions found print(length(s2))
#> [1] 5
# plot solutions plot(stack(s2), axes = FALSE, box = FALSE)
# build multi-zone conservation problem with pool portfolio p3 <- 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_binary_decisions() %>% add_pool_portfolio() %>% add_default_solver(gap = 0, verbose = FALSE) # solve the problem s3 <- solve(p3) # print number of solutions found print(length(s3))
#> [1] 9
# print solutions str(s3, max.level = 1)
#> List of 9 #> $ solution_1:Formal class 'RasterStack' [package "raster"] with 11 slots #> $ solution_2:Formal class 'RasterStack' [package "raster"] with 11 slots #> $ solution_3:Formal class 'RasterStack' [package "raster"] with 11 slots #> $ solution_4:Formal class 'RasterStack' [package "raster"] with 11 slots #> $ solution_5:Formal class 'RasterStack' [package "raster"] with 11 slots #> $ solution_6:Formal class 'RasterStack' [package "raster"] with 11 slots #> $ solution_7:Formal class 'RasterStack' [package "raster"] with 11 slots #> $ solution_8:Formal class 'RasterStack' [package "raster"] with 11 slots #> $ solution_9:Formal class 'RasterStack' [package "raster"] with 11 slots #> - attr(*, "objective")= Named num [1:9] 9808 9814 9822 9944 9947 ... #> ..- attr(*, "names")= chr [1:9] "solution_1" "solution_2" "solution_3" "solution_4" ... #> - attr(*, "status")= Named chr [1:9] "OPTIMAL" "SUBOPTIMAL" "SUBOPTIMAL" "SUBOPTIMAL" ... #> ..- attr(*, "names")= chr [1:9] "solution_1" "solution_2" "solution_3" "solution_4" ... #> - attr(*, "runtime")= Named num [1:9] 3.75 3.75 3.75 3.75 3.75 ... #> ..- attr(*, "names")= chr [1:9] "solution_1" "solution_2" "solution_3" "solution_4" ...
# plot solutions in portfolio plot(stack(lapply(s3, category_layer)), main = "solution", axes = FALSE, box = FALSE)