lpSolveAPI (version 5.5.2.0-17.6)

get.primal.solution: Get Primal Solution

Description

Retrieve the values of the primal variables from a successfully solved lpSolve linear program model object.

Usage

get.primal.solution(lprec, orig = FALSE)

Arguments

lprec

an lpSolve linear program model object.

orig

a logical value. When presolve is active, the size of the lp may decrease during solve. By default, the answer to this reduced problem is returned. Set this argument to TRUE to retrieve the solution to the original lp.

Value

a numeric vector containing the values of the primal variables. If an error occurs (for instance lprec has not been successfully solved) a NULL value is returned.

References

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

Examples

Run this code
# NOT RUN {
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)
xt <- c(4,5,4)
add.constraint(lps.model, xt, "=", 40)
set.objfn(lps.model, c(-3,-4,-3))

solve(lps.model)
get.primal.solution(lps.model)
# }

Run the code above in your browser using DataLab