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

Function ot_next_gamma

ot/regpath.py:215–277  ·  view source on GitHub ↗

r""" This function computes the next value of gamma if a variable is added in the next iteration of the regularization path. We look for the largest value of gamma such that the gradient of an inactive variable vanishes .. math:: \max_{i \in \bar{A}} \frac{\mathbf{h}_i^T(H_

(phi, delta, HtH, Hty, c, active_index, current_gamma)

Source from the content-addressed store, hash-verified

213
214
215def ot_next_gamma(phi, delta, HtH, Hty, c, active_index, current_gamma):
216 r""" This function computes the next value of gamma if a variable
217 is added in the next iteration of the regularization path.
218
219 We look for the largest value of gamma such that
220 the gradient of an inactive variable vanishes
221
222 .. math::
223 \max_{i \in \bar{A}} \frac{\mathbf{h}_i^T(H_A \phi - \mathbf{y})}
224 {\mathbf{h}_i^T H_A \delta - \mathbf{c}_i}
225
226 where :
227
228 - A is the current active set
229 - :math:`\mathbf{h}_i` is the :math:`i` th column of the design \
230 matrix :math:`{H}`
231 - :math:`{H}_A` is the sub-matrix constructed by the columns of \
232 :math:`{H}` whose indices belong to the active set A
233 - :math:`\mathbf{c}_i` is the :math:`i` th element of the cost vector \
234 :math:`\mathbf{c}`
235 - :math:`\mathbf{y}` is the concatenation of the source and target \
236 distributions
237 - :math:`\phi` is the intercept of the solutions at the current iteration
238 - :math:`\delta` is the slope of the solutions at the current iteration
239
240 Parameters
241 ----------
242 phi : np.ndarray (size(A), )
243 Intercept of the solutions at the current iteration
244 delta : np.ndarray (size(A), )
245 Slope of the solutions at the current iteration
246 HtH : np.ndarray (dim_a * dim_b, dim_a * dim_b)
247 Matrix product of :math:`{H}^T {H}`
248 Hty : np.ndarray (dim_a + dim_b, )
249 Matrix product of :math:`{H}^T \mathbf{y}`
250 c: np.ndarray (dim_a * dim_b, )
251 Flattened array of the cost matrix :math:`{C}`
252 active_index : list
253 Indices of active variables
254 current_gamma : float
255 Value of the regularization parameter at the beginning of the current \
256 iteration
257
258 Returns
259 -------
260 next_gamma : float
261 Value of gamma if a variable is added to active set in next iteration
262 next_active_index : int
263 Index of variable to be activated
264
265
266 References
267 ----------
268 .. [41] Chapel, L., Flamary, R., Wu, H., Févotte, C., and Gasso, G. (2021).
269 Unbalanced optimal transport through non-negative penalized
270 linear regression. NeurIPS.
271 """
272 M = (HtH[:, active_index].dot(phi) - Hty) / (

Callers 1

fully_relaxed_pathFunction · 0.85

Calls 3

dotMethod · 0.45
maxMethod · 0.45
argmaxMethod · 0.45

Tested by

no test coverage detected