[mlpack] 169/324: Fix elusive bug that only occurred in particularly rare situations.

Barak A. Pearlmutter barak+git at cs.nuim.ie
Sun Aug 17 08:22:07 UTC 2014


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch svn-trunk
in repository mlpack.

commit 6ae18f1a57b0df313c303561cce49fc8ade2c063
Author: rcurtin <rcurtin at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Thu Jul 10 14:04:45 2014 +0000

    Fix elusive bug that only occurred in particularly rare situations.
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@16808 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 .../methods/neighbor_search/neighbor_search_rules_impl.hpp | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp b/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
index 5b4eca9..5b4bb2b 100644
--- a/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
+++ b/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
@@ -151,7 +151,9 @@ inline double NeighborSearchRules<SortPolicy, MetricType, TreeType>::Score(
   const double score = traversalInfo.LastScore();
   double adjustedScore;
 
-  // In some cases we can just use the last base case.
+  // We want to set adjustedScore to be the distance between the centroid of the
+  // last query node and last reference node.  We will do this by adjusting the
+  // last score.  In some cases, we can just use the last base case.
   if (tree::TreeTraits<TreeType>::FirstPointIsCentroid)
   {
     adjustedScore = traversalInfo.LastBaseCase();
@@ -162,10 +164,16 @@ inline double NeighborSearchRules<SortPolicy, MetricType, TreeType>::Score(
   }
   else
   {
+    // The last score is equal to the distance between the centroids minus the
+    // radii of the query and reference bounds along the axis of the line
+    // between the two centroids.  In the best case, these radii are the
+    // furthest descendant distances, but that is not always true.  It would
+    // take too long to calculate the exact radii, so we are forced to use
+    // MinimumBoundDistance() as a lower-bound approximation.
     const double lastQueryDescDist =
-        traversalInfo.LastQueryNode()->FurthestDescendantDistance();
+        traversalInfo.LastQueryNode()->MinimumBoundDistance();
     const double lastRefDescDist =
-        traversalInfo.LastReferenceNode()->FurthestDescendantDistance();
+        traversalInfo.LastReferenceNode()->MinimumBoundDistance();
     adjustedScore = SortPolicy::CombineWorst(score, lastQueryDescDist);
     adjustedScore = SortPolicy::CombineWorst(score, lastRefDescDist);
   }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git



More information about the debian-science-commits mailing list