Thanks you so much.

So I did it wrong. My idea was not to modify the nsga-ii behaviour or to make a new algorithm. I just wanted to modify the behaviour of the tournament selection operator by using another fitness comparator instead of the Pareto dominance. Because of this I thought that I had to extend the MultiObjectiveFitness class.  So, which class would be the right one??

Thanks again for your help,

On Sun, 9 Dec 2018, 23:32 Sean Luke <[log in to unmask] wrote:
If you're using NSGA2, your custom fitness class must be a subclass of NSGA2MultiObjectiveFitness.  Furthermore, NSGA2 has its own way of handling fitness comparisons, so overriding betterThan will deviate from how NSGA2 works: you need to make sure you know what you're doing.

The only reason you'd subclass directly from MultiObjectiveFitness is if you're implementing your own multiobjective optimization algorithm.


> On Dec 9, 2018, at 4:35 PM, Adrián Romero Cáceres <[log in to unmask]> wrote:
> Hello!
> I have implemented a new betterThan operator into a CustomFitness class, which is an extended class of MultiObjectiveFitness.  I wrote = ec.multiobjective.CustomFitness inside my experiment param file. Once the execution starts, after the first generation fails, returning the next error:
> Exception in thread "main" java.lang.ClassCastException: ec.multiobjective.CustomFitness cannot be cast to ec.multiobjective.nsga2.NSGA2MultiObjectiveFitness
>         at ec.multiobjective.nsga2.NSGA2Breeder.assignFrontRanks(
>         at ec.multiobjective.nsga2.NSGA2Breeder.buildArchive(
>         at ec.multiobjective.nsga2.NSGA2Breeder.loadElites(
>         at ec.simple.SimpleBreeder.breedPopulation(
>         at ec.multiobjective.nsga2.NSGA2Breeder.breedPopulation(
>         at ec.simple.SimpleEvolutionState.evolve(
>         at
>         at ec.Evolve.main(
> I forgot something? Is it the right way to extend the betterThan operator?
> Thanks in advance,
> Adrián.