Slightly tighter prune.

This commit is contained in:
Ryan Curtin
2015-03-12 15:42:45 -04:00
parent aa36ea42dc
commit bce6482563
2 changed files with 15 additions and 7 deletions
@@ -42,7 +42,7 @@ DualTreeKMeans<MetricType, MatType, TreeType>::DualTreeKMeans(
datasetCopy = datasetOrig;
// Now build the tree. We don't need any mappings.
tree = new TreeType(const_cast<typename TreeType::Mat&>(this->dataset), 1);
tree = new TreeType(const_cast<typename TreeType::Mat&>(this->dataset), 10);
Timer::Stop("tree_building");
}
@@ -312,8 +312,8 @@ closest << "! It's part of node r" << node->Begin() << "c" << node->Count() <<
else if (node->Stat().MaxQueryNodeDistance() < 0.5 *
interclusterDistances(0, owner))
{
Log::Warn << "Secondary Elkan prune! r" << node->Begin() << "c" <<
node->Count() << ".\n";
// Log::Warn << "Secondary Elkan prune! r" << node->Begin() << "c" <<
//node->Count() << ".\n";
node->Stat().HamerlyPruned() = true;
if (!node->Parent()->Stat().HamerlyPruned())
hamerlyPruned += node->NumDescendants();
@@ -148,10 +148,18 @@ double DualTreeKMeansRules<MetricType, TreeType>::Score(
if (distances.Lo() < referenceNode.Stat().MinQueryNodeDistance())
{
// This is the new closest node.
referenceNode.Stat().SecondMinQueryNodeDistance() =
referenceNode.Stat().MinQueryNodeDistance();
referenceNode.Stat().SecondMaxQueryNodeDistance() =
referenceNode.Stat().MaxQueryNodeDistance();
if (queryNode.NumDescendants() >= 2)
{
referenceNode.Stat().SecondMinQueryNodeDistance() = distances.Lo();
referenceNode.Stat().SecondMaxQueryNodeDistance() = distances.Hi();
}
else
{
referenceNode.Stat().SecondMinQueryNodeDistance() =
referenceNode.Stat().MinQueryNodeDistance();
referenceNode.Stat().SecondMaxQueryNodeDistance() =
referenceNode.Stat().MaxQueryNodeDistance();
}
referenceNode.Stat().MinQueryNodeDistance() = distances.Lo();
referenceNode.Stat().MaxQueryNodeDistance() = distances.Hi();
}