useSolver {eatATA} | R Documentation |
Use a solver for a list of constraints.
Description
Use a mathematical programming solver to solve a list for constrains.
Usage
useSolver(
allConstraints,
solver = c("GLPK", "lpSolve", "Gurobi", "Symphony"),
timeLimit = Inf,
formNames = NULL,
...
)
Arguments
allConstraints |
List of constraints. |
solver |
A character string indicating the solver to use. |
timeLimit |
The maximal runtime in seconds. |
formNames |
A character vector with names to give to the forms. |
... |
Additional arguments for the solver. |
Details
Wrapper around the functions of different solvers (gurobi::gurobi(),
lpSolve::lp(), ...
for a list of constraints set up via eatATA
.
Rglpk
is used per default.
Additional arguments can be passed through
...
and vary from solver to solver (see their respective help pages,
lp
or Rglpk_solve_LP
); for example
time limits can not be set for lpSolve
.
Value
A list with the following elements:
solution_found
Was a solution found?
solution
Numeric vector containing the found solution.
solution_status
Was the solution optimal?
Examples
nForms <- 2
nItems <- 4
# create constraits
target <- minimaxObjective(nForms = nForms, c(1, 0.5, 1.5, 2),
targetValue = 2, itemIDs = 1:nItems)
noItemOverlap <- itemUsageConstraint(nForms, operator = "=", itemIDs = 1:nItems)
testLength <- itemsPerFormConstraint(nForms = nForms,
operator = "<=", targetValue = 2, itemIDs = 1:nItems)
# use a solver
result <- useSolver(list(target, noItemOverlap, testLength),
itemIDs = paste0("Item_", 1:4),
solver = "GLPK")
[Package eatATA version 1.1.2 Index]