MCPcopy Create free account
hub / github.com/PythonOT/POT / partial_wasserstein_lagrange

Function partial_wasserstein_lagrange

ot/partial/partial_solvers.py:20–184  ·  view source on GitHub ↗

r""" Solves the partial optimal transport problem for the quadratic cost and returns the OT plan The function considers the following problem: .. math:: \gamma = \mathop{\arg \min}_\gamma \quad \langle \gamma, (\mathbf{M} - \lambda) \rangle_F .. math:: s.t. \ \

(
    a, b, M, reg_m=None, nb_dummies=1, log=False, **kwargs
)

Source from the content-addressed store, hash-verified

18
19
20def partial_wasserstein_lagrange(
21 a, b, M, reg_m=None, nb_dummies=1, log=False, **kwargs
22):
23 r"""
24 Solves the partial optimal transport problem for the quadratic cost
25 and returns the OT plan
26
27 The function considers the following problem:
28
29 .. math::
30 \gamma = \mathop{\arg \min}_\gamma \quad \langle \gamma, (\mathbf{M} - \lambda) \rangle_F
31
32 .. math::
33 s.t. \ \gamma \mathbf{1} &\leq \mathbf{a}
34
35 \gamma^T \mathbf{1} &\leq \mathbf{b}
36
37 \gamma &\geq 0
38
39 \mathbf{1}^T \gamma^T \mathbf{1} = m &
40 \leq \min\{\|\mathbf{a}\|_1, \|\mathbf{b}\|_1\}
41
42
43 or equivalently (see Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X.
44 (2018). An interpolating distance between optimal transport and Fisher–Rao
45 metrics. Foundations of Computational Mathematics, 18(1), 1-44.)
46
47 .. math::
48 \gamma = \mathop{\arg \min}_\gamma \quad \langle \gamma, \mathbf{M} \rangle_F +
49 \sqrt{\frac{\lambda}{2} (\|\gamma \mathbf{1} - \mathbf{a}\|_1 + \|\gamma^T \mathbf{1} - \mathbf{b}\|_1)}
50
51 s.t. \ \gamma \geq 0
52
53
54 where :
55
56 - :math:`\mathbf{M}` is the metric cost matrix
57 - :math:`\mathbf{a}` and :math:`\mathbf{b}` are source and target unbalanced distributions
58 - :math:`\lambda` is the lagrangian cost. Tuning its value allows attaining
59 a given mass to be transported `m`
60
61 The formulation of the problem has been proposed in
62 :ref:`[28] <references-partial-wasserstein-lagrange>`
63
64
65 Parameters
66 ----------
67 a : np.ndarray (dim_a,)
68 Unnormalized histogram of dimension `dim_a`
69 b : np.ndarray (dim_b,)
70 Unnormalized histograms of dimension `dim_b`
71 M : np.ndarray (dim_a, dim_b)
72 cost matrix for the quadratic cost
73 reg_m : float, optional
74 Lagrangian cost
75 nb_dummies : int, optional, default:1
76 number of reservoir points to be added (to avoid numerical
77 instabilities, increase its value if an error is raised)

Callers 1

partial_wassersteinFunction · 0.85

Calls 10

list_to_arrayFunction · 0.85
get_backendFunction · 0.85
emdFunction · 0.85
to_numpyMethod · 0.80
from_numpyMethod · 0.80
sumMethod · 0.45
maxMethod · 0.45
zerosMethod · 0.45
whereMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected