I'm looking into absolute function minimization problem in Java. Can anyone suggest libraries and solutions?
apache common math3, however, could not find related functions to create linear function to minimize absolute functions.
Simply, I am looking into writing below functions in Java.
f(x) = b + | x - a | + d + | x - c | + f + | x - e |
I've edited this problem a bit for my second problem, here b, d, f are also linear functions.
b = a1x + b1 d = a2x + b2 f = a3x + b3
If you are summing N terms of the form
|x - a_i|, consider the gradient as
x increases from negative infinity:
a_ivalues, the gradient increases slightly, to
a_ivalues, the gradient increases again, to
a_ipassed, the gradient increases by 2;
So, the gradient starts negative, increases in steps at each of the
a_i positions, and ends up positive; you're looking for the point or range where the gradient is zero. This will occur "in the middle", i.e. at the median of the values
median(a, c, e).