[mlpack-git] master, mlpack-1.0.x: When the parent-child rule can't be applied, the correct bound wasn't being used before. This fixes that. (32fdc74)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:44:03 EST 2015


Repository : https://github.com/mlpack/mlpack

On branches: master,mlpack-1.0.x
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

>---------------------------------------------------------------

commit 32fdc7404a7ab8fa5ffb98bc7a5e9c15fdbce32c
Author: Ryan Curtin <ryan at ratml.org>
Date:   Wed Feb 19 14:57:22 2014 +0000

    When the parent-child rule can't be applied, the correct bound wasn't being used
    before.  This fixes that.


>---------------------------------------------------------------

32fdc7404a7ab8fa5ffb98bc7a5e9c15fdbce32c
 .../methods/neighbor_search/neighbor_search_rules_impl.hpp   | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 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 031965c..639483b 100644
--- a/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
+++ b/src/mlpack/methods/neighbor_search/neighbor_search_rules_impl.hpp
@@ -183,7 +183,11 @@ inline double NeighborSearchRules<SortPolicy, MetricType, TreeType>::Score(
   }
   else
   {
-    adjustedScore = SortPolicy::CombineBest(adjustedScore, queryDescDist);
+    // If the parent node is NULL, force adjustedScore to be such that it can't
+    // be pruned.  Otherwise use the parent descendant distance.
+    const double queryParentDescDist = (queryNode.Parent() == NULL) ?
+        bestDistance : queryNode.Parent()->FurthestDescendantDistance();
+    adjustedScore = SortPolicy::CombineBest(adjustedScore, queryParentDescDist);
   }
 
   if (traversalInfo.LastReferenceNode() == referenceNode.Parent())
@@ -193,7 +197,11 @@ inline double NeighborSearchRules<SortPolicy, MetricType, TreeType>::Score(
   }
   else
   {
-    adjustedScore = SortPolicy::CombineBest(adjustedScore, refDescDist);
+    // If the parent node is NULL, force adjustedScore to be such that it can't
+    // be pruned.  Otherwise use the parent descendant distance.
+    const double refParentDescDist = (referenceNode.Parent() == NULL) ?
+        bestDistance : referenceNode.Parent()->FurthestDescendantDistance();
+    adjustedScore = SortPolicy::CombineBest(adjustedScore, refParentDescDist);
   }
 
   // Can we prune?



More information about the mlpack-git mailing list