How to write an absolute value expression in linear programming?

6.3k Views Asked by At

My objective function for the Xpress-IVE (Mosel lang) model is

minimize |a-b|

where a and b the number of elements in the decision variables which are arrays.

Since there is no function to calculate the absolute value, i want to get something of the form

objective = max(a,b) - min(a,b)

and then minimize the objective

What I have tried: introduced two variables x and y with the following constraints: x >= a x >= b y => a y => b and re-written the objective as x-y

But this gives me zero as the solution.

Could I please get a hint on what i am doing wrong?

1

There are 1 best solutions below

6
On

Minimizing $$ Z=|a-b| $$ is equivalent to minimizing $$ Z=\omega, $$ subject to the constraints $$ a-b\le \omega\\ b-a \le \omega $$