def compute_num_adds(self, cell, composition_space, random):
"""
Computes the number of atoms (or stoichiometries worth of atoms) to add
or remove. Returns a non-zero integer.
Args:
cell: the Cell of the parent organism
composition_space: the CompositionSpace of the search
random: a copy of Python's built in PRNG
"""
num_adds = int(round(random.gauss(self.mu_num_adds,
self.sigma_num_adds)))
# keep trying until we get a valid number
while num_adds == 0 or \
(composition_space.objective_function == 'epa' and num_adds*-1 >=
cell.num_sites/composition_space.endpoints[0].num_atoms) or \
(composition_space.objective_function == 'pd' and
num_adds*-1 >= cell.num_sites):
num_adds = int(round(random.gauss(self.mu_num_adds,
self.sigma_num_adds)))
return num_adds
评论列表
文章目录