1

I'm working on a problem that involves constraints containing certain kind of expressions, which are to be solved using LPsolve. I can't seem to figure out how to formulate the constraints though.

e.g:- I'd like to reformulate the following constraint:

+0.35 C1 +0.15 C2 +0.15 C3 +0.2 C4 +0.15 C5 +0.15 C6 +0.15 C7 +0.15 C8 +0.15 C9 +0.15 C10 <= 3750; 

as

+(0.35)*(1+C1) +0.15*(1+C2) +0.15*(1+C3)....+0.15*(1+C10)<= 3750;

I've tried using set.constr.value() but that only takes a fixed row as an input.

and then solve for the optimal solution.

Albert Hidalgo
  • 113
  • 2
  • 9
SO user
  • 15
  • 4

2 Answers2

1

To maximize the sum of the Ci variables subject to the constraint given int he question and assuming that they are non-negative:

library(lpSolve)

cc <- c(0.35, 0.15, 0.15, 0.2, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15)
result <- lp(direction = "max", 
   objective = rep(1, length(cc)),
   const.mat = t(cc),
   const.dir = "<=",
   const.rhs = 3750 - sum(cc))

result
## Success: the objective function is 24988.33 

result$solution
##  [1]     0.00 24988.33     0.00     0.00     0.00     0.00     0.00     0.00
##  [9]     0.00     0.00
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341
0

The constraint in the program (assumet C_i >= 0):

+(0.35)*(1+C1) +0.15*(1+C2) +0.15*(1+C3)....+0.15*(1+C10)<= 3750;

is the same as:

+0.35*C1 +0.15*C2 + ... +0.15*C10 <= 3750 - (0.35 + 0.15 + ... + 0.15)

Dont get the point of the question... Pls try to writte down the program in normal form and make your question more precise.

Freakazoid
  • 490
  • 3
  • 10