test_ot.py 文件源码

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

项目:POT 作者: rflamary 项目源码 文件源码
def check_duality_gap(a, b, M, G, u, v, cost):
    cost_dual = np.vdot(a, u) + np.vdot(b, v)
    # Check that dual and primal cost are equal
    np.testing.assert_almost_equal(cost_dual, cost)

    [ind1, ind2] = np.nonzero(G)

    # Check that reduced cost is zero on transport arcs
    np.testing.assert_array_almost_equal((M - u.reshape(-1, 1) - v.reshape(1, -1))[ind1, ind2],
                                         np.zeros(ind1.size))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号