Updated Implementation Framework

Updated to cover changes made by Dan to Master regarding general design changes

Also added remove_two_worst survivor selection method
This commit is contained in:
RyleyGG
2020-10-05 20:46:25 -04:00
parent e05aa7f62b
commit 665062fdf1
24 changed files with 133 additions and 126 deletions

View File

@ -0,0 +1,32 @@
# Import the data structure
from .population_structure.population import Population as create_population
from .chromosome_structure.chromosome import Chromosome as create_chromosome
from .gene_structure.gene import Gene as create_gene
class Initialization_Methods:
"""Initialization examples that are used as defaults and examples"""
def random_initialization(self, ga):
"""Takes the initialization inputs and choregraphs them to output the type of population with the given parameters."""
# Create the population object
population = create_population()
# Fill the population with chromosomes
for i in range(ga.population_size):
chromosome = create_chromosome()
#Fill the Chromosome with genes
for j in range(ga.chromosome_length):
# Using the chromosome_impl to set every index inside of the chromosome
if ga.chromosome_impl != None:
# Each chromosome location is specified with its own function
chromosome.add_gene(create_gene(ga.chromosome_impl(j)))
# Will break if chromosome_length != len(lists) in domain
elif ga.gene_impl != None:
function = ga.gene_impl[0]
chromosome.add_gene(create_gene(function(*ga.gene_impl[1:])))
else:
#Exit because either were not specified
print("You did not specify any initialization constraints.")
population.add_chromosome(chromosome)
return population