File name changes to match the rest of framework. generation goal was setup twice in EasyGA.

This commit is contained in:
danielwilczak101
2020-10-08 15:53:35 -04:00
parent 3649293133
commit 88927f7415
19 changed files with 11 additions and 61 deletions

View File

@ -9,13 +9,13 @@ class Crossover_Methods:
"""
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"""
crossover_pool = ga.population.mating_pool
new_population = Population()
for i in range(len(crossover_pool)):
if i + 1 < len(crossover_pool):
@ -23,14 +23,14 @@ class Crossover_Methods:
parent_one = crossover_pool[i].get_genes()
parent_two = crossover_pool[i+1].get_genes()
#halfway_point = int(ga.chromosome_length/2)
split_point = random.randint(0,ga.chromosome_length)
split_point = random.randint(0,ga.chromosome_length)
new_gene_set.extend(parent_one[0:split_point])
new_gene_set.extend(parent_two[split_point:])
new_chromosome = Chromosome(new_gene_set)
new_population.add_chromosome(new_chromosome)
return new_population
def multi_point_crossover(ga, number_of_points = 2):
"""Multi point crossover is when a specific number (More then one) of
"points" are created to merge the genetic makup of the chromosomes."""