addConstraint: Add a new constraint to a LP or MIP

Description Usage Arguments Details Value Author(s) See Also Examples

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

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

Arguments

p

an object of class lpmodeler

sense

sense of the constraint (<, >, <=, >=, == 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

Details

TODO

Value

An object of class lpmodeler.

Author(s)

Cyrille Szymanski <cnszym at gmail.com>

See Also

TODO

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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")

lpmodeler documentation built on May 2, 2019, 2:46 p.m.