Dealing with ABSOLUTE VALUE and IF STATEMENT in linear integer programming

integer programminglinear programming

I am trying to write a linear constraint that computes the absolute value of a difference, only if both the variables $x$ and $y$ are different from zero.

$x,y$ are binary variables while $s$ is a positive integer variable. $a$ and $b$ are positive integer coefficients.

$|xa-yb| \leq s$ only if $x \neq 0$ and $y \neq 0$

for the first part I did:

$(xa-yb) \leq s$ and $-(xa-yb) \leq s$

but I don't know how to proceed with the second part, if that is ever possible.

Thank you in advance

Best Answer

You can enforce $$(x = 1 \land y = 1) \implies |a-b| \le s$$ with linear constraint $$|a-b|(x + y - 1) \le s.$$

Do you instead (or also) want to enforce $$|a-b| \le s \implies (x = 1 \land y = 1),$$ which is the converse?