@@ -0,0 +1,1299 @@
+%0A%0Aimport ot%0Aimport numpy as np%0A%0A# import pytest%0A%0A%0Adef test_conditional_gradient():%0A%0A    n = 100  # nb bins%0A%0A    # bin positions%0A    x = np.arange(n, dtype=np.float64)%0A%0A    # Gaussian distributions%0A    a = ot.datasets.get_1D_gauss(n, m=20, s=5)  # m= mean, s= std%0A    b = ot.datasets.get_1D_gauss(n, m=60, s=10)%0A%0A    # loss matrix%0A    M = ot.dist(x.reshape((n, 1)), x.reshape((n, 1)))%0A    M /= M.max()%0A%0A    def f(G):%0A        return 0.5 * np.sum(G**2)%0A%0A    def df(G):%0A        return G%0A%0A    reg = 1e-1%0A%0A    G, log = ot.optim.cg(a, b, M, reg, f, df, verbose=True, log=True)%0A%0A    assert np.allclose(a, G.sum(1))%0A    assert np.allclose(b, G.sum(0))%0A%0A%0Adef test_generalized_conditional_gradient():%0A%0A    n = 100  # nb bins%0A%0A    # bin positions%0A    x = np.arange(n, dtype=np.float64)%0A%0A    # Gaussian distributions%0A    a = ot.datasets.get_1D_gauss(n, m=20, s=5)  # m= mean, s= std%0A    b = ot.datasets.get_1D_gauss(n, m=60, s=10)%0A%0A    # loss matrix%0A    M = ot.dist(x.reshape((n, 1)), x.reshape((n, 1)))%0A    M /= M.max()%0A%0A    def f(G):%0A        return 0.5 * np.sum(G**2)%0A%0A    def df(G):%0A        return G%0A%0A    reg1 = 1e-3%0A    reg2 = 1e-1%0A%0A    G, log = ot.optim.gcg(a, b, M, reg1, reg2, f, df, verbose=True, log=True)%0A%0A    assert np.allclose(a, G.sum(1), atol=1e-05)%0A    assert np.allclose(b, G.sum(0), atol=1e-05)%0A

add test optim