13 #ifndef MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC_IMPL_HPP 14 #define MLPACK_CORE_TREE_RECTANGLE_TREE_R_TREE_DESCENT_HEURISTIC_IMPL_HPP 21 template<
typename TreeType>
26 typedef typename TreeType::ElemType ElemType;
28 ElemType minScore = std::numeric_limits<ElemType>::max();
30 ElemType bestVol = 0.0;
32 for (
size_t i = 0; i < node->NumChildren(); ++i)
36 for (
size_t j = 0; j < node->Child(i).Bound().Dim(); ++j)
38 v1 *= node->Child(i).Bound()[j].Width();
39 v2 *= node->Child(i).Bound()[j].Contains(node->Dataset().col(point)[j]) ?
40 node->Child(i).Bound()[j].Width() :
41 (node->Child(i).Bound()[j].Hi() < node->Dataset().col(point)[j] ?
42 (node->Dataset().col(point)[j] - node->Child(i).Bound()[j].Lo()) :
43 (node->Child(i).Bound()[j].Hi() - node->Dataset().col(point)[j]));
48 if ((v2 - v1) < minScore)
54 else if ((v2 - v1) == minScore && v1 < bestVol)
64 template<
typename TreeType>
67 const TreeType* insertedNode)
70 typedef typename TreeType::ElemType ElemType;
72 ElemType minScore = std::numeric_limits<ElemType>::max();
74 ElemType bestVol = 0.0;
76 for (
size_t i = 0; i < node->NumChildren(); ++i)
80 for (
size_t j = 0; j < node->Child(i).Bound().Dim(); ++j)
82 v1 *= node->Child(i).Bound()[j].Width();
83 v2 *= node->Child(i).Bound()[j].Contains(insertedNode->Bound()[j]) ?
84 node->Child(i).Bound()[j].Width() :
85 (insertedNode->Bound()[j].Contains(node->Child(i).Bound()[j]) ?
86 insertedNode->Bound()[j].Width() :
87 (insertedNode->Bound()[j].Lo() < node->Child(i).Bound()[j].Lo()
88 ? (node->Child(i).Bound()[j].Hi() -
89 insertedNode->Bound()[j].Lo()) : (insertedNode->Bound()[j].Hi() -
90 node->Child(i).Bound()[j].Lo())));
95 if ((v2 - v1) < minScore)
101 else if ((v2 - v1) == minScore && v1 < bestVol)
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
static size_t ChooseDescentNode(const TreeType *node, const size_t point)
Evaluate the node using a heuristic.
Definition: r_tree_descent_heuristic_impl.hpp:22