Specify that the Gurobi software should be used to solve a conservation planning problem. This function can also be used to customize the behavior of the solver. It requires the gurobi package.
add_gurobi_solver( x, gap = 0.1, time_limit = .Machine$integer.max, presolve = 2, threads = 1, first_feasible = 0, numeric_focus = FALSE, verbose = TRUE )
x 


gap 

time_limit 

presolve 

threads 

first_feasible 

numeric_focus 

verbose 

Object (i.e. ConservationProblem
) with the solver
added to it.
Gurobi is a stateoftheart 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 solver that 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.
# 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() # \dontrun{ # if the package is installed then add solver and generate solution if (require("gurobi")) { # specify solver and generate solution s < p %>% add_gurobi_solver(gap = 0.1, presolve = 2, time_limit = 5) %>% solve() # plot solutions plot(stack(sim_pu_raster, s), main = c("planning units", "solution"), axes = FALSE, box = FALSE) }#>#>#> Gurobi Optimizer version 9.0.2 build v9.0.2rc0 (linux64) #> Optimize a model with 5 rows, 90 columns and 450 nonzeros #> Model fingerprint: 0x6442bf6e #> Variable types: 0 continuous, 90 integer (90 binary) #> Coefficient statistics: #> Matrix range [2e01, 9e01] #> Objective range [2e+02, 2e+02] #> Bounds range [1e+00, 1e+00] #> RHS range [3e+00, 8e+00] #> Found heuristic solution: objective 2337.9617505 #> Presolve time: 0.00s #> Presolved: 5 rows, 90 columns, 450 nonzeros #> Variable types: 0 continuous, 90 integer (90 binary) #> Presolved: 5 rows, 90 columns, 450 nonzeros #> #> #> Root relaxation: objective 1.931582e+03, 12 iterations, 0.00 seconds #> #> Nodes  Current Node  Objective Bounds  Work #> Expl Unexpl  Obj Depth IntInf  Incumbent BestBd Gap  It/Node Time #> #> 0 0 1931.58191 0 4 2337.96175 1931.58191 17.4%  0s #> H 0 0 1987.3985265 1931.58191 2.81%  0s #> #> Explored 1 nodes (12 simplex iterations) in 0.00 seconds #> Thread count was 1 (of 4 available processors) #> #> Solution count 2: 1987.4 2337.96 #> #> Optimal solution found (tolerance 1.00e01) #> Best objective 1.987398526526e+03, best bound 1.931581908865e+03, gap 2.8085%# }