Genetic Algorithm’s provide a way to let the algorithm evolve into it’s natural optimum. If done properly, over a long enough period of time, it can be extremely effective. The key to creating a useful genetic algorithm is the fitness tests. It’s survival of the fittest in action.
My theory is that using Unit Tests as a first-entry (or “health”) fitness test, could very well be a way to creating genetic algorithms that can learn to program. The trick here is to create unit tests that are all encompassing. They should test each and every aspect of the program.
Fitness tests would then be layered:
- Does it compile / run
- Does it pass unit tests
If both of these are true, it survives. Then we can add in additional fitness tests, for instance, we can compare each generation’s run time, memory usage. Maybe we toss in code quality metrics as well. All of these can be automated, so it’s conceivable that each of these could be used as a fitness test.
Now, this is just a theory. I haven’t tested it, but please feel free. I may test it when I have time, and if I do I’ll update this post / write a new one.