Added more structure methods and some quality of life changes

Overall cleaned up a lot of comments.

EasyGA:
- Code cleanup.

Population:
- Added sort_by_best_fitness
- Added parent/mating pool methods.
- Renamed some methods for consistency.

Chromosome:
- Added get_gene(index).

Parent Selection:
- Improved selection methods to use the ga.selection_probability so that the roulette selection actually works well.
- Added stochastic selection.

Survivor Selection:
- Added fill_in_random and fill_in_parents_then_random.

Crossover/Mutation:
- Cleaned up code.
This commit is contained in:
SimpleArt
2020-10-13 12:48:20 -04:00
parent 5e6f9b0427
commit fb213f04dd
8 changed files with 223 additions and 77 deletions

View File

@ -13,7 +13,7 @@ class Mutation_Methods:
# Randomly apply mutations
if random.uniform(0, 1) < ga.mutation_rate:
ga.population.set_chromosome(ga.mutation_individual_impl(ga, ga.population.get_all_chromosomes()[index]), index)
ga.population.set_chromosome(ga.mutation_individual_impl(ga, ga.population.get_chromosome(index)), index)
class Individual: