# Linear programming: Converting nested absolute value

I am having trouble converting the following objective function into LP: $$\min\left\lvert(\left\lvert x_1-a_1\right\rvert-\left\lvert x_2-a_2 \right\rvert )\right\rvert$$ where $x$ is the decision variable and $(a)$ is an integer constant.

I tried adding the following constraints, but it did not work out:

$x_i-a_i\le y_i$

$a_i-x_i\le y_i$

$y_1-y_2\le U$

$y_2-y_1\le U$

• Why it didn't work out? The only step missing is $\min U$, since we have $y_i \ge 0$. – GNUSupporter 8964民主女神 地下教會 Jan 29 '18 at 1:42
• I think the inner absolute values need to be modeled with binary variables (that part is non-convex). – Erwin Kalvelagen Jan 29 '18 at 19:40

where $M$ is large enough constant.