Merge branch 'master' of https://github.com/danielwilczak101/EasyGA
This commit is contained in:
@ -30,9 +30,11 @@ class Matplotlib_Graph:
|
|||||||
def plot(self):
|
def plot(self):
|
||||||
"""Plot all the graph attributes"""
|
"""Plot all the graph attributes"""
|
||||||
|
|
||||||
|
if self.xlabel is not None: xlabel = self.xlabel
|
||||||
|
if self.ylabel is not None: xlabel = self.ylabel
|
||||||
|
if self.title is not None: xlabel = self.title
|
||||||
|
|
||||||
|
if yscale == "log":
|
||||||
if self.yscale == "log":
|
|
||||||
# If using log then the values have to be positive numbers
|
# If using log then the values have to be positive numbers
|
||||||
self.y = [abs(ele) for ele in self.y]
|
self.y = [abs(ele) for ele in self.y]
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
class Chromosome:
|
class Chromosome:
|
||||||
|
|
||||||
def __init__(self, gene_list = None):
|
def __init__(self, gene_list = []):
|
||||||
if gene_list is None:
|
"""Initialize the chromosome with fitness value of None, and a
|
||||||
self.gene_list = []
|
set of genes dependent on user-passed parameter."""
|
||||||
else:
|
|
||||||
self.gene_list = gene_list
|
|
||||||
|
|
||||||
|
self.gene_list = deepcopy(gene_list)
|
||||||
self.fitness = None
|
self.fitness = None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +1,11 @@
|
|||||||
def check_gene(value):
|
from copy import deepcopy
|
||||||
#Check to make sure the gene is not empty
|
|
||||||
assert value != "" , "Gene can not be empty"
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
class Gene:
|
class Gene:
|
||||||
|
|
||||||
def __init__(self, value):
|
def __init__(self, value):
|
||||||
"""Initialize a gene with fitness of value None and the input value"""
|
"""Initialize a gene with fitness of value None and the input value"""
|
||||||
|
self.value = deepcopy(value)
|
||||||
self.fitness = None
|
self.fitness = None
|
||||||
self.value = check_gene(value)
|
|
||||||
|
|
||||||
|
|
||||||
def get_fitness(self):
|
def get_fitness(self):
|
||||||
|
|||||||
@ -1,14 +1,12 @@
|
|||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
class Population:
|
class Population:
|
||||||
|
|
||||||
def __init__(self, chromosome_list = None):
|
def __init__(self, chromosome_list = []):
|
||||||
"""Intiialize the population with fitness of value None, and a
|
"""Initialize the population with fitness of value None, and a
|
||||||
set of chromosomes dependant on user-passed parameter"""
|
set of chromosomes dependant on user-passed parameter."""
|
||||||
|
|
||||||
if chromosome_list is None:
|
|
||||||
self.chromosome_list = []
|
|
||||||
else:
|
|
||||||
self.chromosome_list = chromosome_list
|
|
||||||
|
|
||||||
|
self.chromosome_list = deepcopy(chromosome_list)
|
||||||
self.fitness = None
|
self.fitness = None
|
||||||
self.mating_pool = []
|
self.mating_pool = []
|
||||||
self.next_population = []
|
self.next_population = []
|
||||||
|
|||||||
Reference in New Issue
Block a user