Changeset 1139 for framspy/evolalg/base


Ignore:
Timestamp:
05/08/21 12:42:58 (3 years ago)
Author:
Maciej Komosinski
Message:

Added --debug mode that prints names of steps; final multiple evaluation now evaluates genotypes in hall of fame instead of the last population

Location:
framspy/evolalg/base
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • framspy/evolalg/base/frams_step.py

    r1113 r1139  
    33
    44class FramsStep(Step):
    5     def __init__(self, frams_lib, commands=None):
     5    def __init__(self, frams_lib, commands=None, *args, **kwargs):
     6        super(FramsStep, self).__init__(*args, **kwargs)
    67        if commands is None:
    78            commands = []
  • framspy/evolalg/base/lambda_step.py

    r1114 r1139  
    1818
    1919    def call(self, population):
     20        super(LambdaStep, self).call(population)
    2021        if self.in_place:
    2122            [self.fun(_) for _ in population]
  • framspy/evolalg/base/step.py

    r1113 r1139  
     1import logging
    12from abc import abstractmethod
    23
     
    78
    89    """
     10
     11    def __init__(self, name=None):
     12        self.name = name
     13        if name is None:
     14            self.name = type(self).__name__
     15
     16
    917    def pre(self):
    1018        pass
    1119
    1220    @abstractmethod
    13     def call(self, *args, **kwargs):
    14         pass
     21    def call(self, population, *args, **kwargs):
     22        logging.getLogger(self.name).debug(f"Population size {len(population)}")
    1523
    1624    def post(self):
  • framspy/evolalg/base/union_step.py

    r1113 r1139  
    55
    66class UnionStep(Step):
    7     def __init__(self, steps):
     7    def __init__(self, steps, *args, **kwargs):
     8        super(UnionStep, self).__init__(*args, **kwargs)
    89        if isinstance(steps, Iterable):
    910            self.steps = steps
     
    1213
    1314    def call(self, population):
     15        super(UnionStep, self).call(population)
    1416        for s in self.steps:
    1517            population = s(population)
    1618        return population
     19
     20    def __len__(self):
     21        return len(self.steps)
     22
     23    def __iter__(self):
     24        return iter(self.steps)
Note: See TracChangeset for help on using the changeset viewer.