Genetic algorithms - how they can be useful?
Recently, my friend George told me that he successfully used Genetic algorithm in his application.
Problem
Application execute some deep analyzing of the data. The application use up to 10 heavy alternative analyzing techniques to archive the goal. Each of analyzing technique has some results accuracy, and it can give wrong results. So, the application run several analyzing techniques on same data and summarize the result.
The problem is: each analyzing technique have up two 20 settings. To archive the maximum performance and accurateness- it need to find the best values for those settings.
The simple iterates through all possible values ("Brute-Force") of all 20 settings is not impossible - analyzing algorithms is too heavy and require from 1min to 30min to complete.
The experimenting and manual analyzing is possible, but it require too much time and is tricky one.
Also, if analyzing algorithm code changed with the time -old values become not effective and need to find a new one.
Solution
The Genetic algorithm was used to find a best application settings for each of analyzing algorithm.
So, if damn "Brute-Force" will require like a billion executions, then Genetic algorithms performing a "wise" search required only thousand of executions to find a best application settings. This is incredible!
To implementation of some simple Genetic algorithm (GA) require:
Some simple articles to start with:
Problem
Application execute some deep analyzing of the data. The application use up to 10 heavy alternative analyzing techniques to archive the goal. Each of analyzing technique has some results accuracy, and it can give wrong results. So, the application run several analyzing techniques on same data and summarize the result.
The problem is: each analyzing technique have up two 20 settings. To archive the maximum performance and accurateness- it need to find the best values for those settings.
The simple iterates through all possible values ("Brute-Force") of all 20 settings is not impossible - analyzing algorithms is too heavy and require from 1min to 30min to complete.
The experimenting and manual analyzing is possible, but it require too much time and is tricky one.
Also, if analyzing algorithm code changed with the time -old values become not effective and need to find a new one.
Solution
The Genetic algorithm was used to find a best application settings for each of analyzing algorithm.
So, if damn "Brute-Force" will require like a billion executions, then Genetic algorithms performing a "wise" search required only thousand of executions to find a best application settings. This is incredible!
To implementation of some simple Genetic algorithm (GA) require:
- Hight-level underspending of how Genetic algorithm working. You can start with Wikipedia. :)
- Write your own, specific to you needs and goals following main GA methods:
- Solution Representation - a genetic representation of the solution domain (it is like DNA).
- In our case it is 20 settings represented as bytes.
- Fitness Function - quality of the represented solution, like how our DNA solves the problem.
- In our case it is some static function which accepts our 20 setting as parameter and return some integer.
- Inside this function our analyzing algorithm should be executed (took 1min to 30min). When done - we calculate result like this: <results accuracy compared to expected>. (from 0-to <Int max>), more is better.
- Mutation function (optionally, some common implementation can be used)
- Crossover function (optionally, some common implementation can be used)
- "A crossover operation combines data in the hash maps of two parents, and then it creates a vector of slots according to the content of the new hash map. A crossover 'splits' hash maps of both parents in parts of random size. The number of parts is defined by the number of crossover points (plus one) in the chromosome's parameters. Then, it alternately copies parts form parents to the new chromosome, and forms a new vector of slots."
Some simple articles to start with:
- http://www.codeproject.com/KB/recipes/GaClassSchedule.aspx
- http://www.codeproject.com/Articles/3172/A-Simple-C-Genetic-Algorithm
- http://www.c-sharpcorner.com/UploadFile/mgold/GeneticAlgorithm12032005044205AM/GeneticAlgorithm.aspx
Comments
Post a Comment