eckity.genetic_operators.mutations.identity_transformation
1from eckity.genetic_operators.genetic_operator import GeneticOperator 2 3 4class IdentityTransformation(GeneticOperator): 5 def __init__(self, probability=1.0, events=None): 6 """ 7 Basic mutation operator that does not change the individuals. 8 9 Parameters 10 ---------- 11 probability : float, optional 12 Probability to apply each generation, by default 1.0 13 events : List[str], optional 14 custom events that the operator publishes, by default None 15 """ 16 super().__init__(probability=probability, arity=1, events=events) 17 18 def apply(self, individuals): 19 self.applied_individuals = individuals 20 return individuals
5class IdentityTransformation(GeneticOperator): 6 def __init__(self, probability=1.0, events=None): 7 """ 8 Basic mutation operator that does not change the individuals. 9 10 Parameters 11 ---------- 12 probability : float, optional 13 Probability to apply each generation, by default 1.0 14 events : List[str], optional 15 custom events that the operator publishes, by default None 16 """ 17 super().__init__(probability=probability, arity=1, events=events) 18 19 def apply(self, individuals): 20 self.applied_individuals = individuals 21 return individuals
Abstract class for genetic operators. Each operator has a probability of being applied each generation.
Genetic operators are applied in-place.
Parameters
- probability (float, optional): probability of being applied each generation, by default 1.0
- arity (int, optional): number of individuals required for the operator, by default 0
- events (List[str], optional): custom events that the operator publishes, by default None
IdentityTransformation(probability=1.0, events=None)
6 def __init__(self, probability=1.0, events=None): 7 """ 8 Basic mutation operator that does not change the individuals. 9 10 Parameters 11 ---------- 12 probability : float, optional 13 Probability to apply each generation, by default 1.0 14 events : List[str], optional 15 custom events that the operator publishes, by default None 16 """ 17 super().__init__(probability=probability, arity=1, events=events)
Basic mutation operator that does not change the individuals.
Parameters
- probability (float, optional): Probability to apply each generation, by default 1.0
- events (List[str], optional): custom events that the operator publishes, by default None
def
apply(self, individuals):
Apply the genetic operator to the individuals. This method should be implemented by the subclasses.
Parameters
- individuals (List[Individual]): Individuals to apply the operator to.