I have a number of variables that need to be set to 0. They are positive real numbers so the way I see it I can do this by setting each one to 0 by separate constraints, or I can set their sum to zero. Would that help with the efficiency? Im working on some big problems so I would like the the lowest solving time possible.

  • 1
    $\begingroup$ It would help if you provide information for your entire problem. is this s Linear Programming, or perhaps some other optimiIaation problem? if so, you are generally better off elminating these variables from the problem provided to the solver. However, most modern solvers have a presolve phase before the main solver is called which will do that for you. As for your constraint that the sum equals zero, that would only work if all the variables in that sum are also constrained to be nonnegative (or all to be nonpositive) - that may or may not be recognized by the presolve, and is not preferred. $\endgroup$ – Mark L. Stone Jun 15 '19 at 15:43
  • $\begingroup$ Sorry, but I tagged it as linear programming. And by 'they are positive real numbers' I meant nonnegative variables. But it's not preferred then I guess. $\endgroup$ – Tafel Poot Jun 15 '19 at 15:52
  • 3
    $\begingroup$ You can simply drop these variables from the problem. In practice the variables will be removed from the problem during preprocessing. $\endgroup$ – Brian Borchers Jun 15 '19 at 15:58

I'd recommend setting each variable to 0, rather than trying to do something clever.

This is for two reasons:

  1. You might be too clever and make a mistake. For instance, setting each variable to zero is a different problem than setting the sum of a set of variables to be zero (since this constraint still holds if some of the variables take negative values and others positive values). So, even here, the example you suggest in your question would give the wrong answer. You can waste a lot of time tracking down an error like that.

  2. Simple constraints are easier to process than more complex constraints. You're mentally modeling the cost as "two constraints are much more expensive than one complex constraint". But an alternative cost model is: "many simple constraints are still less expensive than one complex constraint". Without knowing details about the solver, it's hard to judge between these; however, I suspect the latter model is closer to the truth. Parsing a statement like a+b+c=0 requires building something like a parse tree, which is expensive. However, it's likely that a solver would add a couple of lines of code to optimize for the special case where, e.g., a=0. Thus, this operation would be relatively much less expensive.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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