Added structure directory and improved sort by fitness

This commit is contained in:
SimpleArt
2020-10-12 23:43:28 -04:00
parent 8056bbde1c
commit b42034c402
7 changed files with 9 additions and 8 deletions

View File

@ -1,9 +1,9 @@
import random
# Import all the data structure prebuilt modules
from initialization import Population as create_population
from initialization import Chromosome as create_chromosome
from initialization import Gene as create_gene
from structure import Population as create_population
from structure import Chromosome as create_chromosome
from structure import Gene as create_gene
# Structure Methods
from fitness_function import Fitness_Examples
@ -130,4 +130,4 @@ class GA:
etc.
"""
return list(reversed(sorted(chromosome_set, key = lambda chromosome: chromosome.get_fitness())))
return sorted(chromosome_set, key = lambda chromosome: chromosome.get_fitness(), reverse = True)

View File

@ -1,5 +1,2 @@
# FROM (. means local) file_name IMPORT function_name
from .initialization_methods import Initialization_Methods
from .gene_structure.gene import Gene
from .chromosome_structure.chromosome import Chromosome
from .population_structure.population import Population

0
src/structure/README.md Normal file
View File

View File

@ -0,0 +1,4 @@
# FROM (. means local) file_name IMPORT function_name
from .gene import Gene
from .chromosome import Chromosome
from .population import Population