6

I'm working on a MILP (Mixed-Integer Linear Programming) problem with the Java API of Cplex.

In order to easily exclude some variables from my problem I thought about setting both their lower and upper bound equal to '0.0'.

Now I have these questions:

  • Could it be a good solution to achieve my goal, or does it have any particular drawbacks?

  • Will, in this case, the simulation time be longer than the situation where I just eliminate those variables?

  • If a variable, with both upper and lower bounds equal to '0.0', is multiplied by a coefficient equal to '0.0', could it be a problem for any reason (e.g.: from a numerical point of view, etc)?

rainbow
  • 307
  • 1
  • 7
  • No. That will be taken care by the Presolve step of CPLEX because that is what its intended to do i.e. to remove all the redundant info in the modeling. – chupa_kabra Aug 23 '21 at 05:47

1 Answers1

5

Unless you turn off the presolve step, CPLEX will eliminate the variables that are locked at zero during presolve. So the answer to your second question is that presolve may take slightly longer (but the difference will be too small to notice) and the actual branch-and-cut phase will not take any longer than if you had omitted the variables yourself. The answer to your third question is that there will be no issues, since the variables will have been eliminated. (There would be no problem in any case.)

Circling around to whether it is a good idea, I would say that there are at least two potential benefits and no liabilities. The first potential benefit is that the model may be a bit easier to read by someone other than yourself, since you avoid having to define subsets of indices for which the variables should not exit. The second potential benefit is that you can create vectors or matrices of variables without having to do any reindexing. There are a number of methods in the Java API where the arguments can be IloNumVar[]. If you pass in an array in which some elements are missing/undefined, CPLEX will throw an exception. So either you get creative with indexing (sales[i] is the i-th included sales variable as opposed to sales of the i-th product, or whatever), which is a PITA and prone to user error, or you pass in the full vector (sales[]) and let CPLEX skip over the variables that are fixed at zero.

For what it's worth, I frequently use the lower bound = upper bound = zero technique when some variables should be fixed at zero.

prubin
  • 39,078
  • 3
  • 37
  • 104
  • And is it better to work with the bounds, rather than fixing the variable value in the constraints directly ? – Kuifje Jul 15 '21 at 15:41
  • If the presolver removes 80% of the nonzero elements, I feel a bit embarrassed. – Erwin Kalvelagen Jul 15 '21 at 21:15
  • 1
    @Erwin Why? The solver works for you, not the other way around. :-) – prubin Jul 16 '21 at 15:00
  • @Kuifje I doubt it makes a difference in the final model. I suspect it is slightly less work for the solver when you use bounds, and it definitely makes the model passed to the solver a bit smaller. – prubin Jul 16 '21 at 15:03
  • I know, I am super old-fashioned. I like to generate small models and if there are redundancies in the model, I'd like to understand them. And once I understand them, I want to prevent them. Same with the issue @Kuifje mentioned. I always try to use bounds instead of singleton constraints. Just for model hygiene. Or maybe more psychological: makes me feel better. – Erwin Kalvelagen Jul 16 '21 at 15:50
  • 1
    @prubin comment "The solver works for you, not the other way around. :-) – " That depends on whether you are a customer or employee of the solver company. – Mark L. Stone Jul 21 '21 at 19:32