15 #ifndef MLPACK_CORE_TREE_SPILL_TREE_SPILL_SINGLE_TREE_TRAVERSER_IMPL_HPP 16 #define MLPACK_CORE_TREE_SPILL_TREE_SPILL_SINGLE_TREE_TRAVERSER_IMPL_HPP 24 template<
typename MetricType,
25 typename StatisticType,
27 template<
typename HyperplaneMetricType>
class HyperplaneType,
28 template<
typename SplitMetricType,
typename SplitMatType>
30 template<
typename RuleType,
bool Defeatist>
38 template<
typename MetricType,
39 typename StatisticType,
41 template<
typename HyperplaneMetricType>
class HyperplaneType,
42 template<
typename SplitMetricType,
typename SplitMatType>
44 template<
typename RuleType,
bool Defeatist>
47 const size_t queryIndex,
50 const bool bruteForce)
54 if (!bruteForce && Defeatist &&
56 (referenceNode.
Parent() != NULL) &&
57 (referenceNode.
Parent()->Overlap()))
61 else if (referenceNode.
IsLeaf() || bruteForce)
64 rule.BaseCase(queryIndex, referenceNode.
Descendant(i));
68 if (Defeatist && referenceNode.
Overlap())
71 size_t bestChild = rule.GetBestChild(queryIndex, referenceNode);
78 double leftScore = rule.Score(queryIndex, *referenceNode.
Left());
79 double rightScore = rule.Score(queryIndex, *referenceNode.
Right());
81 if (leftScore < rightScore)
87 rightScore = rule.Rescore(queryIndex, *referenceNode.
Right(),
90 if (rightScore != DBL_MAX)
95 else if (rightScore < leftScore)
101 leftScore = rule.Rescore(queryIndex, *referenceNode.
Left(), leftScore);
103 if (leftScore != DBL_MAX)
110 if (leftScore == DBL_MAX)
120 rightScore = rule.Rescore(queryIndex, *referenceNode.
Right(),
123 if (rightScore != DBL_MAX)
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
SpillTree & Child(const size_t child) const
Return the specified child (0 will be left, 1 will be right).
Definition: spill_tree_impl.hpp:631
void Traverse(const size_t queryIndex, SpillTree &referenceNode, const bool bruteForce=false)
Traverse the tree with the given point.
Definition: spill_single_tree_traverser_impl.hpp:46
SpillTree * Right() const
Gets the right child of this node.
Definition: spill_tree.hpp:262
A hybrid spill tree is a variant of binary space trees in which the children of a node can "spill ove...
Definition: spill_tree.hpp:73
bool Overlap() const
Distinguish overlapping nodes from non-overlapping nodes.
Definition: spill_tree.hpp:275
size_t NumDescendants() const
Return the number of descendants of this node.
Definition: spill_tree_impl.hpp:666
SpillTree * Parent() const
Gets the parent of this node.
Definition: spill_tree.hpp:267
SpillTree * Left() const
Gets the left child of this node.
Definition: spill_tree.hpp:257
bool IsLeaf() const
Return whether or not this node is a leaf (true if it has no children).
Definition: spill_tree_impl.hpp:433
size_t Descendant(const size_t index) const
Return the index (with reference to the dataset) of a particular descendant of this node...
Definition: spill_tree_impl.hpp:681
SpillSingleTreeTraverser(RuleType &rule)
Instantiate the single tree traverser with the given rule set.
Definition: spill_single_tree_traverser_impl.hpp:32