Changed population print
This commit is contained in:
@ -156,7 +156,7 @@ class GA(Attributes):
|
|||||||
|
|
||||||
def print_population(self):
|
def print_population(self):
|
||||||
"""Prints the entire population"""
|
"""Prints the entire population"""
|
||||||
self.population.print_all()
|
print(self.population)
|
||||||
|
|
||||||
|
|
||||||
def print_best(self):
|
def print_best(self):
|
||||||
|
|||||||
@ -151,19 +151,8 @@ class Population:
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""Returns a backend string representation of the entire population"""
|
"""Returns a backend string representation of the entire population"""
|
||||||
pass
|
return ''.join(
|
||||||
|
'Chromosome - {index} {self.get_chromosome(index)} ' +
|
||||||
|
'/ Fitness = {self.get_chromosome(index).get_fitness()}\n'
|
||||||
def print_all(self):
|
for index in range(self.size())
|
||||||
"""Prints information about the population in the following format:
|
)
|
||||||
Current population
|
|
||||||
Chromosome 1 - [gene][gene][gene][.etc] / Chromosome fitness -
|
|
||||||
Chromosome 2 - [gene][gene][gene][.etc] / Chromosome fitness -
|
|
||||||
etc.
|
|
||||||
"""
|
|
||||||
|
|
||||||
print("Current population:")
|
|
||||||
|
|
||||||
for index in range(self.size()):
|
|
||||||
print(f'Chromosome - {index} {self.get_chromosome(index)}', end = "")
|
|
||||||
print(f' / Fitness = {self.get_chromosome(index).get_fitness()}')
|
|
||||||
|
|||||||
Reference in New Issue
Block a user