本文整理汇总了Python中Population.Population.abundances[2**genome_length]方法的典型用法代码示例。如果您正苦于以下问题:Python Population.abundances[2**genome_length]方法的具体用法?Python Population.abundances[2**genome_length]怎么用?Python Population.abundances[2**genome_length]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population.Population
的用法示例。
在下文中一共展示了Population.abundances[2**genome_length]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import abundances[2**genome_length] [as 别名]
#.........这里部分代码省略.........
config.set(section='RegularTopology', option='seed', value=self.config.get(section='Simulation', option='seed'))
seed = self.config.getint(section='RegularTopology', option='seed')
self.topology = topology.regular(size=size, degree=degree,
seed=seed)
export_topology = self.config.getboolean(section='Simulation',
option='export_topology')
# Export the structure of the topology, allowing the topology to be
# re-created. This is especially useful for randomly-generated
# topologies.
if export_topology:
data_dir = self.config.get(section='Simulation', option='data_dir')
nx.write_gml(self.topology, os.path.join(data_dir, 'topology.gml'))
# Store the probabilities of mutations between all pairs of genotypes
self.mutation_probs = self.get_mutation_probabilities()
# Create the fitness landscape
self.fitness_landscape = self.build_fitness_landscape()
initial_state = self.config.get(section='Metapopulation',
option='initial_state')
genome_length = self.config.getint(section='Population',
option='genome_length')
max_cap = self.config.getint(section='Population', option='capacity_max')
min_cap = self.config.getint(section='Population', option='capacity_min')
initial_producer_proportion = self.config.getfloat(section='Population',
option='initial_producer_proportion')
mutation_rate_tolerance = self.config.getfloat(section='Population',
option='mutation_rate_tolerance')
# Create each of the populations
for n, d in self.topology.nodes_iter(data=True):
d['population'] = Population(metapopulation=self, config=config)
if initial_state == 'corners':
# Place all producers in one corner and all non-producers in
# the other
if n == 0:
d['population'].abundances[2**genome_length] = max_cap
d['population'].dilute(stochastic=self.dilution_stochastic)
elif n == len(self.topology)-1:
d['population'].abundances[0] = min_cap
d['population'].dilute(stochastic=self.dilution_stochastic)
elif initial_state == 'stress':
cap = int(min_cap + ( (max_cap - min_cap) * initial_producer_proportion))
num_producers = int(cap * initial_producer_proportion)
num_nonproducers = cap - num_producers
d['population'].abundances[0] = num_producers
d['population'].abundances[2**genome_length] = num_nonproducers
d['population'].bottleneck(survival_rate=mutation_rate_tolerance)
# How frequently should the metapopulation be mixed?
self.mix_frequency = self.config.getint(section='Metapopulation',
option='mix_frequency')
assert self.mix_frequency >= 0
# How frequently should the environment be changed?
self.environment_changed = False
self.env_change_frequency = self.config.getint(section='Metapopulation',
option='env_change_frequency')
assert self.env_change_frequency >= 0
data_dir = self.config.get(section='Simulation', option='data_dir')
self.log_demographics = self.config.getboolean(section='Simulation',
option='log_demographics')
self.log_genotypes = self.config.getboolean(section='Simulation',
option='log_genotypes')
self.log_fitness = self.config.getboolean(section='Simulation',
option='log_fitness')
# log_objects is a list of any logging objects used by this simulation
self.log_objects = []
if self.log_demographics:
out_demographics = DemographicsOutput(metapopulation=self,
filename=os.path.join(data_dir, 'demographics.csv.bz2'))
self.log_objects.append(out_demographics)
if self.log_genotypes:
out_genotypes = GenotypesOutput(metapopulation=self,
filename=os.path.join(data_dir, 'genotypes.csv.bz2'))
self.log_objects.append(out_genotypes)
if self.log_fitness:
out_fitness = FitnessOutput(metapopulation=self,
filename=os.path.join(data_dir, 'fitness.csv.bz2'))
self.log_objects.append(out_fitness)