Natural Computing Blog

Genetic Algorithm – live coding in python

Today we are solving the Travelling Salesman Problem using evolutionary computation.

As Wikipedia says:

In artificial intelligence, an evolutionary algorithm (EA) is a subset of evolutionary computation, a generic population-based metaheuristic optimization algorithm. An EA uses mechanisms inspired by biological evolution, such as reproduction, mutation, recombination, and selection. Candidate solutions to the optimization problem play the role of individuals in a population, and the fitness function determines the quality of the solutions […]. Evolution of the population then takes place after the repeated application of the above operators

Genetic Algorithm were the first, and are possibly the most diffused, subset of evolutionary computation.

Historically speaking, Genetic Algorithms became popular through the work of John Holland in the early 1970s, and particularly his book Adaptation in Natural and Artificial Systems (1975). His work originated with studies of cellular automata, conducted by Holland and his students at the University of Michigan. Holland introduced a formalized framework for predicting the quality of the next generation, known as Holland’s Schema Theorem. Research in GAs remained largely theoretical until the mid-1980s, when The First International Conference on Genetic Algorithms was held in Pittsburgh, Pennsylvania.

And now…

Let’s get coding 😉

Note – This is not a ‘python for beginners’ tutorial, although I myself only started using python recently. The video does not show all the time I paused the actual coding to lookup references online. It also gives very little explaination of how python works. I assume you can all stop, look at what I write, and check online if you want to know more about how python or its libraries pandas, random, and numpy work.

The truth is that you don’t really need to know python that much to follow along, and it may be a good tutorial to get you started coding an AI system with this language. It is expected that you know how to code though, at least a little bit (knowing about variables, functions, classes and all that basic stuff basically)

All the source code is available on my gitHub >>HERE <<


Leave a Reply

Your e-mail address will not be published. Required fields are marked *