Illustration of a Genetic Algorithm in a Dynamic Environment

Genetic Algorithms are something that I have written about several times on the blog. It’s a powerful way of finding solutions to problems which does not require a lot of specialized knowledge about the space of solutions in which you are operating. This is a genetic algorithm that is being used to find the maximum value of the 3D function seen in the video. There are 10,000 points representing 10,000 individuals in each generation of the algorithm. The greener the point, the more fit that individual is. The bluer the point, the less fit that individual is. The landscape over which the population is trying to find the maximum value is composed of the red and white areas in the video. White areas are areas of positive values; the whiter, the more positive. Red areas are areas of negative values; the redder, the more negative. The landscape is changing over time which forces evolutionary change in the population.

The information about each generation displayed in the video, which can be more clearly seen by looking at the full screen version, shows that the best solution given by the genetic algorithm is always very close to the maximum possible value even when the average of the population is relatively far away. In the dynamic environment which I modelled, I used a large population because it made for a more compelling visualization. However, in the real application, much smaller populations would work just as well. What the simulation shows clearly is that even in somewhat complicated situations, genetic algorithms can be feasible solutions to a problem. I am going to provide detailed code showing the simplicity of the core algorithm that produces such useful outcomes. What I want you to keep in mind is how simple the code is and how closely it matches the road map that I gave in my article outlining the basics of this kind of algorithm.

2 thoughts on “Illustration of a Genetic Algorithm in a Dynamic Environment

    • Hi Amit,

      I wrote the algorithm in C++ and I used the Easy BMP library to make bitmap images at different stages. Then I used bmp2avi.exe to convert it to a video. The video ended up being quite large so I used the built-in Windows software to convert it to something smaller.

      I was satisfied with the results but I think the quality could be improved with some tweaking of settings.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s