This is the seventieth fourth part of the ILP series. For your convenience you can find other parts in the table of contents in Part 1 – Boolean algebra
We know how to calculate absolute value and how to compare real numbers.
The original formula uses comparisons:
      ![Rendered by QuickLaTeX.com \[ \left(r + a \stackrel{?}{=} 0\right) \vee \left(r - a \stackrel{?}{=} 0\right) = 1 \]](../../../../wp-content/ql-cache/quicklatex.com-f696a9de6110c919154e105574d3372b_l3.png)
where  should be an absolute value of
 should be an absolute value of  . We know that
. We know that  is at least
 is at least  and we use the formula above to enforce the equality. Effectively, we want to say that
 and we use the formula above to enforce the equality. Effectively, we want to say that  is either equal to
 is either equal to  or
 or 
We know that this is very dangerous as it implicitly requires  to be at least
 to be at least  . However, we don’t need to compare numbers precisely. What we need is a formula which will not allow for
. However, we don’t need to compare numbers precisely. What we need is a formula which will not allow for  to be greater than
 to be greater than  . Let’s introduce this unreliable comparison:
. Let’s introduce this unreliable comparison:
      ![Rendered by QuickLaTeX.com \[ 0 \le r - a - Kx \]](../../../../wp-content/ql-cache/quicklatex.com-81228ba095eaf09e1967e31f059cb793_l3.png)
if  then
 then  must be one. However, if
 must be one. However, if  then
 then  is already non-positive so
 is already non-positive so  can be either zero or one.
 can be either zero or one.
However, important part for us is that if  then
 then  will be one. So now we can do two comparisons:
 will be one. So now we can do two comparisons:
      ![Rendered by QuickLaTeX.com \[ \left(r \stackrel{?}{\~>} a\right) \vee \left(r \stackrel{?}{\~>} -a\right) = 1 \]](../../../../wp-content/ql-cache/quicklatex.com-6dfba7984112dd563d060cb6ed2bf17e_l3.png)
If  then both comparisons would yield true which in turn would violate the constraint. Since we know that
 then both comparisons would yield true which in turn would violate the constraint. Since we know that  is at least
 is at least  then there is no other way as to set
 then there is no other way as to set  . This works because solver can choose any result for unreliable comparisons.
. This works because solver can choose any result for unreliable comparisons.
This can be used for integer values as well. We can effectively calculate absolute value without any comparisons (which break the model for real numbers). Same goes for maximum and minimum, we can calculate these in a safe manner.