Skip to content

Commit

Permalink
Reduce LAP comparison precision (#33)
Browse files Browse the repository at this point in the history
* Remove soft_lap. Precision 4 works; let's conservatively go to 8.

* Update metatext

* Arithmetic sequence

* Document
  • Loading branch information
ms609 authored Aug 17, 2020
1 parent ce5ffa4 commit e9ae788
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
10 changes: 10 additions & 0 deletions R/lap.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
#' The Jonker & Volgenant approach is a faster alternative to the Hungarian
#' algorithm (Munkres 1957), which is implemented in `clue::solve_LSAP()`.
#'
#' Note: the JV algorithm expects integers. In order to apply the function
#' to a non-integer _n_, as in the tree distance calculations in this package,
#' each _n_ is multiplied by the largest available integer before applying
#' the JV algorithm. If two values of _n_ exhibit a trivial difference --
#' e.g. due to floating point errors -- then this can lead to interminable
#' run times. (If numbers of the magnitude of billions differ only in their
#' last significant digit, then the JV algorithm may undergo billions of
#' iterations.) To avoid this, integers over 2^22 that differ by a value of
#' 8 or less are treated as equal.
#'
#' NB. At present, only square matrices are supported; if you need support for
#' non-square matrices, drop a note at
#' [issue #25](https://github.com/ms609/TreeDist/issues/25)
Expand Down
10 changes: 10 additions & 0 deletions man/LAPJV.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/tree_distances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,13 @@ List cpp_mutual_clustering (const RawMatrix x, const RawMatrix y,
} else {
score[ai][bi] = max_score -
// Division by n_tips converts n(A&B) to P(A&B) for each ic_element
cost((max_score / double(n_tips)) * (
cost(max_score * ((
// 0 < Sum of IC_elements <= n_tips
ic_element(a_and_b, na, nb, n_tips) +
ic_element(a_and_B, na, nB, n_tips) +
ic_element(A_and_b, nA, nb, n_tips) +
ic_element(A_and_B, nA, nB, n_tips)
)
ic_element(a_and_B, na, nB, n_tips) +
ic_element(A_and_b, nA, nb, n_tips) +
ic_element(A_and_B, nA, nB, n_tips)
) / n_tips)
);
}
}
Expand Down

0 comments on commit e9ae788

Please sign in to comment.