POT
POT copied to clipboard
[WIP] Sparse implementation of EMD
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
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
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