Hi list,

I want to find the total maximum resources I can spend given a set
allocation proportion and some simple budget constraints.

However, I get suboptimal results via lp and friends (i.e. lpSolve and
simplex in the linprog and boot) .

For example:

library(lpSolve)

proportions = c( 0.46, 0.28, 0.26)
constraints = c( 352, 75, 171)

lp(objective.in = proportions,
   const.mat = diag(c(1,1,1)),
   const.rhs=constraints,
   const.dir=rep('<=',3),
   direction='max'
   )

## > Success: the objective function is 227.38
227.38 * proportions #[1] 104.5948  63.6664  59.1188 (OK all less than
constraints, however...)

267 * proportions ## [1] 122.82  74.76  69.42 (... a better result is
possible)

## This example goes over the budget constraints

proportions2 = c( 0.47, 0.28, 0.25)
constraints2 = c(12, 7, 99)

lp(objective.in = proportions2,
   const.mat = diag(c(1,1,1)),
   const.rhs=constraints2,
   const.dir=rep('<=',3),
   direction='max'
   )

## > Success: the objective function is 32.35
32.35 * proportions2 ##[1] 15.2045  9.0580  8.0875 1st and second values are
higher than the constraints allow!!!

Any help gratefully received.

Best regards,
Selwyn

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to