variations.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:GASP-python 作者: henniggroup 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号