I am trying to implement a Genetic Algorithm which will recreate a given image by positioning, sizing and colouring 1000 circles. However, I found that when the fitness reaches a certain value (around 0.37 in my case) it stop increasing. In other words it just converges on the value.
I can't think of a way to improve this
Some Details
population size: 50
mutation rate: 0.025
the genes of each child is an 1000 element array with element type CircleData
, which contains the size, color and position of a circle
Fitness Function
I loop through every pixels on the target image and the canvas the algorithm drew on. For each pixel, I map the RGB value to a point in 3D space and calculate the distance between the two points. The distance will then be summed up for every pixels and normalise to get a fitness value in [0, 1], where 1 means each pixel are identical. Finally I take the value of pow(fitness, 2)
as the final fitness value.
Selection
I sort the children base on their fitness, and drop the worse 2/3. For the remaining children, I use Fitness Proportionate Selection to select two parents
Crossover
I use one point crossover with random crossover point
Update
I suspect the problem is due to local maximum, still trying to fix that...
Some SO questions on local maximum in GA:
How to prevent genetic algorithm from converging on local minima?
Max Fitness stuck at local maxima in genetic algorithm implementation