For quadratic programming, the trick can be implementing an constant. Example:
$$H = A^T Q A$$
$$Min: \frac{1}{2}x^THx + c^T x$$
Where $Q = \alpha I$
This gives more smooth optimal values. Just set $\alpha$ to a value like 0.85 and everything will be fine.
But how would I do that for linear programming?
$$Max: c^Tx$$ S.t $$Ax \le b \\ x \ge 0$$
I know that for ordinary least squares:
$$x = (A^TA)^{-1}A^Tb$$
Then we can add this feature and it will give us a regularized solution.
$$x = (A^TA + \alpha I)^{-1}A^Tb$$
But how should I write my objective function so it has the feature as well?
Here is the answer!
Let's say that you have the system $Ax = b$. OK! Then you want to find $x$ with regularization.
Use ordinary least square:
$$x = (A^TA + \alpha I)^{-1}A^Tb$$
If you want the same result, but using linear programming.
$$max : c^T x$$ With S.t to: $$Ax \le b \\ x \ge 0$$
Then you need to replace the constraints and the objective function to:
$$max : (A^TA + \alpha I)^Tb x$$ With S.t to: $$(A^TA + \alpha I)x \le A^Tb \\ x \ge 0$$
GNU Octave example: