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)?

  • $\begingroup$ 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. $\endgroup$ Commented Aug 23, 2021 at 5:47

1 Answer 1


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.

  • $\begingroup$ And is it better to work with the bounds, rather than fixing the variable value in the constraints directly ? $\endgroup$
    – Kuifje
    Commented Jul 15, 2021 at 15:41
  • $\begingroup$ If the presolver removes 80% of the nonzero elements, I feel a bit embarrassed. $\endgroup$ Commented Jul 15, 2021 at 21:15
  • 1
    $\begingroup$ @Erwin Why? The solver works for you, not the other way around. :-) $\endgroup$
    – prubin
    Commented Jul 16, 2021 at 15:00
  • $\begingroup$ @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. $\endgroup$
    – prubin
    Commented Jul 16, 2021 at 15:03
  • 1
    $\begingroup$ @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. $\endgroup$ Commented Jul 21, 2021 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.