Learn R Programming

prioritizr (version 3.0.4)

add_shuffle_portfolio: Add a shuffle portfolio

Description

Generate a portfolio of solutions by randomly reordering the data prior to #' attempting to solve the problem.

Usage

add_shuffle_portfolio(x, number_solutions = 10L, threads = 1L,
  remove_duplicates = TRUE)

Arguments

number_solutions

integer number of attempts to generate different solutions. Defaults to 10.

threads

integer number of threads to use for the generating the solution portfolio. Defaults to 1.

remove_duplicates

logical should duplicate solutions be removed? Defaults to TRUE.

Details

This strategy for generating a portfolio of solutions often results in different solutions, depending on optimality gap, but may return duplicate solutions. In general, this strategy is most effective when problems are quick to solve and multiple threads are available for solving each problem separately.

See Also

portfolios.

Examples

Run this code
# NOT RUN {
# load data
data(sim_pu_raster, sim_features)

# create problem
p <- problem(sim_pu_raster, sim_features) %>%
     add_min_set_objective() %>%
     add_relative_targets(0.2) %>%
     add_shuffle_portfolio(10, remove_duplicates = FALSE) %>%
     add_default_solver(gap = 0.2, verbose = FALSE)

# }
# NOT RUN {
# solve problem and generate 10 solutions within 20 % of optimality
s <- solve(p)

# plot solution
plot(s, axes = FALSE, box = FALSE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab