solve {prioriactions} | R Documentation |
Solve mathematical models
Description
Solves the optimization model associated with the multi-action
conservation planning problem. This function is used to solve
the mathematical model created by the problem()
function.
Usage
solve(
a,
solver = "",
gap_limit = 0,
time_limit = .Machine$integer.max,
solution_limit = FALSE,
cores = 2,
verbose = TRUE,
name_output_file = "output",
output_file = TRUE
)
Arguments
a |
optimizationProblem object. Optimization model created
for the problem of prioritization of multiple conservation actions. This object must be
created using the |
solver |
|
gap_limit |
|
time_limit |
|
solution_limit |
|
cores |
|
verbose |
|
name_output_file |
|
output_file |
|
Details
The solvers supported by the solve()
function are
described below.
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, also this solver is not freely available. That said, licenses are available to academics at no cost. The gurobi package is distributed with the Gurobi software suite. This solver uses the gurobi package to solve problems.
CPLEX solver
-
cplex is a state-of-the-art commercial optimization software with an R package interface. Like Gurobi, it is not freely accessible, but we can obtain academic licenses. We recommend using this solver if the Gurobi solver is not available. Licenses are available for the IBM CPLEX software to academics at no cost here. This solver uses the Rcplex package to solve problems.
CBC solver
-
CBC is an open-source mixed integer linear programming solver written in C++. It is part of the Computational Infrastructure for Operations Research (COIN-OR) project interface. rcbc package to solve problems is now available only on Github. Please ensure that you closely adhere to the detailed installation instructions provided here for proper setup.
Symphony 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.
Value
An object of class solution.
See Also
For more information on how to install and obtain an academic license of the Gurobi solver, see the Gurobi installation guide, which can be found online at prioritizr vignette. Just like Gurobi, cplex needs an academic licence to work. Details about how to install the cplex solver, see the webpage IBM CPLEX. Once installed, see the Rcplex installation guide, which can be found online at Rcplex package.
Examples
## Not run:
## This example uses input files included into package.
## Load data
data(sim_pu_data, sim_features_data, sim_dist_features_data,
sim_threats_data, sim_dist_threats_data, sim_sensitivity_data,
sim_boundary_data)
## Create data instance
problem_data <- inputData(
pu = sim_pu_data, features = sim_features_data, dist_features = sim_dist_features_data,
threats = sim_threats_data, dist_threats = sim_dist_threats_data,
sensitivity = sim_sensitivity_data, boundary = sim_boundary_data
)
## Create optimization model
problem_model <- problem(x = problem_data, blm = 1)
## Solve the optimization model using a gap_limit and gurobi solver
## NOTE: The Gurobi solver must be previously installed and must have a valid license!
s1 <- solve(a = problem_model, solver = "gurobi", gap_limit = 0.01, output_file = FALSE, cores = 2)
print(s1)
## Solve the optimization model using a gap_limit and symphony solver
s2 <- solve(a = problem_model,
solver = "symphony",
gap_limit = 0.01,
output_file = FALSE,
cores = 2)
print(s2)
## Solve the optimization model using a time_limit and gurobi solver
s3 <- solve(a = problem_model, solver = "gurobi", time_limit = 10, output_file = FALSE, cores = 2)
print(s3)
## End(Not run)