fitness_transformations.py 文件源码

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

项目:pycma 作者: CMA-ES 项目源码 文件源码
def __call__(self, *args, **kwargs):
        # late initialization if necessary
        try:
            if not self.__initialized:
                raise AttributeError
        except AttributeError:
            Function.initialize(self, None)
        # find the "right" callable
        callable_ = self.__callable
        if callable_ is None:
            for name in self.function_names_to_evaluate_first_found:
                try:
                    callable_ = getattr(self, name)
                    break
                except AttributeError:
                    pass
        # call with each vector
        if callable_ is not None:
            X, list_revert = utils.as_vector_list(args[0])
            self.evaluations += len(X)
            return list_revert([
                    callable_(np.asarray(x), *args[1:], **kwargs)
                    for x in X])
        else:
            self.evaluations += 1  # somewhat bound to fail
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号