Haha!! I know, I know. I still get nightmares about starting three part series on Memcached. Whose second and third part I never ended up writing, despite promising about it in multiples posts. I can only picture myself finishing that on a super lazy day, away from city, lying on a beach and that's not happening soon :).
So, I have been reading about Genetic Algorithms since last one week. Very fascinating subject and I
will not write any theory on this as there are already well written information on this (how else would I learn about it? :)). See notes.
So, I be dividing the whole thought train in four posts. Yeah, here I go again :)
- Introduction: I intend to write my notes and some thoughts about Genetic Algorithms. I will skip most of the theory but following paragraphs can definitely serve as a starting point.
- API: I will primarily be writing a Java package for writing further code using this approach. Just interfaces which will serve as guide.
- PathFinder: Using the package written in second post. I will try solving an interesting problem of finding a path. There be tons of code :).
- Eight Queens: Well, everyone can recall this problem from childhood days. It will be a good candidate for testing power of this approach.
The Need
Programming is as much challenging a task as it is fun. From the very start, language designers have tried modeling various paradigms
around real world. In the starting there was only machine code then came better instruction set then came functional programming
and then object oriented programming. Advancement here is the increasing ability to model the code as near to real world; so it can aid in thinking and understanding for humans. But are we actually mimicking the real world while solving problems?
Genetic algorithms is a problem solving approach which tries to mix evolutionary biology with computer science. Idea is not to find an exact solution but an acceptable solution without actually writing the steps. Sounds magical? (Read the links in notes)
Idea is to
1) Create a population
2) Give it a goal
3) Give means to approach towards that goal but not the solution
4) Kill the population
5) Have some way to measure effectiveness of the ones who lived
6)
Select the best
7) Mutate (optional)
8) Create new generation with some experience from the best in previous
9) Repeat the process until some generation solves the problem
That's how nature works. Right?
Algorithm Vs Genetic AlgorithmsTerm algorithm in "Genetic Algorithm" is misleading in a way. Algorithm translates into series of steps which transforms a given input into
expected output. The keyword here is expected. I know precisely what output I will get if I pass (4, 6, 2, 2) to any sorting algorithm.
The problems solved using GA approach are of different nature. What if I want to simulate some situation whose outcome I don't know. War games? Affect of population increase on existent resources? Machine learning.
Applications
- Simulation
- Machine Evolution aka machines making other machines
- Machine Learning
Notes:http://en.wikipedia.org/wiki/Genetic_algorithmhttp://www.ai-junkie.com/ga/intro/gat1.html