0

Is there any way to define constraint for lpSolve as a set of discrete values. E.g., I can define constraint with '<=','=','>=':

    fn.obj <- c(3.62, 5.19, 7.29, 7.76, 3.82, 4.86, 4.03, 8.81, 9.14)
    require(lpSolveAPI)
    ...
    add.constraint(model, c(70,70,-30,70,-30,-30,-30,-30,70), ">=", 0)
    ...

What if I just want my x[1],x[2],...,x[9] each to be in a discrete set of values like:

    x[1] in c(20000,25000,30000,35000,40000,45000,50000)
    ...
Alex
  • 533
  • 4
  • 12
  • 3
    There's no such option in LPSolve, but since your values are equally distant, you can define (for each x) a new integer variable z1, and 2 other constraints: `x1 = z1 * 5000; 4 <= z1 <= 10` (of course you can also simply define x1 as integer in [4-10] and multiply by 1/5000 constant wherever you use x1) – digEmAll Jun 07 '16 at 10:44
  • Thank you, @digEmAll. Is there any way to add these new constraint without adding 9 more variables into my model? – Alex Jun 13 '16 at 10:03
  • please post a small but complete model example (not just some lines as in your question) and I will try to modify it and explain how to do that ;) – digEmAll Jun 13 '16 at 10:14

0 Answers0