source: framspy/evolalg/repair/mutate.py @ 1164

Last change on this file since 1164 was 1139, checked in by Maciej Komosinski, 4 years ago

Added --debug mode that prints names of steps; final multiple evaluation now evaluates genotypes in hall of fame instead of the last population

File size: 618 bytes
Line 
1import random
2import copy
3
4from evolalg.repair.repair import Repair
5
6
7class MutateRepair(Repair):
8    def __init__(self, mutate_step, excepted_size, iterations=1, *args, **kwargs):
9        super(MutateRepair, self).__init__(excepted_size, *args, **kwargs)
10        self.mutate_step = mutate_step
11        self.iterations = iterations
12
13
14    def generate_new(self, population, missing_count):
15        selected = population[random.randint(0, len(population))]
16        selected = copy.deepcopy(selected)
17        for _ in range(self.iterations):
18            selected = self.mutate_step([selected])[0]
19        return selected
Note: See TracBrowser for help on using the repository browser.