# Is it possible to express inequality constraints as equality constraints?

For quadratic programming, the objective function is:

$$\text{min } \frac{1}{2}x^TQx + c^Tx$$

Subject to: $$Ax \leq b$$

These QP-solvers that can only handle inequality constraints are the most simplest QP-solvers. But adding an equality constraints together with the inequality constraints, can turn the QP-solver to a much more advanced QP-solver.

I got therefore a question. What if I could do like this:

Subject to: $$Ax \leq b$$ $$Gx \leq d$$ $$-Gx \leq -d$$

For example if $$G = 5$$ and $$d = 7$$. Assume that we say $$x = 0.5$$

5*0.5 <= 7.0 // Yes
-5*0.5 <= -7.0 // No


If I say $$x = 1.4$$

5*1.4 <= 7.0 // Yes
-5*1.4 <= -7.0 // Yes


If I say $$x = 1.5$$

5*1.5 <= 7.0 // No
-5*1.5 <= -7.0 // Yes


Question:

By using the same inequality constraints, but adding a negative sign on both sides, does this turn two inequality constraints into an equality constraint?

$$Gx = d$$

Or is it important to have some kind of a small number $$\epsilon$$ ?

$$Gx \leq d + \epsilon$$ $$-Gx \leq -d - \epsilon$$

Yes it works!

Q = [1.200 -5.1000; -5.1000 26.0000];
c = [-2; -6];

% Inequality constraints
A = [1 1; -1 2; 2 1];
b = [2; 2; 3];

% "Equality" constraints
Aeq = [3 6; 3 1];
beq = [5; 1];

% Internal QP-solver for GNU Octave
[x, ~, info] = qp([], Q, c, Aeq, beq, [], [], [], A, b)

% Internal QP-solver for GNU Octave
[x, ~, info] = qp([], Q, c, [], [], [], [], [], [A;Aeq;-Aeq], [b;beq;-beq])

Output is:

x =

0.066667
0.800000

info =

scalar structure containing the fields:

solveiter = 1
info = 0

x =

0.066667
0.800000

info =

scalar structure containing the fields:

solveiter = 3
info = 0

>>


The only difference is that the QP-solver that using equality constraints as it should be used, was faster than the "trick".