Last change
on this file since 1324 was
1185,
checked in by Maciej Komosinski, 2 years ago
|
Renamed a module; new name is "evolalg_steps"
|
File size:
624 bytes
|
Line | |
---|
1 | import random |
---|
2 | import copy |
---|
3 | |
---|
4 | from evolalg_steps.repair.repair import Repair |
---|
5 | |
---|
6 | |
---|
7 | class 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.