Categories
Mastering Development

‘list’ object has no attribute ‘fitness’ ERROR

import random class Individual(object): ”’ Class representing individual in population ”’ def __init__(self, chromosome): self.chromosome = chromosome self.fitness = self.fitness() @classmethod def mutate(chromosome): ”’ random change value of a random col ”’ # randomly choose mutation position col = random.randint(0, len(chromosome)-1) row = random.randint(0, len(chromosome)-1) chromosome[col] = row return chromosome @classmethod def create_chromosome(self,size): ”’ create […]