optimalks.py 文件源码

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

项目:det_k_bisbm 作者: junipertcy 项目源码 文件源码
def _check_if_local_minimum(self, ka, kb, old_desc_len, k_th):
        '''
            The `neighborhood search` as described in the paper.
        '''
        self.is_tempfile_existed = True
        items = map(lambda x: (x[0] + ka, x[1] + kb), product(range(-k_th, k_th + 1), repeat=2))
        # if any item has values less than 1, delete it. Also, exclude the suspected point.
        items = [(i, j) for i, j in items if i >= 1 and j >= 1 and (i, j) != (ka, kb)]
        ka_moving, kb_moving = 0, 0

        for item in items:
            self._calc_and_update(item, old_desc_len)
            if self._is_this_mdl(self.confident_desc_len[(item[0], item[1])]):
                p_estimate = sorted(self.confident_desc_len, key=self.confident_desc_len.get)[0]
                self._logger.info("Found {} that gives an even lower description length ...".format(p_estimate))
                ka_moving, kb_moving, _, _ = self._back_to_where_desc_len_is_lowest()
                break
        if ka_moving * kb_moving == 0:
            return True
        else:
            return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号