# Can we use ILP here?

Is it possible to encode $y=0\implies G=0$ else $G=x$ by Integer Linear Programming where $x,y,G$ are integer variables?

The answer mentioned below gets to the point of taking absolute value of difference of two integers $a,b$. How do we get $|a-b|$ from ILP?

If $y$ is binary, $x$ is non-negative and you know upper bound for $x$, you can calculate this as: $G = \min(y \cdot K, x)$ where $K$ is greater than the upper bound.
If you only know the upper bound for $|x|$ and $|y|$, you can generalize this solution using tricks similar to https://blog.adamfurmanek.pl/2015/10/17/ilp-part-9/ . You basically need to compare $y$ with zero and use conditional operator (which is just a multiplication).