GA Demo: Unimodal Function Optimization

by Amit


Here is a demo of using a Genetic Algorithm for a function optimization. Vital information:

  • Real coded Genetic Algorithm
  • Population size: 100, Generations: 100
  • Crossover: SBX Crossover
  • Mutation: Polynomial Mutation

What do you see?

A. We start with a initial population which is randomly distributed throughout the function landscape. If you have keen eyes, like a friend, Shivam, you will notice that the initial population is not so random. If you increase the population size, the initial population will cover all most all areas of the fitness landscape, like shown in this figure:

With a increased popultion size, the fitness ladscape is well "covered"

B. As the GA evolves, you see more individuals settling in on the two global minima and finally all the individuals settle in only one of the global minima. (A vanilla GA will in most cases converge to the best solution in the fitness landscape, to capture mulitple solutions, we will have to use one of the  GA methods specially developed for that purpose, which are loosely called GAs for multimodal optimization)

C. An interesting thing to see here is that, which one of the minima the individuals go to is completely unpredictable, since our fitness or cost function here is the function value. In this case, since both the minima are global, hence the probability of the GA converging to each is equal and will vary w.r.t the GA parameter settings.

Code

I used an existing RGA implementation and I just hooked it up with gnuplot and xvidcap to capture the population evolution. I f you want to take a look at the code, please let me know and I shall be happy to discuss it with you.

Wishful wish

Such visualizations often help you with understanding the evolution of the population, which otherwise is not so easy. Sadly, we are in a three dimensional space. (which however, I hope is not true).Once that happens, working with GAs will be sure fun- Imagine population of individuals in 10s of dimensions evolving and you seeing them where exactly they are going) :D

Advertisements