I have to do a project which using a genetic algorithm solves the subset sum problem. Unfortunately, when coding the algorithm I found a big problem ...
My algorithm:
(Algorithm was taken from the book "Genetic Algorithms + Data Structures = Evolution Programs, Chapter 2 ") Variables such as population size, amount of data, scope of data collection, number of steps, the number of mutations (in step), the number of crossings (in a step) is set rigidly in the program options.
The problem is that after a certain (relatively small) number of steps in the population all the chromosomes are identical. The problem illustrates this graph: http://imageshack.us/m/96/7693/wykresb.png
What I'm doing wrong? How to fix it? Thanks in advance.
Edit:
Here You can find logs from my app: http://paste.pocoo.org/show/391318/
I think that roulette is not the best solution (as deong said). Mutations also need to improve.
I had a similar problem before, I wish it s the same as your's
First, you need to check (using any measuring metric) if chromosome A is better than chromosome B. This let you have a strict order of the chromosomes of your population and be able to sort your population.
Then, when you produce a new chromosome (either by mutation or crossover) you may be producing a chromosome that already exist in your population. Make sure not to include this in your population list.
In other words, make sure your list always contains different chromosomes and always sorted from best to worst !
Note: The genetic algorithms I work with are usually like this (this is the most general algorithm and most used):