source: framspy/evolalg_steps/base/step.py @ 1200

Last change on this file since 1200 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
Line 
1import logging
2from abc import abstractmethod
3
4
5class Step:
6    """
7    Base abstract class for experiment's steps. It has three stages: pre, call and post.
8
9    """
10
11    def __init__(self, name=None):
12        self.name = name
13        if name is None:
14            self.name = type(self).__name__
15
16
17    def pre(self):
18        pass
19
20    @abstractmethod
21    def call(self, population, *args, **kwargs):
22        logging.getLogger(self.name).debug(f"Population size {len(population)}")
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.