Skip to content
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ot/optim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
31 changes: 31 additions & 0 deletions test/test_optim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading