View source: R/add.constraint.R
add.constraint | R Documentation |
Add a constraint to an lpSolve linear program model object.
add.constraint(lprec, xt, type = c("<=", "=", ">="), rhs, indices, lhs)
lprec |
an lpSolve linear program model object. |
xt |
a numeric vector containing the constraint coefficients (only the nonzero coefficients if |
type |
a numeric or character value from the set |
rhs |
a single numeric value specifying the right-hand-side of the constraint. |
indices |
optional for sparse |
lhs |
optional. A single numeric value specifying the left-hand-side of the constraint. |
Specifying the objective function before adding constraints will improve the performance of this function.
The use of this function should be avoided when possible. Building a model column-by-column rather than row-by-row will be on the order of 50 times faster (building the model - not solving the model).
a NULL
value is invisibly returned.
Kjell Konis kjell.konis@me.com
https://lpsolve.sourceforge.net/5.5/index.htm
lps.model <- make.lp(0, 4)
set.objfn(lps.model, rep(1, 4))
add.constraint(lps.model, c(6,2,4,9), "<=", 50)
add.constraint(lps.model, c(3,1,5), 2, 75, indices = c(1,2,4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.