Last change
on this file since 1297 was
1185,
checked in by Maciej Komosinski, 2 years ago
|
Renamed a module; new name is "evolalg_steps"
|
File size:
489 bytes
|
Rev | Line | |
---|
[1113] | 1 | import copy |
---|
| 2 | import random |
---|
| 3 | |
---|
[1185] | 4 | from evolalg_steps.repair import Repair |
---|
[1113] | 5 | |
---|
| 6 | |
---|
| 7 | class HallOfFameRepair(Repair): |
---|
[1139] | 8 | def __init__(self, excepted_size, halloffame, top, *args, **kwargs): |
---|
| 9 | super(HallOfFameRepair, self).__init__(excepted_size, *args, **kwargs) |
---|
[1113] | 10 | self.halloffame = halloffame |
---|
| 11 | self.top = top |
---|
| 12 | |
---|
| 13 | def generate_new(self, population, missing_count): |
---|
| 14 | ind = random.randint(0, min(self.top, len(self.halloffame)) - 1) |
---|
| 15 | return copy.deepcopy(population[ind]) |
---|
| 16 | |
---|
Note: See
TracBrowser
for help on using the repository browser.