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 5 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

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

Successfully merging this pull request may close these issues.

2 participants