diff options
author | arolet <antoine.rolet@gmail.com> | 2017-07-21 13:33:44 +0900 |
---|---|---|
committer | arolet <antoine.rolet@gmail.com> | 2017-07-21 13:33:44 +0900 |
commit | db2a70b1f5146d6374af57f4bea66ab95b202e77 (patch) | |
tree | eb6fb01b1297c1350e7c1ea176c015d717697773 /ot | |
parent | 88c62c39a9623e8b58ebb776a9deddc96b43b4a0 (diff) |
Compute cost with primal
Diffstat (limited to 'ot')
-rw-r--r-- | ot/lp/EMD_wrapper.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ot/lp/EMD_wrapper.cpp b/ot/lp/EMD_wrapper.cpp index 6bda6a7..c6cbb04 100644 --- a/ot/lp/EMD_wrapper.cpp +++ b/ot/lp/EMD_wrapper.cpp @@ -93,12 +93,14 @@ void EMD_wrap(int n1, int n2, double *X, double *Y, double *D, double *G, } } else { - *cost = net.totalCost(); + *cost = 0; Arc a; di.first(a); for (; a != INVALID; di.next(a)) { int i = di.source(a); int j = di.target(a); - *(G+indI[i]*n2+indJ[j-n]) = net.flow(a); + double flow = net.flow(a); + *cost += flow * (*(D+indI[i]*n2+indJ[j-n])); + *(G+indI[i]*n2+indJ[j-n]) = flow; *(alpha + indI[i]) = net.potential(i); *(beta + indJ[j-n]) = net.potential(j); } |