Last change
on this file since 1174 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:
690 bytes
|
Rev | Line | |
---|
[1139] | 1 | import logging |
---|
[1113] | 2 | from abc import abstractmethod |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | class Step: |
---|
| 6 | """ |
---|
| 7 | Base abstract class for experiment's steps. It has three stages: pre, call and post. |
---|
| 8 | |
---|
| 9 | """ |
---|
[1139] | 10 | |
---|
| 11 | def __init__(self, name=None): |
---|
| 12 | self.name = name |
---|
| 13 | if name is None: |
---|
| 14 | self.name = type(self).__name__ |
---|
| 15 | |
---|
| 16 | |
---|
[1113] | 17 | def pre(self): |
---|
| 18 | pass |
---|
| 19 | |
---|
| 20 | @abstractmethod |
---|
[1139] | 21 | def call(self, population, *args, **kwargs): |
---|
| 22 | logging.getLogger(self.name).debug(f"Population size {len(population)}") |
---|
[1113] | 23 | |
---|
| 24 | def post(self): |
---|
| 25 | pass |
---|
| 26 | |
---|
| 27 | def init(self): |
---|
| 28 | pass |
---|
| 29 | |
---|
| 30 | def __call__(self, *args, **kwargs): |
---|
| 31 | self.pre() |
---|
| 32 | res = self.call(*args, **kwargs) |
---|
| 33 | self.post() |
---|
| 34 | return res |
---|
Note: See
TracBrowser
for help on using the repository browser.