## More On Absolute Value
I needed to model an absolute value in a MIP model. I could have used one of the methods described in the very good revi I am given a binary variable z and an integer variable x such that 0 <= x <= 2 z = abs(x-1) The rest of the model is such that we cannot assume we minimize z. This is therefore a non convex constraint.
The method I used works for any function of x. In order to model z = f(x) we introduce one binary x
In this case, we introduce x
1 = x
x = 0 x
z = 1 x We can derive in turn this equivalent set of constraints
z = x
1 = z + x
x =
We can then eliminate x
z >= x
x = These constraints imply the bounds on x, hence these bounds can be removed. The end result seems simpler and more efficient in our case than the methods described in Paul's post. Readers should still read his post if faced with more general cases than mine. |