Typically, a genetic algorithm works by the notion of maximizing the fitness. Consider a function y=x, which is to be minimized in the interval [5,5]. One approach is use 1x as the fitness function. Intuitively, by maximizing 1x, we are minimizing y=x. However, a plot of 1x reveals some serious flaws.

fig1.png
Figure 1. Plot of y=1x

If we move from the right, the maximum occurs at x=0 instead of x=5. Why? because 1x is not differentiable at x=0. Always make sure that the fitness/loss function is differentiable! In this case, it is better to use y=x as the fitness function.

In general, if we are seeking to minimize y=f(x), where f(x) is differentiable, then it is safer to use y=f(x) as the fitness function. Probably very obvious, but I got burned by this.