suttonchen.py 文件源码

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

项目:sdaopt 作者: sgubianpm 项目源码 文件源码
def sutton_chen(x):
    x = x.reshape((int(x.size/3), 3))
    idx = np.array(list(np.arange(0, x.shape[0])) * x.shape[0])
    jdx = np.concatenate([[a] * x.shape[0] for a in range(
        0, x.shape[0])])
    index = np.column_stack((idx, jdx))
    index = index[index[:, 0] < index[:, 1], :]
    rij = np.zeros(index.shape[0])
    for i in range(index.shape[0]):
        rij[i] = np.sqrt(np.sum((x[index[i, 0], :] - x[
            index[i, 1], :]) ** 2))
    f1s = np.zeros(index.shape[0])
    rhos = np.zeros(index.shape[0])
    for i in range(0, x.shape[0]):
        idx = np.logical_or(index[:, 0] == i, index[:, 1] == i)
        f1s[i] = 0.5 * (A**K) * np.sum(1/rij[idx] ** K)
        rhos[i] = (A**M) * sum(1/(rij[idx]) ** M)
    return np.sum(f1s - C * np.sqrt(rhos))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号