Fixed attributes to allow setting attributes on initialization

e.g.
GA({
    'chromosome_length' : 10,
    'population_size'         : 50
})
This commit is contained in:
SimpleArt
2020-11-03 13:19:09 -05:00
parent 5b6dc8348a
commit 621fdef86d
2 changed files with 73 additions and 36 deletions

View File

@ -17,10 +17,10 @@ from mutation import Mutation_Methods
from crossover import Crossover_Methods
# Default Attributes for the GA
from attributes import attributes
from attributes import Attributes
class GA(attributes):
class GA(Attributes):
"""GA is the main class in EasyGA. Everything is run through the ga
class. The GA class inherites all the default ga attributes from the
attributes class.
@ -29,9 +29,8 @@ class GA(attributes):
https://github.com/danielwilczak101/EasyGA/wiki
"""
# Inhert all the ga attributes from the attributes class.
def __init__(self):
super(GA, self).__init__()
def __init__(self, attributes = None):
super(GA, self).__init__({} if attributes is None else attributes)
def evolve_generation(self, number_of_generations = 1, consider_termination = True):