hal-cgp icon indicating copy to clipboard operation
hal-cgp copied to clipboard

Redesign setting/getting fitness of an individual

Open jakobj opened this issue 5 years ago • 0 comments

Currently we set the fitness of an individual like individual.fitness = <value> in the objective function. Internally, this triggers the setter self._fitness[self._objective_idx] = v where _objective_idx is set by the evolutionary algorithm prior to calling the objective. In contrast, getting the fitness, e.g., print(individual.fitness) will trigger the getter sum([f for f in self._fitness if f is not None]). The setter/getter are hence logically incompatible.

I would suggest to drop the setter and replace it with a function set_fitness_for_current_objective(<value>) and make the getter return list(self._fitness). To me this seems like the least confusing approach. what do you think @HenrikMettler @mschmidt87 ?

jakobj avatar Jan 08 '21 16:01 jakobj