It is important to benchmark your algorithm before applying it to a specific question. Otherwise, garbage in, garbage out. Having implemented a genetic algorithm (GA) with elitism, I have no idea how to test whether it works or not.
I have thought about printing out the statistics, such as mean, median, and variance, of each generation. However, they are not really strong indicators of the correctness. For example, the maximum fitness doesn't say anything, because even for random search with elitism, you have a non-decreasing maximum fitness. Mean and median do not say much either, because they may occasionally deteriorate, even if the GA is perfectly correct.
What is an effective way of testing if GA is working good?
A great approach is that you have elitism, in that way you ensure you will never lose your best individual.
However, that doesn't mean that through the generations you will see progress. First you need to understand the GA, and best way to do that is to play around with the parameters (CROSSOVER RATE, MUTATION RATE, No. INDIVIDUAL, No. ITERATION, ELITISM VALUE) and see the outcome.
As trailmax says, visualize or print out the best individual as a function of the number of iterations. If you see that the best individual is "stuck", e.i. doesn't really show progress, try to change the parameters and see what happens. If a progress is shown (ok, this is too relative!) your algorithm works. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With