# Is it more efficient to capture many constraints in one constraint?

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.

• 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. – Mark L. Stone Jun 15 at 15:43
• 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. – Tafel Poot Jun 15 at 15:52
• You can simply drop these variables from the problem. In practice the variables will be removed from the problem during preprocessing. – Brian Borchers Jun 15 at 15:58

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.