Implement the following problem using genetic algorithms in any programming language
(e.g. C++/python/java):
Problem
Suppose your “individuals” are 32-bit computer words. You want a string in which all the bits are ones.
Here’s how you can do it:
- Create 100 randomly generated computer word
- Repeatedly do the following:
- Count the 1 bits in each word
- Exit if any of the words have all 32 bits set to 1
- Keep the ten words that have the most 1s (discard the rest)
- From each word, generate 9 new words as follows:
- Pick a random bit in the word and toggle (change) it
- Note that this procedure does not guarantee that the next “generation” will have more 1 bits, but it’s likely.
THANKS ALOT!
Top comments (1)
Please help me to solve this algorithm. I am stuck with this algo.