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

Function compute_next_removal

ot/regpath.py:357–403  ·  view source on GitHub ↗

r""" This function computes the next gamma value if a variable is removed at the next iteration of the regularization path. We look for the largest value of the regularization parameter such that an element of the current solution vanishes .. math:: \max_{j \in A} \frac{\ph

(phi, delta, current_gamma)

Source from the content-addressed store, hash-verified

355
356
357def compute_next_removal(phi, delta, current_gamma):
358 r""" This function computes the next gamma value if a variable
359 is removed at the next iteration of the regularization path.
360
361 We look for the largest value of the regularization parameter such that
362 an element of the current solution vanishes
363
364 .. math::
365 \max_{j \in A} \frac{\phi_j}{\delta_j}
366
367 where :
368
369 - A is the current active set
370 - :math:`\phi_j` is the :math:`j` th element of the intercept of the \
371 current solution
372 - :math:`\delta_j` is the :math:`j` th element of the slope of the \
373 current solution
374
375
376 Parameters
377 ----------
378 phi : ndarray, shape (size(A), )
379 Intercept of the solution at the current iteration
380 delta : ndarray, shape (size(A), )
381 Slope of the solution at the current iteration
382 current_gamma : float
383 Value of the regularization parameter at the beginning of the \
384 current iteration
385
386 Returns
387 -------
388 next_removal_gamma : float
389 Gamma value if a variable is removed at the next iteration
390 next_removal_index : int
391 Index of the variable to be removed at the next iteration
392
393
394 .. _references-regpath:
395 References
396 ----------
397 .. [41] Chapel, L., Flamary, R., Wu, H., Févotte, C., and Gasso, G. (2021).
398 Unbalanced optimal transport through non-negative penalized
399 linear regression. NeurIPS.
400 """
401 r_candidate = phi / (delta - 1e-16)
402 r_candidate[r_candidate >= (1 - 1e-8) * current_gamma] = 0
403 return np.max(r_candidate), np.argmax(r_candidate)
404
405
406def complement_schur(M_current, b, d, id_pop):

Callers 2

fully_relaxed_pathFunction · 0.85
semi_relaxed_pathFunction · 0.85

Calls 2

maxMethod · 0.45
argmaxMethod · 0.45

Tested by

no test coverage detected