Description Usage Arguments Details Examples
Specify the software and configurations used to solve a conservation planning
problem. Below is a list of different solvers that can be added to a
ConservationProblem-class
object.
1 2 3 4 5 6 7 8 9 10 | add_default_solver(x, ...)
add_gurobi_solver(x, gap = 0.1, time_limit = .Machine$integer.max,
presolve = 2, threads = 1, first_feasible = 0)
add_rsymphony_solver(x, gap = 0.1, time_limit = -1, first_feasible = 0,
verbosity = 1)
add_lpsymphony_solver(x, gap = 0.1, time_limit = -1, verbosity = 1,
first_feasible = 0)
|
x |
|
... |
arguments passed to the default solver. |
gap |
|
time_limit |
|
presolve |
|
threads |
|
first_feasible |
|
verbosity |
|
default_solver
This solver uses the best software currently installed on the system.
add_gurobi_solver
Gurobi is a
state-of-the-art commercial optimization software with an R package
interface. It is by far the fastest of the solvers available in this
package, however, it is also the only one that isn"t free. That said,
free academic licenses are available. The gurobi
package is
distributed with the Gurobi software suite. This solver uses the
gurobi
package to solve problems.
add_rsymphony_solver
SYMPHONY is an open-source
integer programming solver that is part of the Computational
Infrastructure for Operations Research (COIN-OR) project, an initiative
to promote development of open-source tools for operations research (a
field that includes linear programming). The Rsymphony
package
provides an interface to COIN-OR and is available on CRAN. This solver
uses the Rsymphony
package to solve problems.
add_lpsymphony_solver
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
may be easier to install. This solver uses the lpsymphony
package
to solve.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # load packages
require(gurobi)
require(lpsymphony)
require(Rsymphony)
# load data
data(sim_pu_raster, sim_features)
# create basic problem
p <- problem(sim_pu_raster, sim_features) %>%
add_min_set_objective() %>%
add_relative_targets(0.1)
# create vector to store plot titles
titles <- c()
# create empty stack to store solutions
s <- stack()
# create problem with added rsymphony solver and limit the time spent
# searching for the optimal solution to 2 seconds
if (requireNamespace("Rsymphony", quietly = TRUE)) {
titles <- c(titles, "Rsymphony (2s)")
p1 <- p %>% add_rsymphony_solver(time_limit = 2)
s <- addLayer(s, solve(p1))
}
# create problem with added rsymphony solver and limit the time spent
# searching for the optimal solution to 5 seconds
if (requireNamespace("Rsymphony", quietly = TRUE)) {
titles <- c(titles, "Rsymphony (5s)")
p2 <- p %>% add_rsymphony_solver(time_limit = 5)
s <- addLayer(s, solve(p2))
}
# if the gurobi is installed: create problem with added gurobi solver
if (requireNamespace("gurobi", quietly = TRUE)) {
titles <- c(titles, "gurobi (5s)")
p3 <- p %>% add_gurobi_solver(gap = 0.1, presolve = 2, time_limit = 5)
s <- addLayer(s, solve(p3))
}
# if the lpsymphony is installed: create problem with added lpsymphony solver
if (requireNamespace("lpsymphony", quietly = TRUE)) {
titles <- c(titles, "lpsymphony")
p4 <- p %>% add_lpsymphony_solver(gap = 0.1, time_limit = 5)
s <- addLayer(s, solve(p4))
}
# plot solutions
plot(s, main = titles)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.