I am using a single population which has single sub population in a single threaded generational ECJ (that is ec.simple.* and extending the SimpleEvaluator only). While I am planning to implement fitness sharing, the following comes to my mind. Any suggestion is appreciated.
1. Store the ‘calculated fitness’ of each individual in your current generation only before you perform setfitness() in the problem or evaluator (in case you turn off evaluated flag in problem.evaluate() and trying to setfitness() in the custom evaluator())
2. Call your implemented 'fitness sharing method' using the 'calculated fitness' . Update the ‘calculated fitness ‘ of that individual by ‘shared fitness’ returned by the 'fitness sharing method'. As I understand, fitness sharing is a niching method to adjust one's fitness based on the fitness of other niche members to maintain a stable population plus finding out multiple maxima in your solution.
3. At this point, the individual's fitness is a shared fitness and this fitness is updated in the niche.
4. Set this 'shared fitness' using setfitness(). So, this individual will get shared fitness such that the selector will use this fitness for next generation’s breeding.
NB: I am storing only the current generation's individual before setting their fitness and emptying the bucket after the fitness evaluation of that generation.