Variable name changes and fix to y_data on plots

This commit is contained in:
danielwilczak101
2020-11-12 12:28:50 -05:00
parent 357df1609f
commit 435c6c1335
3 changed files with 18 additions and 10 deletions

BIN
src/database.db Normal file

Binary file not shown.

View File

@ -30,16 +30,17 @@ class Matplotlib_Graph:
X = list(range(0, generations))
# Query for Y data
Y_list = self.database.get_generation_total_fitness()
Y_data = self.database.get_generation_total_fitness()
if(self.yscale == "log"):
# If using log then the values have to be positive numbers
Y = [abs(ele) for ele in Y_list]
Y = [abs(ele) for ele in Y_data]
Y_data = Y
# Setup data
plt.figure(figsize = self.size)
plt.yscale(self.yscale)
self.type_of_plot(X,Y_list)
self.type_of_plot(X,Y_data)
# x and y labels
if(self.xlabel == None):
@ -63,16 +64,17 @@ class Matplotlib_Graph:
X = list(range(0, generations))
# Query for Y data
Y_list = self.database.get_highest_chromosome()
Y_data = self.database.get_highest_chromosome()
if(self.yscale == "log"):
# If using log then the values have to be positive numbers
Y = [abs(ele) for ele in Y_list]
Y = [abs(ele) for ele in Y_data]
Y_data = Y
# Setup data
plt.figure(figsize = self.size)
plt.yscale(self.yscale)
self.type_of_plot(X,Y_list)
self.type_of_plot(X,Y_data)
# x and y labels
if(self.xlabel == None):
@ -94,19 +96,22 @@ class Matplotlib_Graph:
# Create the generations list - [0,1,2,etc]
X = list(range(0, generations))
print(X)
# Query for Y data
Y_list = self.database.get_lowest_chromosome()
Y_data = self.database.get_lowest_chromosome()
if(self.yscale == "log"):
# If using log then the values have to be positive numbers
Y = [abs(ele) for ele in Y_list]
Y = [abs(ele) for ele in Y_data]
Y_data = Y
# Setup data
plt.figure(figsize = self.size)
plt.yscale(self.yscale)
self.type_of_plot(X,Y_list)
self.type_of_plot(X,Y_data)
# x and y labels
# Default x and y labels
if(self.xlabel == None):
plt.xlabel('Generation')
if(self.ylabel == None):

View File

@ -18,6 +18,9 @@ ga.target_fitness_type = 'min'
ga.evolve()
ga.print_generation()
ga.print_population()
ga.graph.type_of_plot = "line"
ga.graph.yscale = "log"
ga.graph.lowest_value_chromosome()