diff --git a/RELEASES.md b/RELEASES.md index 049ce18d0..3ed17c8a7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -45,6 +45,7 @@ This new release adds support for sparse cost matrices and a new lazy EMD solver - Reverting the openmp fix on macOS (PR #789) for macOS (PR #797) - Align documentation build dependencies and doc extras (PR #801) - Debug Debug linux test core dump (PR #815) +- Fix entropic regularization in `gcg`(PR #817, Issue #758) - Fix documentation build on master with submodules (PR #818) ## 0.9.6.post1 diff --git a/ot/optim.py b/ot/optim.py index e6246b3c1..35f819c19 100644 --- a/ot/optim.py +++ b/ot/optim.py @@ -910,7 +910,7 @@ def line_search(cost, G, deltaG, Mi, cost_G, df_G, **kwargs): f, df, reg2, - reg1, + None, lp_solver, line_search, G0=G0, diff --git a/test/test_optim.py b/test/test_optim.py index 2d4b4d0ff..b54c267dc 100644 --- a/test/test_optim.py +++ b/test/test_optim.py @@ -123,6 +123,37 @@ def fb(G): np.testing.assert_allclose(b, Gb.sum(0), atol=1e-05) +def test_gcg_no_reg(): + n = 100 + X = ot.datasets.make_2D_samples_gauss(n, m=[0, 0], sigma=np.eye(2)) + Y = ot.datasets.make_2D_samples_gauss(n, m=[1, 1], sigma=np.eye(2)) + + a = ot.unif(n) + b = ot.unif(n) + + M = ot.dist(X, Y) + M /= M.max() + + eps = 1e-2 + + G_gcg = ot.optim.gcg( + a, + b, + M, + eps, + 0.0, + lambda x: 0.0, + lambda x: np.zeros(x.shape), + numInnerItermax=1000, + numItermax=10, + ) + G_sinkhorn = ot.sinkhorn(a, b, M, eps, numItermax=1000) + + np.testing.assert_allclose(G_gcg, G_sinkhorn, atol=1e-12) + np.testing.assert_allclose(a, G_gcg.sum(1), atol=1e-5) + np.testing.assert_allclose(b, G_gcg.sum(0), atol=1e-5) + + def test_solve_1d_linesearch_quad_funct(): np.testing.assert_allclose(ot.optim.solve_1d_linesearch_quad(1, -1), 0.5) np.testing.assert_allclose(ot.optim.solve_1d_linesearch_quad(-1, 5), 0)