Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The metaclass verifies that weights are provided at Fitness class creation and that they are a sequence. We should probably add a verification that weights are actually a sequence of numbers too.
This check was in Fitness init before, so it was ran every time a new fitness instance was created. With MetaFitness, the check is done only at class creation and fail earlier if it has to fail, avoiding tedious debugging.
This could be added in 1.1.0 as it should not break the API, but metaclasses could also be seen as the main point of 2.0. The following paragraphs can only be considered for 2.0 however.
This commit also makes DEAP base Fitness class a mono-objective maximization fitness. This simplifies MetaFitness check as it would fail otherwise when defining base.Fitness and it also means that user won't have to define a fitness for basic problems.
This is just the beginning as this class could be used to avoid having to provides a sequence for mono-objective fitness. It could also be used to define an alternative dominance strategy to Pareto dominance. Instead of defining a dominates method and comparisons operators (>,<,<=,...), we could only define comparisons operators that uses the defined dominance strategy (Pareto, lexicographic, etc.). The keyword 'dominance' would be required at Fitness class creation only if there is more than one values in the weights sequence.