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$
I think this needs to be modeled as a MIP:
\begin{align} \min\> & z\\ & -z \le y_1 - y_2 \le z\\ & y_i \ge x_i - a_i\\ & y_i \ge -(x_i - a_i)\\ & y_i \le x_i - a_i + \delta_i M\\ & y_i \le -(x_i - a_i) + (1-\delta_i) M\\ & \delta_i \in \{0,1\} \end{align}
where $M$ is large enough constant.