Added comments & fixed small bug

Mostly added comments, but also fixed a small bug in parent selection where the tournament size would be much smaller than it should be.
This commit is contained in:
RyleyGG
2020-10-12 09:23:41 -04:00
parent c3d9ef8bd1
commit 94d7c52666
7 changed files with 50 additions and 46 deletions

View File

@ -3,19 +3,13 @@ from initialization.chromosome_structure.chromosome import Chromosome
from initialization.population_structure.population import Population
class Crossover_Methods:
""" Crossover explination goes here.
Points - Defined as sections between the chromosomes genetic makeup
"""
def __init__(self):
pass
def single_point_crossover(ga):
"""Single point crossover is when a "point" is selected and the genetic
make up of the two parent chromosomes are "Crossed" or better known as swapped"""
"""Single point crossover is when a "point" is selected and the genetic
make up of the two parent chromosomes are swapped at that point"""
crossover_pool = ga.population.mating_pool
"""The structure of GA requires that the crossover method return a population strictly with offspring chromosomes"""
new_population = Population()
for i in range(len(crossover_pool)):
if i + 1 < len(crossover_pool):