Renamed create methods to make methods for consistency and fixed fitnesses after adapting

This commit is contained in:
SimpleArt
2020-12-20 13:58:21 -05:00
parent ed67697cee
commit 6861688400

View File

@ -5,9 +5,9 @@ import math
import random
# Import all the data structure prebuilt modules
from structure import Population as create_population
from structure import Chromosome as create_chromosome
from structure import Gene as create_gene
from structure import Population as make_population
from structure import Chromosome as make_chromosome
from structure import Gene as make_gene
# Structure Methods
from fitness_function import Fitness_Examples
@ -106,6 +106,10 @@ class GA(Attributes):
self.adapt_probabilities()
self.adapt_population()
# Update and sort fitnesses
self.set_all_fitness()
self.population.sort_by_best_fitness(self)
def adapt_probabilities(self):
"""Modifies the parent ratio and mutation rates
@ -228,8 +232,6 @@ class GA(Attributes):
tol_j = tol(j)
best_chromosome = self.population[n]
self.population.sort_by_best_fitness(self)
def initialize_population(self):
"""Initialize the population using