lp2 | R Documentation |
Solve LP with free variables
lp2(direction = "min", objective.in, const.mat, const.dir, const.rhs, free.var = NULL)
direction |
Character string giving direction of optimization: "min" (default) or "max." |
objective.in |
Numeric vector of coefficients of objective function |
const.mat |
Matrix of numeric constraint coefficients, one row per constraint, one column per variable (unless transpose.constraints = FALSE; see below). |
const.dir |
Vector of character strings giving the direction of the constraint: each value should be one of "<," "<=," "=," "==," ">," or ">=". (In each pair the two values are identical.) |
const.rhs |
Vector of numeric values for the right-hand sides of the constraints. |
free.var |
Vector of numeric values for indicating free variables. If this argument is NULL, no free variables is included. |
lp2 extends lpSolve::lp() to incorporate free variables easily.
An lp object. See 'lp.object' for details.
Dong-hyun Oh, oh.donghyun77@gmail.com
lp
# Set up problem: maximize # x1 + 9 x2 + x3 subject to # x1 + 2 x2 + 3 x3 <= 9 # 3 x1 + 2 x2 + 2 x3 <= 15 # f.obj <- c(1, 9, 3) f.con <- matrix (c(1, 2, 3, 3, 2, 2), nrow=2, byrow=TRUE) f.dir <- c("<=", "<=") f.rhs <- c(9, 15) # # Now run. # lp2("max", f.obj, f.con, f.dir, f.rhs) lp2("max", f.obj, f.con, f.dir, f.rhs, free.var = c(0, 1, 0))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.