Skip to content
Prev 301737 / 398506 Next

Optimization help

On Mon, Jul 30, 2012 at 06:51:47AM -0700, Megh Dal wrote:
Hi.

As stated, there are no constraints on x5, x6, x7. So, these will be 0.
Try the following

  library(lpSolve)
  mat <- rbind(
    c(1, 1, 0, 0),
    c(0, 1, 1, 0),
    c(0, 0, 1, 1))
  obj <- rep(1, times=ncol(mat))
  dir <- rep(">=", times=nrow(mat))
  rhs <- c(80, 65, 40)
  out <- lp("min", objective.in=obj, const.mat=mat, const.dir=dir, const.rhs=rhs, all.int=TRUE)
  out$solution

  [1] 55 25 40  0

Hope this helps.

Petr Savicky.