aegis_sim.submodels.genetics.envdrift
Modifier of fitness landscape
Modifies topology of fitness landscape over time by changing the interpretation of zeros and ones in genomes.
1"""Modifier of fitness landscape 2 3Modifies topology of fitness landscape over time by changing the interpretation of zeros and ones in genomes. 4""" 5 6import numpy as np 7 8 9class Envdrift: 10 """ 11 12 GUI 13 Environmental drift is deactivated when [[ENVDRIFT_RATE]] is 0. 14 Conceptually, environmental drift simulates long-term environmental change such as climate change, resource depletion, pollution, etc. 15 The main purpose of environmental drift is to allow the population to keep evolving adaptively. 16 When the environment does not change, the fitness landscape is static – initially, the population evolves adaptively as it climbs the fitness landscape but once it approaches the fitness peak, 17 natural selection acts mostly to purify new detrimental mutations. When environmental drift is activated, the fitness landscape changes over time – thus, the population keeps evolving adaptively, following the fitness peak. 18 19 """ 20 21 def __init__(self, ENVDRIFT_RATE, genome_shape): 22 self.ENVDRIFT_RATE = ENVDRIFT_RATE 23 24 if self.ENVDRIFT_RATE == 0: 25 self.map = None 26 else: 27 self.map = np.zeros(genome_shape, dtype=np.bool_) 28 29 def will_evolve(self, step): 30 if (self.map is None) or (step % self.ENVDRIFT_RATE > 0): 31 return False 32 return True 33 34 def evolve(self, step): 35 """Modify the envdrift""" 36 if self.will_evolve(step=step): 37 indices = tuple(np.random.randint(self.map.shape)) 38 self.map[indices] = ~self.map[indices] 39 40 def call(self, array): 41 """Return the genomes reinterpreted""" 42 if self.map is not None: 43 array = np.logical_xor(self.map, array) 44 return array
10class Envdrift: 11 """ 12 13 GUI 14 Environmental drift is deactivated when [[ENVDRIFT_RATE]] is 0. 15 Conceptually, environmental drift simulates long-term environmental change such as climate change, resource depletion, pollution, etc. 16 The main purpose of environmental drift is to allow the population to keep evolving adaptively. 17 When the environment does not change, the fitness landscape is static – initially, the population evolves adaptively as it climbs the fitness landscape but once it approaches the fitness peak, 18 natural selection acts mostly to purify new detrimental mutations. When environmental drift is activated, the fitness landscape changes over time – thus, the population keeps evolving adaptively, following the fitness peak. 19 20 """ 21 22 def __init__(self, ENVDRIFT_RATE, genome_shape): 23 self.ENVDRIFT_RATE = ENVDRIFT_RATE 24 25 if self.ENVDRIFT_RATE == 0: 26 self.map = None 27 else: 28 self.map = np.zeros(genome_shape, dtype=np.bool_) 29 30 def will_evolve(self, step): 31 if (self.map is None) or (step % self.ENVDRIFT_RATE > 0): 32 return False 33 return True 34 35 def evolve(self, step): 36 """Modify the envdrift""" 37 if self.will_evolve(step=step): 38 indices = tuple(np.random.randint(self.map.shape)) 39 self.map[indices] = ~self.map[indices] 40 41 def call(self, array): 42 """Return the genomes reinterpreted""" 43 if self.map is not None: 44 array = np.logical_xor(self.map, array) 45 return array
GUI Environmental drift is deactivated when [[ENVDRIFT_RATE]] is 0. Conceptually, environmental drift simulates long-term environmental change such as climate change, resource depletion, pollution, etc. The main purpose of environmental drift is to allow the population to keep evolving adaptively. When the environment does not change, the fitness landscape is static – initially, the population evolves adaptively as it climbs the fitness landscape but once it approaches the fitness peak, natural selection acts mostly to purify new detrimental mutations. When environmental drift is activated, the fitness landscape changes over time – thus, the population keeps evolving adaptively, following the fitness peak.