Linearize if statement in linear programming

I am having trouble figuring out how to formulate the following objective function in LP

a + b + (if(c < d) then e else 0)

Where a, b, c, d and e are some sums or differences of variables multiplied by some real constants. I thought that maybe by introducing a binary variable x I could redefine it as

a + b + xe

But that would no longer be linear, not to mention even then I couldnt come up with what constraints x would need to have...

Any help with this would be greatly appreciated, Ive been racking my brain and googling left and right for hours now, but with no clear solution in sight.

Edit: For full context, I am trying to minimize distance and trying to use the last distance approximation formula found here: http://www.flipcode.com/archives/Fast_Approximate_Distance_Functions.shtml


Solution 1:

Let the objective be $a + b + q$ and use the big M trick.

Letting $\delta$ be the binary variable, we first define constraints such that $\delta = 0$ if $c \leq d$ and $\delta = 1$ otherwise.

$$ c \leq d + M \delta \\ c \geq d - M (1 - \delta) $$ where $M$ is a large number. Then we define constraints such that $q$ gives the values required.

$$ e - M\delta \leq q \leq e + M \delta \\ - M(1 - \delta) \leq q \leq e + M (1 + \delta) $$