eckity.multi_objective_evolution.nsga2_plot

 1import matplotlib.pyplot as plt
 2
 3
 4class NSGA2Plot:
 5	def print_plots(self, sender, data_dict):
 6		population = data_dict["population"]
 7		ind = population.sub_populations[0].individuals[0]
 8		if len(ind.fitness.fitness) == 2:
 9			self._print_plots_2d(population)
10
11	def _print_plots_2d(self, population):
12		for sub_pop in population.sub_populations:
13			fit0_list = [ind.fitness.fitness[0] for ind in sub_pop.individuals]
14			fit1_list = [ind.fitness.fitness[1] for ind in sub_pop.individuals]
15			self._print_plot(fit0_list, fit1_list)
16
17	def _print_plot(self, ls1, ls2):
18		plt.scatter(ls1, ls2)
19		plt.xlabel('Objective function 1')
20		plt.ylabel('Objective function 2')
21		plt.show()
class NSGA2Plot:
 5class NSGA2Plot:
 6	def print_plots(self, sender, data_dict):
 7		population = data_dict["population"]
 8		ind = population.sub_populations[0].individuals[0]
 9		if len(ind.fitness.fitness) == 2:
10			self._print_plots_2d(population)
11
12	def _print_plots_2d(self, population):
13		for sub_pop in population.sub_populations:
14			fit0_list = [ind.fitness.fitness[0] for ind in sub_pop.individuals]
15			fit1_list = [ind.fitness.fitness[1] for ind in sub_pop.individuals]
16			self._print_plot(fit0_list, fit1_list)
17
18	def _print_plot(self, ls1, ls2):
19		plt.scatter(ls1, ls2)
20		plt.xlabel('Objective function 1')
21		plt.ylabel('Objective function 2')
22		plt.show()
def print_plots(self, sender, data_dict):
 6	def print_plots(self, sender, data_dict):
 7		population = data_dict["population"]
 8		ind = population.sub_populations[0].individuals[0]
 9		if len(ind.fitness.fitness) == 2:
10			self._print_plots_2d(population)