add_gurobi_solver {oppr} | R Documentation |
Add a Gurobi solver
Description
Specify that the Gurobi software should be used to solve a
project prioritization problem()
. This function can also be
used to customize the behavior of the solver. In addition to the
Gurobi software suite, it also requires the gurobi package to
be installed.
Usage
add_gurobi_solver(
x,
gap = 0,
number_solutions = 1,
solution_pool_method = 2,
time_limit = .Machine$integer.max,
presolve = 2,
threads = 1,
first_feasible = FALSE,
verbose = TRUE
)
Arguments
x |
ProjectProblem object.
|
gap |
numeric gap to optimality. This gap is relative
and expresses the acceptable deviance from the optimal objective.
For example, a value of 0.01 will result in the solver stopping when
it has found a solution within 1% of optimality.
Additionally, a value of 0 will result in the solver stopping
when it has found an optimal solution.
The default value is 0.1 (i.e. 10% from optimality).
|
number_solutions |
integer number of solutions desired.
Defaults to 1. Note that the number of returned solutions can sometimes
be less than the argument to number_solutions depending on the
argument to solution_pool_method , for example if 100
solutions are requested but only 10 unique solutions exist, then only 10
solutions will be returned.
|
solution_pool_method |
numeric search method identifier that
determines how multiple solutions should be generated. Available search
modes for generating a portfolio of solutions include: 0
recording all solutions identified whilst trying to find
a solution that is within the specified optimality gap, 1 finding
one solution within the optimality gap and a number of additional
solutions that are of any level of quality (such that the total number of
solutions is equal to number_solutions ), and 2 finding a
specified number of solutions that are nearest to optimality. For more
information, see the Gurobi manual (i.e. https://www.gurobi.com/documentation/8.0/refman/poolsearchmode.html#parameter:PoolSearchMode). Defaults to 2.
|
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.
|
presolve |
integer number indicating how intensively the
solver should try to simplify the problem before solving it. The default
value of 2 indicates to that the solver should be very aggressive in
trying to simplify the problem.
|
threads |
integer number of threads to use for the
optimization algorithm. The default value of 1 will result in only
one thread being used.
|
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.
Defaults to FALSE .
|
verbose |
logical should information be printed while solving
optimization problems?
|
Details
Gurobi is a
state-of-the-art commercial optimization software with an R package
interface. It is by far the fastest of the solvers supported by 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.
To install the gurobi package, the
Gurobi optimization suite will first need to
be installed (see instructions for Linux,
Mac OSX, and
Windows operating systems). Although
Gurobi is a commercial software, academics
can obtain a
special license for no cost. After installing the
Gurobi optimization suite, the gurobi
package can then be installed (see instructions for Linux,
Mac OSX, and
Windows operating systems).
Value
ProjectProblem object with the solver added
to it.
See Also
solvers.
Examples
## Not run:
# load data
data(sim_projects, sim_features, sim_actions)
# build problem
p1 <- problem(sim_projects, sim_actions, sim_features,
"name", "success", "name", "cost", "name") %>%
add_max_richness_objective(budget = 200) %>%
add_binary_decisions()
# build another problem, and specify the Gurobi solver
p2 <- p1 %>%
add_gurobi_solver()
# print problem
print(p2)
# solve problem
s2 <- solve(p2)
# print solution
print(s2)
# plot solution
plot(p2, s2)
# build another problem and obtain multiple solutions
# note that this problem doesn't have 100 unique solutions so
# the solver won't return 100 solutions
p3 <- p1 %>%
add_gurobi_solver(number_solutions = 100)
# print problem
print(p3)
# solve problem
s3 <- solve(p3)
# print solutions
print(s3)
## End(Not run)
[Package
oppr version 1.0.4
Index]