Tuesday, January 11, 2011

A Gotcha with function minimization using genetic algorithms

Tyically, 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 1/x as the fitness function. Intuitively, by maximizing y = 1/x, we are minimizing y = x. However, a plot of y = 1/x reveals some serious flaws.

Figure: Plot of y = 1/x

If we move from the right, the maximum occurs at x = 0 instead of x = -5. Why? Probably because 1/x is not differentiable at x = 0. Therefore, it is safe to use y = -x as the fitness function.

In general, if we are seeking to minimize Y = F(X), then it is safe to use Y = -F(x) as the fitness function.

No comments:

Post a Comment