Removed get/set/size/gene_list

This commit is contained in:
SimpleArt
2020-11-22 15:48:38 -05:00
parent a84b79d391
commit 691642e19c

View File

@ -7,7 +7,7 @@ class Fitness_Examples:
# Overall fitness value # Overall fitness value
fitness = 0 fitness = 0
# For each gene in the chromosome # For each gene in the chromosome
for gene in chromosome.gene_list: for gene in chromosome:
# Check if its value = 5 # Check if its value = 5
if(gene.value == 5): if(gene.value == 5):
# If its value is 5 then add one to # If its value is 5 then add one to
@ -21,7 +21,7 @@ class Fitness_Examples:
"""Test's the GA's ability to handle floats. """Test's the GA's ability to handle floats.
Computes how close each gene is to 5. Computes how close each gene is to 5.
""" """
return sum([1-pow(1-gene.get_value()/5, 2) for gene in chromosome.get_gene_list()]) return sum([1-pow(1-gene.value/5, 2) for gene in chromosome])
def index_dependent_values(chromosome): def index_dependent_values(chromosome):
@ -29,8 +29,8 @@ class Fitness_Examples:
If a gene is equal to its index in the chromosome + 1, fitness is incremented. If a gene is equal to its index in the chromosome + 1, fitness is incremented.
""" """
fitness = 0 fitness = 0
for i in range(chromosome.size()): for i in range(len(chromosome)):
if (chromosome.gene_list[i].value == i+1): if (chromosome[i].value == i+1):
fitness += 1 fitness += 1
return fitness return fitness