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.
This PR adds the two main genetic operations: crossover and mutation.
Crossover works to preserve good 'genes' (pokemon team mebers) by selecting two 'chromosomes' (teams) (with replacement) in proportion to their fitness, then swapping their 'genes' (pokemon).
Mutation works to maintain 'genetic' diversity (pokemon diversity) by occasionally randomly adding members to the teams and removing old ones.
There's been some discussion about how best to do this, so I've made this code as modular and as flexible as possible.
For crossover:
locus_swap
,slot_swap
, andsample_swap
all have their own kwargs.For mutation:
genetic_team
in genetic.py to take a crossover function as input, along with some mutation and crossover-related paramsmutate_with_fitness
argument in thegenetic_team
function above), the crossover step will be skipped. This is because post-crossover/mutation, and previous fitness scores will be invalidI've also updated the
win_percentages
fitness function to standardise the fitnesses to sum to 1.Some additional thoughts based on some discussion earlier today and in other PRs: