Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

add_top_portfolio

Add a top portfolio


Description

Generate a portfolio of solutions for a conservation planning problem() by finding a pre-specified number of solutions that are closest to optimality (i.e the top solutions).

Usage

add_top_portfolio(x, number_solutions)

Arguments

x

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

number_solutions

integer number of solutions required.

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 9.0.0 (or greater) of the gurobi package must be installed. Note that the number of solutions returned may be less than the argument to number_solutions, if the total number of feasible solutions is less than the number of solutions requested.

Value

Object (i.e. ConservationProblem) with the portfolio added to it.

See Also

Examples

## Not run: 
# set seed for reproducibility
set.seed(600)

# load data
data(sim_pu_raster, sim_features)

# create minimal problem with a portfolio for the top 5 solutions
p1 <- problem(sim_pu_raster, sim_features) %>%
      add_min_set_objective() %>%
      add_relative_targets(0.05) %>%
      add_top_portfolio(number_solutions = 5) %>%
      add_default_solver(gap = 0, verbose = FALSE)

# solve problem and generate portfolio
s1 <- solve(p1)

# print number of solutions found
print(length(s1))

# plot solutions
plot(stack(s1), axes = FALSE, box = FALSE)

# create multi-zone problem with a portfolio for the top 5 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_top_portfolio(number_solutions = 5) %>%
      add_default_solver(gap = 0, verbose = FALSE)

# solve problem and generate portfolio
s2 <- solve(p2)

# print number of solutions found
print(length(s2))

# plot solutions in portfolio
plot(stack(lapply(s2, category_layer)), main = "solution", axes = FALSE,
     box = FALSE)

## End(Not run)

prioritizr

Systematic Conservation Prioritization in R

v7.0.1
GPL-3
Authors
Jeffrey O Hanson [aut] (<https://orcid.org/0000-0002-4716-6134>), Richard Schuster [aut, cre] (<https://orcid.org/0000-0003-3191-7869>), Nina Morrell [aut], Matthew Strimas-Mackey [aut] (<https://orcid.org/0000-0001-8929-7776>), Matthew E Watts [aut], Peter Arcese [aut] (<https://orcid.org/0000-0002-8097-482X>), Joseph Bennett [aut] (<https://orcid.org/0000-0002-3901-9513>), Hugh P Possingham [aut] (<https://orcid.org/0000-0001-7755-996X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.