Learn R Programming

prioritizr (version 3.0.4)

add_lsymphony_solver: Add a SYMPHONY solver with lpsymphony

Description

Specify the use of a SYMPHONY algorithm to solve a ConservationProblem-class object. Requires the lpsymphony package.

Usage

add_lpsymphony_solver(x, gap = 0.1, time_limit = -1, first_feasible = 0,
  verbose = TRUE)

Arguments

gap

numeric gap to optimality. This gap is absolute and expresses the acceptable deviance from the optimal objective. For example, solving a minimum set objective problem with a gap of 5 will cause the solver to terminate when the cost of the solution is within 5 cost units from the optimal solution.

time_limit

numeric time limit in seconds to run the optimizer. The solver will return the current best solution when this time limit is exceeded.

first_feasible

logical should the first feasible solution be be returned? If first_feasible is set to TRUE, the solver will return the first solution it encounters that meets all the constraints, regardless of solution quality. Note that the first feasible solution is not an arbitrary solution, rather it is derived from the relaxed solution, and is therefore often reasonably close to optimality.

verbose

logical should information be printed while solving optimization problems? Defaults to TRUE.

Details

The lpsymphony package provides a different interface to the COIN-OR software suite. Unlike the Rsymhpony package, the lpsymphony package is distributed through Bioconductor. On Windows and Mac, lpsymphony may be easier to install. This solver uses the lpsymphony package to solve.

See Also

solvers.

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.1) %>%
  add_binary_decisions()
# }
# NOT RUN {
# if the package is installed then add solver and generate solution
# note that this solver is skipped on Linux systems due to instability
# issues
if (requireNamespace("lpsymphony", quietly = TRUE) &
    isTRUE(Sys.info()[["sysname"]] != "Linux")) {
  # specify solver and generate solution
  s <- p %>% add_lpsymphony_solver(time_limit = 5) %>%
             solve()

  # plot solutions
  plot(stack(sim_pu_raster, s), main = c("planning units", "solution"))
}
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab