Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Sparse implementation of EMD #683

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

tvayer
Copy link
Collaborator

@tvayer tvayer commented Oct 31, 2024

The goal is to return a sparse transport in ot.emd plan when the cost matrix matrix is itself sparse which corresponds to infinite cost between points, or when no value is given i.e. we know that no match is allowed.

Wishlist

  • Accelerate the EMD when the cost is sparse
  • Stay in O(nnz(C)) in memory

What we have

  • Working cython wrapper for coo cost matrix, it returns the same result at numerical precision

Working example:

from ot.lp import emd_wrap

# COO representation of cost
iM2 = sM2.row
jM2 = sM2.col
vM2 = sM2.data

maxitr= 1000000
g,ig,jg, cost, alpha, beta, result_code = emd_wrap.emd_c_sparse(a,b,iM2,jM2,vM2, np.int64(maxitr))

# recover the sparse plan
Gs = sp.sparse.coo_matrix((g, (ig, jg)), shape=(m,n))

What we want

  • Change the cpp of NetworkSimplex to remove the O(n^2) memory when associating the cost to each edge of the network flow

@github-actions github-actions bot added the ot.lp label Dec 17, 2024
Copy link

codecov bot commented Dec 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.06%. Comparing base (39cd6ec) to head (ba81674).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #683   +/-   ##
=======================================
  Coverage   97.06%   97.06%           
=======================================
  Files          98       98           
  Lines       19955    19955           
=======================================
  Hits        19370    19370           
  Misses        585      585           

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants