r""" Solve the general regularized OT problem or its semi-relaxed version with conditional gradient or generalized conditional gradient depending on the provided linear program solver. The function solves the following optimization problem if set as a conditional gradient:
(
a,
b,
M,
f,
df,
reg1,
reg2,
lp_solver,
line_search,
G0=None,
numItermax=200,
stopThr=1e-9,
stopThr2=1e-9,
verbose=False,
log=False,
nx=None,
**kwargs,
)
| 141 | |
| 142 | |
| 143 | def generic_conditional_gradient( |
| 144 | a, |
| 145 | b, |
| 146 | M, |
| 147 | f, |
| 148 | df, |
| 149 | reg1, |
| 150 | reg2, |
| 151 | lp_solver, |
| 152 | line_search, |
| 153 | G0=None, |
| 154 | numItermax=200, |
| 155 | stopThr=1e-9, |
| 156 | stopThr2=1e-9, |
| 157 | verbose=False, |
| 158 | log=False, |
| 159 | nx=None, |
| 160 | **kwargs, |
| 161 | ): |
| 162 | r""" |
| 163 | Solve the general regularized OT problem or its semi-relaxed version with |
| 164 | conditional gradient or generalized conditional gradient depending on the |
| 165 | provided linear program solver. |
| 166 | |
| 167 | The function solves the following optimization problem if set as a conditional gradient: |
| 168 | |
| 169 | .. math:: |
| 170 | \gamma = \mathop{\arg \min}_\gamma \quad \langle \gamma, \mathbf{M} \rangle_F + |
| 171 | \mathrm{reg_1} \cdot f(\gamma) |
| 172 | |
| 173 | s.t. \ \gamma \mathbf{1} &= \mathbf{a} |
| 174 | |
| 175 | \gamma^T \mathbf{1} &= \mathbf{b} (optional constraint) |
| 176 | |
| 177 | \gamma &\geq 0 |
| 178 | |
| 179 | where : |
| 180 | |
| 181 | - :math:`\mathbf{M}` is the (`ns`, `nt`) metric cost matrix |
| 182 | - :math:`f` is the regularization term (and `df` is its gradient) |
| 183 | - :math:`\mathbf{a}` and :math:`\mathbf{b}` are source and target weights (sum to 1) |
| 184 | |
| 185 | The algorithm used for solving the problem is conditional gradient as discussed in :ref:`[1] <references-cg>` |
| 186 | |
| 187 | The function solves the following optimization problem if set a generalized conditional gradient: |
| 188 | |
| 189 | .. math:: |
| 190 | \gamma = \mathop{\arg \min}_\gamma \quad \langle \gamma, \mathbf{M} \rangle_F + |
| 191 | \mathrm{reg_1}\cdot f(\gamma) + \mathrm{reg_2}\cdot\Omega(\gamma) |
| 192 | |
| 193 | s.t. \ \gamma \mathbf{1} &= \mathbf{a} |
| 194 | |
| 195 | \gamma^T \mathbf{1} &= \mathbf{b} |
| 196 | |
| 197 | \gamma &\geq 0 |
| 198 | |
| 199 | where : |
| 200 |
no test coverage detected