Tuesday, April 6, 2010

GAlib: The Genetic Algorithms API

I came across this excellent C++ library for programming Genetic Algorithms: GAlib.

It offers a really simple interface to program any type of GA's. Any GA comes with 3 design issues:
  • Deciding the encoding
  • Deciding the genetic operators
  • Deciding the evaluator function
GAlib comes with many inbuilt representations and operators for almost all kinds of GA-related problems. The evaluator function is, predictably, left for the user to define.
GAlib comes with inbuilt genome representations like binary strings(1-D, 2-D and 3-D), arrays(1-D, 2-D and 3-D), lists, and trees.
Also inbuilt are various GA paradigms like 'simple', 'steady-state', and 'incremental'.
For each representation, GAlib includes various operators for crosssover, mutation and selection, etc.
GAlib also gives you freedom to create your own representations and operators if you wish so.

Personally, I found it quite helpful in my projects, and would recommend it to anyone looking to study genetic algorithms.
Cheers.

Tuesday, March 9, 2010

Genetic Algorithms

All great innovations have been inspired by observation from nature. Even Newton's laws came into being when Newton observed the falling apple. Likewise genetic algorithms were derived from the "Survival of the fittest" theory. For those who don't know the theory, I will give a brief description here.

The theory suggests that in a population of individuals, some individuals have better characteristics than others. These characteristics allow those individuals to better adapt to their environment. These individuals are said to be fitter than the rest. Due to the environmental conditions, these fit individuals survive while those that are unfit perish away. The fit individuals reproduce and pass on the characteristics to their offspring. Thus, over successive generations, the individuals become fitter and better suited to survive in their environment.

The characteristics described above are encoded in what is known as a gene, which are present in every organism's DNA. It is from these genes that the term "genetic algorithms" was coined.
Genetic algorithms are basically search algorithms that employ the concepts of natural selection and survival of the fittest to find the optimal solution to a problem.

A typical genetic algorithm has the following stages:
  1. Encoding of characteristics on a chromosome.
  2. Generation of a random population of chromosomes.
  3. Evaluating the fitness of each individual on the basis of a fitness function.
  4. Selecting the individuals that would act as parents for next generation.
  5. Forming a new generation through recombination and/or variation.
  6. Repeating steps 3-5 until the population converges to an optimum solution.
In a real-life scenario, the fit individuals are selected on the basis of ability to survive in the environment. Similarly, in a genetic algorithm the factors that simulate this environment are:
  • the encoding of chromosomes.
  • the fitness function.
Other factors that that are important are:
  • the criterion for selecting parents for next generation.
  • the techniques used for recombination and variation.
These are quite important in that if they are too strict we might end up converging to a local maximum, and if they are too lenient, it might take a long time to get the population to converge to an optimal solution. So, the optimal genetic algorithm should be balanced enough to explore new regions in the solution space and yet be able to achieve convergence in reasonable time.

Genetic algorithms have been employed in a wide variety of problems, ranging from biology to chemistry to finance. One of the major applications is to use genetic algorithms to evolve neural networks. For more info, you may want to follow these links:

The _uck starts here!

Hello reader,
This is the first post for "The AI effect", my official technical blog. Every now and then I would be putting up posts related to Artificial Intelligence and my work in the field. I hope it is worth it. If any of my posts helped you in any way or gave you a new idea, please do comment and let me know.
Thank you.