Generate a portfolio of solutions for a conservation planning problem() by storing feasible solutions discovered during the optimization process. This method is useful for quickly obtaining multiple solutions, but does not provide any guarantees on the number of solutions, or the quality of solutions.

add_extra_portfolio(x)

Arguments

x

problem() (i.e. ConservationProblem) object.

Value

Object (i.e. ConservationProblem) 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.

See also

Examples

# \dontrun{ # set seed for reproducibility set.seed(600) # load data data(sim_pu_raster, sim_features) # create minimal problem with a portfolio for extra solutions p1 <- problem(sim_pu_raster, sim_features) %>% add_min_set_objective() %>% add_relative_targets(0.05) %>% add_extra_portfolio() %>% add_default_solver(gap = 0, verbose = FALSE) # solve problem and generate portfolio s1 <- solve(p1)
#> $LogToConsole #> [1] 0 #> #> $LogFile #> [1] "" #> #> $Presolve #> [1] 2 #> #> $MIPGap #> [1] 0 #> #> $TimeLimit #> [1] 2147483647 #> #> $Threads #> [1] 1 #> #> $NumericFocus #> [1] 0 #>
# print number of solutions found print(length(s1))
#> [1] 10
# plot solutions plot(stack(s1), axes = FALSE, box = FALSE)
# create multi-zone problem with a portfolio for extra solutions 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_extra_portfolio() %>% add_default_solver(gap = 0, verbose = FALSE) # solve problem and generate portfolio s2 <- solve(p2)
#> $LogToConsole #> [1] 0 #> #> $LogFile #> [1] "" #> #> $Presolve #> [1] 2 #> #> $MIPGap #> [1] 0 #> #> $TimeLimit #> [1] 2147483647 #> #> $Threads #> [1] 1 #> #> $NumericFocus #> [1] 0 #>
# print number of solutions found print(length(s2))
#> [1] 10
# plot solutions in portfolio plot(stack(lapply(s2, category_layer)), main = "solution", axes = FALSE, box = FALSE)
# }