Skip to content
Prev 295527 / 398502 Next

Upper an lower bound in linear programing

On Thu, May 24, 2012 at 07:16:20AM -0700, Haio wrote:
Hello:

The formulation of an LP problem allows to use the objective
function also as a row in the constraint matrix. So, it is
possible to set a constraint on it. For example,
maximizing x + y
under the constraints
  x/4 <= y <= 2 + x/3
  x + y <= 9  (constraint on the objective function)
may be done as follows

  library(lpSolve)
 
  crit <- c(1, 1)
  mat <- rbind(
  c(-1/4, 1),
  c(-1/3, 1),
  c( 1,   1))
  dir <- c(">=", "<=", "<=")
  rhs <- c(0, 2, 9)
 
  out <- lp("max", objective.in=crit, const.mat=mat, const.dir=dir, const.rhs=rhs)
  out

  Success: the objective function is 9

  out$solution

  [1] 7.2 1.8

Hope this helps.

Petr Savicky.