Go to the documentation of this file.
15 #ifndef MLPACK_METHODS_RANGE_SEARCH_RS_MODEL_HPP
16 #define MLPACK_METHODS_RANGE_SEARCH_RS_MODEL_HPP
22 #include <boost/variant.hpp>
31 template<
template<
typename TreeMetricType,
32 typename TreeStatType,
33 typename TreeMatType>
class TreeType>
46 std::vector<std::vector<size_t>>& neighbors;
48 std::vector<std::vector<double>>& distances;
52 template<
typename RSType>
57 std::vector<std::vector<size_t>>& neighbors,
58 std::vector<std::vector<double>>& distances):
75 const arma::mat& querySet;
79 std::vector<std::vector<size_t>>& neighbors;
81 std::vector<std::vector<double>>& distances;
83 const size_t leafSize;
86 template<
typename RSType>
87 void SearchLeaf(
RSType* rs)
const;
91 template<
template<
typename TreeMetricType,
92 typename TreeStatType,
93 typename TreeMatType>
class TreeType>
97 template<
template<
typename TreeMetricType,
98 typename TreeStatType,
99 typename TreeMatType>
class TreeType>
114 std::vector<std::vector<size_t>>& neighbors,
115 std::vector<std::vector<double>>& distances,
116 const size_t leafSize);
129 arma::mat&& referenceSet;
133 template<
typename RSType>
134 void TrainLeaf(
RSType* rs)
const;
138 template<
template<
typename TreeMetricType,
139 typename TreeStatType,
140 typename TreeMatType>
class TreeType>
144 template<
template<
typename TreeMetricType,
145 typename TreeStatType,
146 typename TreeMatType>
class TreeType>
160 const size_t leafSize);
170 template<
typename RSType>
181 template<
typename RSType>
195 template<
typename RSType>
208 template<
typename RSType>
247 boost::variant<RSType<tree::KDTree>*,
271 const bool randomBasis =
false);
302 template<
typename Archive>
344 const size_t leafSize,
346 const bool singleMode);
360 std::vector<std::vector<size_t>>& neighbors,
361 std::vector<std::vector<double>>& distances);
373 std::vector<std::vector<size_t>>& neighbors,
374 std::vector<std::vector<double>>& distances);
381 std::string TreeName()
const;
393 #include "rs_model_impl.hpp"
SingleModeVisitor exposes the SingleMode() method of the given RSType.
TreeTypes TreeType() const
Get the type of tree.
void operator()(RSTypeT< tree::KDTree > *rs) const
Bichromatic range search on the given RSType specialized for KDTrees.
RSModel(const RSModel &other)
Copy the given RSModel.
void operator()(RSTypeT< tree::BallTree > *rs) const
Train on the given RSType specialized for BallTrees.
bool SingleMode() const
Get whether the model is in single-tree search mode.
void operator()(RSTypeT< tree::Octree > *rs) const
Bichromatic range search specialized for octrees.
const arma::mat & Dataset() const
Expose the dataset.
const arma::mat & operator()(RSType *rs) const
Return the reference set.
ReferenceSetVisitor exposes the referenceSet of the given RSType.
RSModel(RSModel &&other)
Take ownership of the given RSModel.
bool & SingleMode()
Modify whether the model is in single-tree search mode.
bool & operator()(RSType *rs) const
Get a reference to the naive parameter of the given RangeSearch object.
BiSearchVisitor executes a bichromatic range search on the given RSType.
bool & Naive()
Modify whether the model is in naive search mode.
bool & operator()(RSType *rs) const
Get a reference to the singleMode parameter of the given RangeSeach object.
Linear algebra utility functions, generally performed on matrices or vectors.
bool Naive() const
Get whether the model is in naive search mode.
void operator()(RSTypeT< tree::Octree > *rs) const
Train specialized for octrees.
DeleteVisitor deletes the given RSType instance.
TrainVisitor sets the reference set to a new reference set on the given RSType.
RSModel(const TreeTypes treeType=TreeTypes::KD_TREE, const bool randomBasis=false)
Initialize the RSModel with the given type and whether or not a random basis should be used.
void BuildModel(arma::mat &&referenceSet, const size_t leafSize, const bool naive, const bool singleMode)
Build the reference tree on the given dataset with the given parameters.
MonoSearchVisitor executes a monochromatic range search on the given RSType.
void serialize(Archive &ar, const unsigned int)
Serialize the range search model.
size_t & LeafSize()
Modify the leaf size (applicable to everything but the cover tree).
BiSearchVisitor(const arma::mat &querySet, const math::Range &range, std::vector< std::vector< size_t >> &neighbors, std::vector< std::vector< double >> &distances, const size_t leafSize)
Construct the BiSearchVisitor.
NaiveVisitor exposes the Naive() method of the given RSType.
size_t LeafSize() const
Get the leaf size (applicable to everything but the cover tree).
RSModel & operator=(RSModel other)
Copy the given RSModel.
TrainVisitor(arma::mat &&referenceSet, const size_t leafSize)
Construct the TrainVisitor object with the given reference set, leafSize.
~RSModel()
Clean memory, if necessary.
bool & RandomBasis()
Modify whether a random basis is used (don't do this after the model has been built).
void Search(const math::Range &range, std::vector< std::vector< size_t >> &neighbors, std::vector< std::vector< double >> &distances)
Perform monochromatic range search, with the reference set as the query set.
bool RandomBasis() const
Get whether a random basis is used.
void operator()(RSType *rs) const
Delete the RSType object.
TreeTypes & TreeType()
Modify the type of tree (don't do this after the model has been built).
The RangeSearch class is a template class for performing range searches.
void operator()(RSTypeT< tree::KDTree > *rs) const
Train on the given RSType specialized for KDTrees.
void operator()(RSType *rs) const
Perform monochromatic search with the given RangeSearch object.
void Search(arma::mat &&querySet, const math::Range &range, std::vector< std::vector< size_t >> &neighbors, std::vector< std::vector< double >> &distances)
Perform range search.
void operator()(RSTypeT< tree::BallTree > *rs) const
Bichromatic range search on the given RSType specialized for BallTrees.
MonoSearchVisitor(const math::Range &range, std::vector< std::vector< size_t >> &neighbors, std::vector< std::vector< double >> &distances)
Construct the MonoSearchVisitor with the given parameters.