# Correct way to add slack variables to model

I want to add slack variables to the following feasibility problem. Optimally I want the sum of the slack variables to be zero.

Given the problem

$$\min 0$$ s.t. $$e(x) = 0$$ $$l(x) \leq 0$$ $$g(x) \geq 0$$

Is the following a correct way to add slack variables?

$$\min 0 + |\xi_e| + \xi_l + \xi_g$$ s.t. $$e(x) = \xi_e$$ $$l(x) \leq \xi_l$$ $$g(x) \geq -\xi_g$$ $$\xi_l \geq 0$$ $$\xi_g \geq 0$$

Also, if I add a slack variable to one constrain in the model, do I have to add slack variables to all other constraints?

• Hi @Horvetz, welcome to or.stackexchange. Can you elaborate a little om what you want to achieve by adding slack variables? Do you for example need your constraints to be satisfied (zero slack) in an optimal solution
– Sune
Jun 7, 2022 at 20:36
• @Sune Yes. It is a feasibility problem (c = 0). I'll clarify the question. Thanks! Jun 7, 2022 at 20:38

$$\min \xi_e + \xi_l + \xi_g$$ s.t. $$-\xi_e \le e(x)$$ $$e(x) \le \xi_e$$ $$\xi_e \geq 0$$ $$l(x) \leq \xi_l$$ $$g(x) \geq -\xi_g$$ $$\xi_l \geq 0$$ $$\xi_g \geq 0$$
• Yes, if you have a vector or matrix of constraints, i.e.., evaluating to a vector or matrix RHS, i.e., $n$ or $n^2$ or $mn$ (scalar) constraints written in vector or matrix form as a single vector or matrix constraint. In the case of a vector, you can think of using a vector slack variable, with all elements of the slack vector constrained to be nonnengative. If the constraint involves a vector or matrix variable on the LHS, but evaluates to a scalar (i.e., scalar RHS), then there would only be a single scalar slack variable for that constraint. Jun 8, 2022 at 14:30