Learn R Programming

lpmodeler (version 0.2-1)

addConstraint: Add a new constraint to a LP or MIP

Description

addConstraint creates a new constraint (<,>, <=,>=, ==) and adds it to a linear program (LP) or mixed integer program (MIP) represented by an object of class lpmodeler.

Usage

addConstraint(p, sense, rhs, coefs = NULL, name = NULL)

Arguments

p
an object of class lpmodeler
sense
sense of the constraint (<, >, <=< code="">, >=, == or !=)
rhs
right hand side of the constraint
coefs
optional coefficients of the variables in the left hand side of the constraint
name
an optional string to name the new constraint

Value

An object of class lpmodeler.

Details

TODO

See Also

TODO

Examples

Run this code
p <- newProblem()

# add variables x and y
p <- addVariable(p, "C", 5, "x")
p <- addVariable(p, "C", 4, "y")

# add the constraint: x + 2y >= 5
p <- addConstraint(p, ">=", 5, c(1, 2), name = "x+2y greater or equal than 5")

# add the empty constraint: <= 10
p <- addConstraint(p, "<=", 10, name = "less or equal than 10")

Run the code above in your browser using DataLab