aegis_sim.submodels.reproduction.reproduction
1from aegis_sim.dataclasses.genomes import Genomes 2from aegis_sim.submodels.reproduction.pairing import pairing 3from aegis_sim.submodels.reproduction.recombination import recombination, recombination_via_pairs 4 5 6class Reproducer: 7 """ 8 GUI 9 Individuals are fertile starting with [[MATURATION_AGE]] (can be 0) until [[REPRODUCTION_ENDPOINT]] (if 0, no REPRODUCTION_ENDPOINT occurs). 10 Reproduction can be sexual (with diploid genomes) or asexual (with diploid or haploid genomes). 11 When reproduction is sexual, recombination occurs in gametes at a rate of [[RECOMBINATION_RATE]] 12 and gametes will inherit mutations at an age-independent rate 13 which can be parameterized (genetics-independent) or set to evolve (genetics-dependent). 14 Mutations cause the offspring genome bit states to flip from 0-to-1 or 1-to-0. 15 The ratio of 0-to-1 and 1-to-0 can be modified using the [[MUTATION_RATIO]]. 16 17 If the population is oviparous, [[INCUBATION_PERIOD]] should be set to -1, 1 or greater. 18 When it is set to -1, all laid eggs hatch only once all living individuals die. 19 When it is set to 0 or greater, eggs hatch after that specified time. 20 Thus, when 0, individuals do not go through an egg stage during their life cycle. 21 """ 22 23 # TODO INCUBATION_PERIOD set to -1 or 1 or greater is stupid 24 # TODO INCUBATION_PERIOD is not really a part of this submodel, but it is in the documentation. it should be though. 25 26 # TODO probably better to split mutation logic into another domain and cluster together with genetic architecture stuff 27 28 def __init__(self, RECOMBINATION_RATE, REPRODUCTION_MODE, mutator): 29 self.RECOMBINATION_RATE = RECOMBINATION_RATE 30 self.REPRODUCTION_MODE = REPRODUCTION_MODE 31 self.mutator = mutator 32 33 def generate_offspring_genomes(self, genomes, muta_prob, ages, parental_sexes) -> Genomes: 34 35 if self.REPRODUCTION_MODE == "sexual": 36 # genomes = recombination(genomes, self.RECOMBINATION_RATE) 37 genomes = recombination_via_pairs(genomes, self.RECOMBINATION_RATE) 38 genomes, ages, muta_prob = pairing(Genomes(genomes), parental_sexes, ages, muta_prob) 39 40 genomes = self.mutator._mutate(genomes, muta_prob, ages) 41 genomes = Genomes(genomes) 42 return genomes
7class Reproducer: 8 """ 9 GUI 10 Individuals are fertile starting with [[MATURATION_AGE]] (can be 0) until [[REPRODUCTION_ENDPOINT]] (if 0, no REPRODUCTION_ENDPOINT occurs). 11 Reproduction can be sexual (with diploid genomes) or asexual (with diploid or haploid genomes). 12 When reproduction is sexual, recombination occurs in gametes at a rate of [[RECOMBINATION_RATE]] 13 and gametes will inherit mutations at an age-independent rate 14 which can be parameterized (genetics-independent) or set to evolve (genetics-dependent). 15 Mutations cause the offspring genome bit states to flip from 0-to-1 or 1-to-0. 16 The ratio of 0-to-1 and 1-to-0 can be modified using the [[MUTATION_RATIO]]. 17 18 If the population is oviparous, [[INCUBATION_PERIOD]] should be set to -1, 1 or greater. 19 When it is set to -1, all laid eggs hatch only once all living individuals die. 20 When it is set to 0 or greater, eggs hatch after that specified time. 21 Thus, when 0, individuals do not go through an egg stage during their life cycle. 22 """ 23 24 # TODO INCUBATION_PERIOD set to -1 or 1 or greater is stupid 25 # TODO INCUBATION_PERIOD is not really a part of this submodel, but it is in the documentation. it should be though. 26 27 # TODO probably better to split mutation logic into another domain and cluster together with genetic architecture stuff 28 29 def __init__(self, RECOMBINATION_RATE, REPRODUCTION_MODE, mutator): 30 self.RECOMBINATION_RATE = RECOMBINATION_RATE 31 self.REPRODUCTION_MODE = REPRODUCTION_MODE 32 self.mutator = mutator 33 34 def generate_offspring_genomes(self, genomes, muta_prob, ages, parental_sexes) -> Genomes: 35 36 if self.REPRODUCTION_MODE == "sexual": 37 # genomes = recombination(genomes, self.RECOMBINATION_RATE) 38 genomes = recombination_via_pairs(genomes, self.RECOMBINATION_RATE) 39 genomes, ages, muta_prob = pairing(Genomes(genomes), parental_sexes, ages, muta_prob) 40 41 genomes = self.mutator._mutate(genomes, muta_prob, ages) 42 genomes = Genomes(genomes) 43 return genomes
GUI Individuals are fertile starting with [[MATURATION_AGE]] (can be 0) until [[REPRODUCTION_ENDPOINT]] (if 0, no REPRODUCTION_ENDPOINT occurs). Reproduction can be sexual (with diploid genomes) or asexual (with diploid or haploid genomes). When reproduction is sexual, recombination occurs in gametes at a rate of [[RECOMBINATION_RATE]] and gametes will inherit mutations at an age-independent rate which can be parameterized (genetics-independent) or set to evolve (genetics-dependent). Mutations cause the offspring genome bit states to flip from 0-to-1 or 1-to-0. The ratio of 0-to-1 and 1-to-0 can be modified using the [[MUTATION_RATIO]].
If the population is oviparous, [[INCUBATION_PERIOD]] should be set to -1, 1 or greater. When it is set to -1, all laid eggs hatch only once all living individuals die. When it is set to 0 or greater, eggs hatch after that specified time. Thus, when 0, individuals do not go through an egg stage during their life cycle.
34 def generate_offspring_genomes(self, genomes, muta_prob, ages, parental_sexes) -> Genomes: 35 36 if self.REPRODUCTION_MODE == "sexual": 37 # genomes = recombination(genomes, self.RECOMBINATION_RATE) 38 genomes = recombination_via_pairs(genomes, self.RECOMBINATION_RATE) 39 genomes, ages, muta_prob = pairing(Genomes(genomes), parental_sexes, ages, muta_prob) 40 41 genomes = self.mutator._mutate(genomes, muta_prob, ages) 42 genomes = Genomes(genomes) 43 return genomes