Remove random gene function
This commit is contained in:
@ -4,8 +4,6 @@ from initialization.population_structure.population import population as create_
|
|||||||
from initialization.chromosome_structure.chromosome import chromosome as create_chromosome
|
from initialization.chromosome_structure.chromosome import chromosome as create_chromosome
|
||||||
from initialization.gene_structure.gene import gene as create_gene
|
from initialization.gene_structure.gene import gene as create_gene
|
||||||
|
|
||||||
# Import functions for defaults
|
|
||||||
from initialization.gene_function.gene_random import random_gene
|
|
||||||
# Import functionality defaults
|
# Import functionality defaults
|
||||||
from initialization.random_initialization import random_initialization
|
from initialization.random_initialization import random_initialization
|
||||||
|
|
||||||
@ -21,8 +19,6 @@ class GA:
|
|||||||
self.population_size = 5
|
self.population_size = 5
|
||||||
self.mutation_rate = 0.03
|
self.mutation_rate = 0.03
|
||||||
# Defualt EastGA implimentation structure
|
# Defualt EastGA implimentation structure
|
||||||
|
|
||||||
# Set the GA Configuration
|
|
||||||
self.initialization_impl = random_initialization
|
self.initialization_impl = random_initialization
|
||||||
#self.mutation_impl = PerGeneMutation(Mutation_rate)
|
#self.mutation_impl = PerGeneMutation(Mutation_rate)
|
||||||
#self.selection_impl = TournamentSelection()
|
#self.selection_impl = TournamentSelection()
|
||||||
|
|||||||
@ -6,17 +6,19 @@ ga = EasyGA.GA()
|
|||||||
def user_gene_domain(gene_index):
|
def user_gene_domain(gene_index):
|
||||||
"""Each gene index is assosiated to its index in the chromosome"""
|
"""Each gene index is assosiated to its index in the chromosome"""
|
||||||
domain = [
|
domain = [
|
||||||
random.randrange(1,100),
|
random.randrange(1,100,5),
|
||||||
random.uniform(10,5),
|
random.uniform(10,5),
|
||||||
random.choice(["up","down"])
|
random.choice(["up","down"])
|
||||||
]
|
]
|
||||||
return domain[gene_index]
|
return domain[gene_index]
|
||||||
|
|
||||||
|
print(user_gene_domain(0))
|
||||||
|
|
||||||
# If the user wants to use a domain
|
# If the user wants to use a domain
|
||||||
ga.domain = user_gene_domain
|
ga.domain = user_gene_domain
|
||||||
# If the user wants to use a custom range
|
# If the user wants to use a custom range
|
||||||
#ga.new_range = [random.randrange,1,100]
|
#ga.new_range = [random.randrange,1,100,None]
|
||||||
|
|
||||||
ga.initialize()
|
ga.initialize()
|
||||||
|
|
||||||
ga.population.print_all()
|
#ga.population.print_all()
|
||||||
|
|||||||
Reference in New Issue
Block a user