Changed names of impl

This commit is contained in:
Daniel Wilczak
2020-09-27 16:40:44 -04:00
parent 1703b84ddc
commit a302169415
3 changed files with 16 additions and 22 deletions

View File

@ -1,26 +1,20 @@
import EasyGA
import random
# Create the Genetic algorithm
ga = EasyGA.GA()
def user_gene_domain(gene_index):
"""Each gene index is assosiated to its index in the chromosome"""
domain = [
random.randrange(1,100,5),
chromosome = [
random.randrange(1,100),
random.uniform(10,5),
random.choice(["up","down"])
]
return domain[gene_index]
print(user_gene_domain(0))
return chromosome[gene_index]
# If the user wants to use a domain
ga.domain = user_gene_domain
# If the user wants to use a custom range
#ga.new_range = [random.randrange,1,100,None]
ga.chromosome_impl = user_gene_domain
ga.initialize()
#ga.population.print_all()
ga.population.print_all()