Linear and Mixed Integer Programming Solver Using GLPK
Linear and Mixed Integer Programming Solver Using GLPK
High level R interface to the GNU Linear Programming Kit (GLPK) for solving linear as well as mixed integer linear programming (MILP) problems.
Rglpk_solve_LP(obj, mat, dir, rhs, bounds =NULL, types =NULL, max =FALSE, control = list(),...)
Arguments
obj: a numeric vector representing the objective coefficients.
mat: a numeric vector or a (sparse) matrix of constraint coefficients. If the optimization problem is unconstrained then a matrix of dimension 0 times the number of objective variables is required.
dir: a character vector with the directions of the constraints. For a nonzero number of constraints each element must be one of "<", "<=", ">", ">=", or "==". Note, however, that the GLPK API only allows for non-strict inequalities. Strict inequalities are handled the same way as non-strict inequalities.
rhs: a numeric vector representing the right hand side of the constraints.
bounds: NULL (default) or a list with elements upper and lower containing the indices and corresponding bounds of the objective variables. The default for each variable is a bound between 0 and Inf.
types: a character vector indicating the types of the objective variables. types can be either "B" for binary, "C" for continuous or "I" for integer. By default NULL, taken as all-continuous. Recycled as needed.
max: a logical giving the direction of the optimization. TRUE means that the objective is to maximize the objective function, FALSE (default) means to minimize it.
control: a list of parameters to the solver. See Details.
``: a list of control parameters (overruling those specified in control).
provides a high level solver function using the low level C interface of the GLPK solver. R interface packages which port all low level C routines of the GLPK API to R are also available. Consult the See Also
Section for references.
Matrix mat and obj may be sparse arrays or matrices (simple_triplet_matrix) as provided by the slam
package.
The control argument can be used to set GLPK's many parameters. See the respective method section of the GNU Linear Programming Kit Reference Manual for further details. The following parameters are supported:
verbose:: turn GLPK terminal output on (TRUE) or off (FALSE, the default).
presolve:: turn presolver on (TRUE) or off (FALSE, the default).
tm_limit:: time limit in milliseconds of call to optimizer. Can be any nonnegative integer. Default: 0 (use GLPK default).
canonicalize_status:: a logical indicating whether to canonicalize GLPK status codes (on success Rglpk_solve_LP() returns code 0) or not (1). Default: TRUE.
Returns
A list containing the optimal solution, with the following components. - solution: the vector of optimal coefficients
objval: the value of the objective function at the optimum
status: an integer with status information about the solution returned. If the control parameter canonicalize_status is set (the default) then it will return 0 for the optimal solution being found, and non-zero otherwise. If the control parameter is set to FALSE it will return the GLPK status codes.
solution_dual: variable reduced cost, if available (NA otherwise).
auxiliary: a list with two vectors each containing the values of the auxiliary variable associated with the respective constraint at solution, primal and dual (if available, NA otherwise).