Changeset 1139 for framspy/evolalg/mutation_cross
- Timestamp:
- 05/08/21 12:42:58 (4 years ago)
- Location:
- framspy/evolalg/mutation_cross
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/evolalg/mutation_cross/frams_cross.py
r1113 r1139 6 6 7 7 class FramsCross(FramsStep): 8 def __init__(self, frams_lib, commands, cross_prob ):9 super().__init__(frams_lib, commands )8 def __init__(self, frams_lib, commands, cross_prob, *args, **kwargs): 9 super().__init__(frams_lib, commands, *args, **kwargs) 10 10 self.cross_prob = cross_prob 11 11 12 12 def call(self, population): 13 super(FramsCross, self).call(population) 13 14 for i in range(1, len(population), 2): 14 15 if random.random() < self.cross_prob: -
framspy/evolalg/mutation_cross/frams_cross_and_mutate.py
r1113 r1139 5 5 6 6 class FramsCrossAndMutate(FramsStep): 7 def __init__(self, frams_lib, cross_prob, mutate_prob, mutate_commands=None, cross_commands=None ):8 super().__init__(frams_lib )7 def __init__(self, frams_lib, cross_prob, mutate_prob, mutate_commands=None, cross_commands=None, *args, **kwargs): 8 super().__init__(frams_lib, *args, **kwargs) 9 9 10 10 self.cross_prob = cross_prob … … 15 15 16 16 def call(self, population): 17 super(FramsCrossAndMutate, self).call(population) 17 18 population = self.frams_cross(population) 18 19 population = self.frams_mutate(population) -
framspy/evolalg/mutation_cross/frams_cross_or_mutate.py
r1113 r1139 4 4 import random 5 5 6 6 7 class FramsCrossOrMutate(FramsStep): 7 def __init__(self, frams_lib, commands, cross_prob, mutate_prob, mutate_commands=None, cross_commands=None): 8 super().__init__(frams_lib, commands) 8 def __init__(self, frams_lib, commands, cross_prob, mutate_prob, mutate_commands=None, cross_commands=None, *args, 9 **kwargs): 10 super().__init__(frams_lib, commands, *args, **kwargs) 9 11 10 12 self.cross_prob = cross_prob … … 15 17 16 18 def call(self, population): 19 super(FramsCrossOrMutate, self).call(population) 17 20 mutate_idx = [] 18 21 cross_idx = [] … … 21 24 if rng < self.cross_prob: 22 25 cross_idx.append(i) 23 elif rng < self.cross_prob +self.mutate_prob:26 elif rng < self.cross_prob + self.mutate_prob: 24 27 mutate_idx.append(i) 25 28 … … 32 35 self.frams_cross(cross_idx) 33 36 34 for i, ind in zip(mutate_idx, mutate_ind):37 for i, ind in zip(mutate_idx, mutate_ind): 35 38 population[i] = ind 36 39 37 for i, ind in zip(cross_idx, cross_ind):40 for i, ind in zip(cross_idx, cross_ind): 38 41 population[i] = ind 39 42 -
framspy/evolalg/mutation_cross/frams_mutation.py
r1113 r1139 6 6 7 7 class FramsMutation(FramsStep): 8 def __init__(self, frams_lib, commands, mutate_prob ):9 super().__init__(frams_lib, commands )8 def __init__(self, frams_lib, commands, mutate_prob, *args, **kwargs): 9 super().__init__(frams_lib, commands, *args, **kwargs) 10 10 self.mutate_prob = mutate_prob 11 11 12 12 def call(self, population): 13 super(FramsMutation, self).call(population) 13 14 idx = [] 14 15 for i in range(len(population)):
Note: See TracChangeset
for help on using the changeset viewer.