0

I need to set up all my variables to accept only values from two intervals, e.g. for var C1:

    C1 = 0 or 
    100 <= C1  <= 1000

and so on for each variable.

I can specify either first (=0) or second ([100;1000]) constraints for every variable but I need lpsolve model to to be able to assign either 0 ot any value from given interval.

Any advice appreciated.

Alex
  • 533
  • 4
  • 12
  • This defines a non-convex set, so it can't be formulated by pure linear-programming. You need to introduce a binary variable (resulting in an Mixed-Integer-Program). Then it's just: ```C1 >= 100 * bin-var```, ```C1 <= 1000 * bin-var``` – sascha Jul 09 '16 at 11:37
  • Thank you @sascha! Please correct me if I m wrong, but that approach will require adding constraints explicitly, for example for var _C1_ I need: `C1 - 100*C2 >= 0` and `1000*C2 - C1 >= 0` where _C2_ is my new binary variable. And so on for each of my variables which I want to be in {0 or [100;1000]}. Is it possible to set up upper boundary for all of them at once (e.g. using _set_bounds_ function from _lpsolve_ lib)? – Alex Jul 09 '16 at 12:31
  • Hey @sascha, there is a special type for variable called semi-continuous: http://lpsolve.sourceforge.net/5.5/semi-cont.htm Do you think this is better approach rather than introducing binary vars? – Alex Aug 02 '16 at 10:11
  • 1
    See [this](https://www.or-exchange.org/questions/2720/what-is-the-advantage-of-semi-continous-variables) for some discussion involving experts (and commercial-solver devs). Depending on the solver there could be performance gains; but maybe lpsolve is only doing the binary-var approach automatically (i'm not sure about it's internals). Despite the possible gains: it surely is easier to use. So i would try it! @Alex – sascha Aug 02 '16 at 11:15

0 Answers0