Last change
on this file since 1142 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:
603 bytes
|
Rev | Line | |
---|
[1113] | 1 | from collections import Iterable |
---|
| 2 | |
---|
| 3 | from evolalg.base.step import Step |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | class UnionStep(Step): |
---|
[1139] | 7 | def __init__(self, steps, *args, **kwargs): |
---|
| 8 | super(UnionStep, self).__init__(*args, **kwargs) |
---|
[1113] | 9 | if isinstance(steps, Iterable): |
---|
| 10 | self.steps = steps |
---|
| 11 | else: |
---|
| 12 | self.steps = [steps] |
---|
| 13 | |
---|
| 14 | def call(self, population): |
---|
[1139] | 15 | super(UnionStep, self).call(population) |
---|
[1113] | 16 | for s in self.steps: |
---|
| 17 | population = s(population) |
---|
| 18 | return population |
---|
[1139] | 19 | |
---|
| 20 | def __len__(self): |
---|
| 21 | return len(self.steps) |
---|
| 22 | |
---|
| 23 | def __iter__(self): |
---|
| 24 | return iter(self.steps) |
---|
Note: See
TracBrowser
for help on using the repository browser.