genetic algorithm (DNA) (= GA)
Created | Updated Jan 28, 2002
I had to write a program in MODULA-2 (which is really a vogon-language; it's so primitive that even a Babel-fish wouldn't be any help to you) which would resolve the 8-queens-problem by genetic algorithm...
The problem: place 8 queens safely on a chess-board .
The way to the solution: Genetic Algorythm (GA)
For a GA-solution, you begin with a few (+/- 500) wrong solutions (the computer wil choose them on random) and then, it's very simple: The computer chooses 2 specimens from the 500 original 'persons' (who all have a genetic code) and
does like nature:
REPRODUCTION: the 2 'parents' give a part of their genetic code to the 'child': e.g.
The solution you're looking for is (e.g.) 123456
If the 'parents' have as code: 113524 (1st parent) and 126456 (2nd parent), then, the first parent has score = 2/6 and the second parent = 4/6 (2 or 4 right numbers on the right place). The child can (e.g.) have as genetic code 113456 (score = 5/6) which is better than the parents' genetic codes: thus, the 'parent' with the worst score will then die to make place for his 'child'
otherwise, if his score is under 2/6, he won't survive.
MUTATION: you simply take one of the parents and you change one of his numbers (a part of his genetic code)
( e.g.: 113425 -----> 123425 )
If someone's interested in the program, say so and I'll try to set it on this site.
If I were asked to give some comments about this way of solving problems, I surely would say that this is a typical Sirius Cybernatics program, because it does a job which otherwise can be done within 2 seconds in a quarter of an hour ( this is absolutely TRUE; I've tested it, as researcher for the guide). But it's a quite original way of resolving problems, so try it...
OK, I must also admit it's sometimes the only way out of a problem, but surely not in a 'normal' situation...