eckity.breeders.breeder

 1from abc import abstractmethod, ABC
 2
 3from overrides import overrides
 4
 5from eckity.event_based_operator import Operator
 6from eckity.population import Population
 7
 8
 9class Breeder(Operator, ABC):
10    """
11    The Breeder is responsible to activate the genetic operators (selection, crossover, mutation)
12    on the existing population
13
14    Parameters
15    ----------
16    events: dict(str, dict(object, function))
17            dictionary of event names to dictionary of subscribers to callback methods
18    """
19
20    def __init__(self, events=None):
21        super().__init__(events=events)
22
23    def breed(self, population):
24        """
25        Breed the given population of the experiment.
26        Hence, apply genetic operators on the individuals of the population.
27
28        Parameters
29        ----------
30        population: Population
31        The population of individuals existing in the current experiment.
32        """
33        self.act(population)
34
35    @abstractmethod
36    def apply_breed(self, population):
37        pass
38
39    @overrides
40    def apply_operator(self, payload):
41        population: Population = payload
42        self.apply_breed(population)
class Breeder(eckity.event_based_operator.Operator, abc.ABC):
10class Breeder(Operator, ABC):
11    """
12    The Breeder is responsible to activate the genetic operators (selection, crossover, mutation)
13    on the existing population
14
15    Parameters
16    ----------
17    events: dict(str, dict(object, function))
18            dictionary of event names to dictionary of subscribers to callback methods
19    """
20
21    def __init__(self, events=None):
22        super().__init__(events=events)
23
24    def breed(self, population):
25        """
26        Breed the given population of the experiment.
27        Hence, apply genetic operators on the individuals of the population.
28
29        Parameters
30        ----------
31        population: Population
32        The population of individuals existing in the current experiment.
33        """
34        self.act(population)
35
36    @abstractmethod
37    def apply_breed(self, population):
38        pass
39
40    @overrides
41    def apply_operator(self, payload):
42        population: Population = payload
43        self.apply_breed(population)

The Breeder is responsible to activate the genetic operators (selection, crossover, mutation) on the existing population

Parameters
  • events (dict(str, dict(object, function))): dictionary of event names to dictionary of subscribers to callback methods
def breed(self, population):
24    def breed(self, population):
25        """
26        Breed the given population of the experiment.
27        Hence, apply genetic operators on the individuals of the population.
28
29        Parameters
30        ----------
31        population: Population
32        The population of individuals existing in the current experiment.
33        """
34        self.act(population)

Breed the given population of the experiment. Hence, apply genetic operators on the individuals of the population.

Parameters
  • population (Population):

  • The population of individuals existing in the current experiment.

@abstractmethod
def apply_breed(self, population):
36    @abstractmethod
37    def apply_breed(self, population):
38        pass
@overrides
def apply_operator(self, payload):
40    @overrides
41    def apply_operator(self, payload):
42        population: Population = payload
43        self.apply_breed(population)