Did stuff
This commit is contained in:
@ -1,8 +1,20 @@
|
|||||||
# Import all the data prebuilt modules
|
# Import all the data prebuilt modules
|
||||||
|
from initialization.population_structure.population import population as create_population
|
||||||
|
from initialization.chromosome_structure.chromosome import chromosome as create_chromosome
|
||||||
|
from initialization.gene_structure.gene import gene as create_gene
|
||||||
|
|
||||||
|
# Import functions for defaults
|
||||||
from initialization.gene_creation.gene_random import random_gene
|
from initialization.gene_creation.gene_random import random_gene
|
||||||
|
# Import functionality defaults
|
||||||
from initialization.random_initialization import random_initialization
|
from initialization.random_initialization import random_initialization
|
||||||
|
|
||||||
|
|
||||||
class GA:
|
class GA:
|
||||||
|
|
||||||
|
global population
|
||||||
|
global chromosome
|
||||||
|
global gene
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Default variables
|
# Default variables
|
||||||
self.population = None
|
self.population = None
|
||||||
@ -37,4 +49,8 @@ class GA:
|
|||||||
# and be able to pause and output data based on that generation run.
|
# and be able to pause and output data based on that generation run.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# What about if you want to see how each
|
def make_gene(self,value):
|
||||||
|
return create_gene(value)
|
||||||
|
|
||||||
|
def make_chromosome(self):
|
||||||
|
pass
|
||||||
|
|||||||
@ -3,8 +3,6 @@ from .population_structure.population import population as create_population
|
|||||||
from .chromosome_structure.chromosome import chromosome as create_chromosome
|
from .chromosome_structure.chromosome import chromosome as create_chromosome
|
||||||
from .gene_structure.gene import gene as create_gene
|
from .gene_structure.gene import gene as create_gene
|
||||||
|
|
||||||
from .initialization import initialization
|
|
||||||
|
|
||||||
class random_initialization:
|
class random_initialization:
|
||||||
def initialize(self,chromosome_length,population_size,gene_function):
|
def initialize(self,chromosome_length,population_size,gene_function):
|
||||||
# I dont understand why python needs this in its scope but it does.
|
# I dont understand why python needs this in its scope but it does.
|
||||||
|
|||||||
@ -7,5 +7,9 @@ ga = EasyGA.GA()
|
|||||||
# Start the population
|
# Start the population
|
||||||
ga.initialize()
|
ga.initialize()
|
||||||
|
|
||||||
|
new_gene = ga.make_gene("Hello")
|
||||||
|
print(new_gene.get_value())
|
||||||
|
print(new_gene.get_fitness())
|
||||||
|
|
||||||
for chromosome in ga.population.chromosomes:
|
for chromosome in ga.population.chromosomes:
|
||||||
print(chromosome.genes[0].__dict__)
|
print(chromosome.genes[0].__dict__)
|
||||||
|
|||||||
Reference in New Issue
Block a user