Minimize difference between 3 positive variables

295 Views Asked by At

I have a very simple problem to solve, but I'm trying to find the best way to do it. Suppose we have variables $x, y, z$ (all positive and real). I basically want to set up an optimization where all three variables should be as close as possible to each other (but not exactly equal). One approach I'm taking is to construct the following vector $$P(x,y,z) = \begin{bmatrix}x - y \\ x - z \\ y-z \end{bmatrix}$$

and then $$\min_{ \{x,y,z\} \in \mathbb{R}^+} \| P(x,y,z)\|_2$$ With no other constraints, this optimization will obviously yield $x=y=z$. Lets suppose that we have other constraints such that $x\neq y \neq z$. Then what would be the best way to formulate a problem such that $x, y, z$ are all as close as possible to each other?

Your help is much appreciated!

1

There are 1 best solutions below

3
On

Your quest is for minimization under constraints. Suppose that you want to minimize $\|P(z,y,z)\|^2$ subject to $a x+b y + c \ge d$. A good way to handle this kind of problems is the lagrangian formulation introducing a slack variable to transform the inequality into an equation, as follows

$$ L(x,y,z,\lambda,s) = \|P(z,y,z)\|^2+\lambda(a x + b y + c z - d-s^2) $$

The minima/maxima points are included into the set of $L(x,y,z,\lambda,s)$ stationary points. Those stationary points are determined by solving

$$ \nabla L = 0 = \left\{ \begin{array}{l} a \lambda +2 (x-y)+2 (x-z) \\ b \lambda -2 (x-y)+2 (y-z) \\ c \lambda -2 (x-z)-2 (y-z) \\ a x+b y+c z-d-s^2 \\ -2 \lambda s \\ \end{array} \right. $$

and then we can find

$$ x = y = z = \frac{d}{a+b+c},\ \ s = 0 $$

$s=0$ meaning that the restriction is active.