Learn R Programming

lpSolveAPI (version 5.5.2.0-17.12)

get.type: Get Type

Description

Retrieve the type of a decision variable from an lpSolve linear program model object.

Usage

get.type(lprec, columns = 1:n, as.char = TRUE)

Value

either a character vector with elements from the set {"real", "integer"} indicating the type of each decision variable specified in columns or (if as.char = FALSE) a logical vector with TRUE elements corresponding to the integer decision variables specified in columns.

Arguments

lprec

an lpSolve linear program model object.

columns

a numeric vector of unique values from the set {1, ..., n} (where n is the number of decision variables in lprec) specifying the columns for which the type will be retrieved.

as.char

a logical value. If TRUE the constraint type is returned as a character string, otherwise the integer code used internally by lpSolve is returned.

Author

Kjell Konis kjell.konis@me.com

Details

The function set.type can be used to set a decision variable as binary. A binary decision variable is simply an integer decision with an upper bound of one and a lower bound of zero - hence this function will report the type as integer.

References

https://lpsolve.sourceforge.net/5.5/index.htm

See Also

set.type

Examples

Run this code
lps.model <- make.lp(0, 3)
xt <- c(6,2,4)
add.constraint(lps.model, xt, "<=", 150)
xt <- c(1,1,6)
add.constraint(lps.model, xt, ">=", 0)
set.type(lps.model, 2, "binary")
xt <- c(4,5,4)
add.constraint(lps.model, xt, "=", 40)
set.type(lps.model, 3, "integer")
set.objfn(lps.model, c(-3,-4,-3))

get.type(lps.model)

Run the code above in your browser using DataLab