Be more careful about when to take the last SCB. This gives a trivial speedup, but hey, speedup! Hamerly prunes are still not working properly, but I'm getting there.

This commit is contained in:
Ryan Curtin
2015-03-12 15:42:44 -04:00
parent db0d792ef8
commit abfc0b8e4d
@@ -220,12 +220,14 @@ void DualTreeKMeans<MetricType, MatType, TreeType>::TreeUpdate(
// Re-set second closest bound if necessary.
if (node->Stat().SecondClosestBound() == DBL_MAX)
{
if (node->Begin() == 34654)
Log::Warn << "r34654c" << node->Begin() << " scb is DBL_MAX!\n";
if (node->Parent() == NULL)
node->Stat().SecondClosestBound() = 0.0; // Don't prune the root.
}
else
{
if (node->Parent()->Stat().SecondClosestBound() != DBL_MAX &&
if (node->Parent()->Stat().SecondClosestBound() != DBL_MAX &&
node->Stat().LastSecondClosestBound() != DBL_MAX)
node->Stat().SecondClosestBound() =
std::max(node->Parent()->Stat().SecondClosestBound(),
@@ -234,14 +236,12 @@ node->Stat().LastSecondClosestBound());
node->Stat().SecondClosestBound() =
std::min(node->Parent()->Stat().SecondClosestBound(),
node->Stat().LastSecondClosestBound());
}
// if (node->Begin() == 35871)
// Log::Warn << "Update second closest bound for r35871c" <<
//node->Count() << " to " << node->Stat().SecondClosestBound() << ", which could "
// << "have been parent's (" << node->Parent()->Stat().SecondClosestBound()
//<< ") or adjusted last iteration's (" << node->Stat().LastSecondClosestBound()
//<< ").\n";
}
// if (node->Begin() == 35871)
// Log::Warn << "r35871c" << node->Count() << " has second bound " <<
@@ -268,6 +268,15 @@ node->Parent()->Stat().SecondClosestBound() < node->Stat().SecondClosestBound())
node->Parent()->Stat().SecondClosestBound();
}
if (node->Begin() == 34654)
{
Log::Warn << "Attempt Hamerly prune on r34654c" << node->Count() <<
" with MQND " << node->Stat().MaxQueryNodeDistance() << ", scb "
<< node->Stat().SecondClosestBound() << ", owner " <<
node->Stat().Owner() << ", and clusterDistances " << clusterDistances[clusters]
<< ".\n";
}
if (node->Stat().MaxQueryNodeDistance() < node->Stat().SecondClosestBound()
- clusterDistances[clusters])
{