eckity.genetic_operators.genetic_operator

 1from abc import abstractmethod
 2from random import uniform
 3
 4from eckity.event_based_operator import Operator
 5
 6
 7class GeneticOperator(Operator):
 8    def __init__(self, probability=0.05, arity=0, events=None):
 9        super().__init__(events=events, arity=arity)
10        self.probability = probability
11
12    def apply_operator(self, individuals):
13        if uniform(0, 1) <= self.probability:
14            for individual in individuals:
15                individual.set_fitness_not_evaluated()
16            return self.apply(individuals)
17        return individuals
18
19    @abstractmethod
20    def apply(self, individuals):
21        pass
class GeneticOperator(eckity.event_based_operator.Operator):
 8class GeneticOperator(Operator):
 9    def __init__(self, probability=0.05, arity=0, events=None):
10        super().__init__(events=events, arity=arity)
11        self.probability = probability
12
13    def apply_operator(self, individuals):
14        if uniform(0, 1) <= self.probability:
15            for individual in individuals:
16                individual.set_fitness_not_evaluated()
17            return self.apply(individuals)
18        return individuals
19
20    @abstractmethod
21    def apply(self, individuals):
22        pass
GeneticOperator(probability=0.05, arity=0, events=None)
 9    def __init__(self, probability=0.05, arity=0, events=None):
10        super().__init__(events=events, arity=arity)
11        self.probability = probability
probability
def apply_operator(self, individuals):
13    def apply_operator(self, individuals):
14        if uniform(0, 1) <= self.probability:
15            for individual in individuals:
16                individual.set_fitness_not_evaluated()
17            return self.apply(individuals)
18        return individuals
@abstractmethod
def apply(self, individuals):
20    @abstractmethod
21    def apply(self, individuals):
22        pass